* notify theme loading with --load-extension
* fix crasher in theme parsing with no images

Review URL: http://codereview.chromium.org/160124

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21619 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 2810b66..0ef074c 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -483,6 +483,15 @@
         NotificationType::EXTENSIONS_LOADED,
         Source<ExtensionsService>(this),
         Details<ExtensionList>(&enabled_extensions));
+    for (ExtensionList::iterator iter = enabled_extensions.begin();
+         iter != enabled_extensions.end(); ++iter) {
+      if ((*iter)->IsTheme() && (*iter)->location() == Extension::LOAD) {
+        NotificationService::current()->Notify(
+            NotificationType::THEME_INSTALLED,
+            Source<ExtensionsService>(this),
+            Details<Extension>(*iter));
+      }
+    }
   }
 }
 
@@ -755,19 +764,21 @@
   // Theme resource validation.
   if (extension->IsTheme()) {
     DictionaryValue* images_value = extension->GetThemeImages();
-    DictionaryValue::key_iterator iter = images_value->begin_keys();
-    while (iter != images_value->end_keys()) {
-      std::string val;
-      if (images_value->GetString(*iter , &val)) {
-        FilePath image_path = extension->path().AppendASCII(val);
-        if (!file_util::PathExists(image_path)) {
-          ReportExtensionLoadError(extension_path,
-              StringPrintf("Could not load '%s' for theme.",
-              WideToUTF8(image_path.ToWStringHack()).c_str()));
-          return NULL;
+    if (images_value) {
+      DictionaryValue::key_iterator iter = images_value->begin_keys();
+      while (iter != images_value->end_keys()) {
+        std::string val;
+        if (images_value->GetString(*iter , &val)) {
+          FilePath image_path = extension->path().AppendASCII(val);
+          if (!file_util::PathExists(image_path)) {
+            ReportExtensionLoadError(extension_path,
+                StringPrintf("Could not load '%s' for theme.",
+                WideToUTF8(image_path.ToWStringHack()).c_str()));
+            return NULL;
+          }
         }
+        ++iter;
       }
-      ++iter;
     }
 
     // Themes cannot contain other extension types.