OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "chrome/browser/prefs/pref_service.h" | 51 #include "chrome/browser/prefs/pref_service.h" |
52 #include "chrome/browser/profiles/profile.h" | 52 #include "chrome/browser/profiles/profile.h" |
53 #include "chrome/browser/search_engines/template_url_service.h" | 53 #include "chrome/browser/search_engines/template_url_service.h" |
54 #include "chrome/browser/search_engines/template_url_service_factory.h" | 54 #include "chrome/browser/search_engines/template_url_service_factory.h" |
55 #include "chrome/browser/themes/theme_service.h" | 55 #include "chrome/browser/themes/theme_service.h" |
56 #include "chrome/browser/themes/theme_service_factory.h" | 56 #include "chrome/browser/themes/theme_service_factory.h" |
57 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 57 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
58 #include "chrome/browser/ui/webui/favicon_source.h" | 58 #include "chrome/browser/ui/webui/favicon_source.h" |
59 #include "chrome/browser/ui/webui/ntp/shown_sections_handler.h" | 59 #include "chrome/browser/ui/webui/ntp/shown_sections_handler.h" |
60 #include "chrome/common/child_process_logging.h" | 60 #include "chrome/common/child_process_logging.h" |
| 61 #include "chrome/common/chrome_notification_types.h" |
61 #include "chrome/common/chrome_paths.h" | 62 #include "chrome/common/chrome_paths.h" |
62 #include "chrome/common/chrome_switches.h" | 63 #include "chrome/common/chrome_switches.h" |
63 #include "chrome/common/extensions/extension.h" | 64 #include "chrome/common/extensions/extension.h" |
64 #include "chrome/common/extensions/extension_constants.h" | 65 #include "chrome/common/extensions/extension_constants.h" |
65 #include "chrome/common/extensions/extension_error_utils.h" | 66 #include "chrome/common/extensions/extension_error_utils.h" |
66 #include "chrome/common/extensions/extension_file_util.h" | 67 #include "chrome/common/extensions/extension_file_util.h" |
67 #include "chrome/common/extensions/extension_l10n_util.h" | 68 #include "chrome/common/extensions/extension_l10n_util.h" |
68 #include "chrome/common/extensions/extension_messages.h" | 69 #include "chrome/common/extensions/extension_messages.h" |
69 #include "chrome/common/extensions/extension_resource.h" | 70 #include "chrome/common/extensions/extension_resource.h" |
70 #include "chrome/common/pref_names.h" | 71 #include "chrome/common/pref_names.h" |
71 #include "chrome/common/url_constants.h" | 72 #include "chrome/common/url_constants.h" |
72 #include "content/browser/browser_thread.h" | 73 #include "content/browser/browser_thread.h" |
73 #include "content/browser/debugger/devtools_manager.h" | 74 #include "content/browser/debugger/devtools_manager.h" |
74 #include "content/browser/plugin_process_host.h" | 75 #include "content/browser/plugin_process_host.h" |
75 #include "content/browser/plugin_service.h" | 76 #include "content/browser/plugin_service.h" |
76 #include "content/browser/renderer_host/render_process_host.h" | 77 #include "content/browser/renderer_host/render_process_host.h" |
| 78 #include "content/common/content_notification_types.h" |
77 #include "content/common/json_value_serializer.h" | 79 #include "content/common/json_value_serializer.h" |
78 #include "content/common/notification_service.h" | 80 #include "content/common/notification_service.h" |
79 #include "content/common/notification_type.h" | |
80 #include "content/common/pepper_plugin_registry.h" | 81 #include "content/common/pepper_plugin_registry.h" |
81 #include "googleurl/src/gurl.h" | 82 #include "googleurl/src/gurl.h" |
82 #include "net/base/registry_controlled_domain.h" | 83 #include "net/base/registry_controlled_domain.h" |
83 #include "webkit/database/database_tracker.h" | 84 #include "webkit/database/database_tracker.h" |
84 #include "webkit/database/database_util.h" | 85 #include "webkit/database/database_util.h" |
85 #include "webkit/plugins/npapi/plugin_list.h" | 86 #include "webkit/plugins/npapi/plugin_list.h" |
86 | 87 |
87 #if defined(OS_CHROMEOS) | 88 #if defined(OS_CHROMEOS) |
88 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" | 89 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
89 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" | 90 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 &ExtensionServiceBackend::OnLoadSingleExtension, | 346 &ExtensionServiceBackend::OnLoadSingleExtension, |
346 extension))) | 347 extension))) |
347 NOTREACHED(); | 348 NOTREACHED(); |
348 } | 349 } |
349 | 350 |
350 void ExtensionServiceBackend::ReportExtensionLoadError( | 351 void ExtensionServiceBackend::ReportExtensionLoadError( |
351 const FilePath& extension_path, const std::string &error) { | 352 const FilePath& extension_path, const std::string &error) { |
352 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 353 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
353 if (frontend_.get()) | 354 if (frontend_.get()) |
354 frontend_->ReportExtensionLoadError( | 355 frontend_->ReportExtensionLoadError( |
355 extension_path, error, NotificationType::EXTENSION_INSTALL_ERROR, | 356 extension_path, error, chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
356 true /* alert_on_error */); | 357 true /* alert_on_error */); |
357 } | 358 } |
358 | 359 |
359 void ExtensionServiceBackend::OnLoadSingleExtension( | 360 void ExtensionServiceBackend::OnLoadSingleExtension( |
360 const scoped_refptr<const Extension>& extension) { | 361 const scoped_refptr<const Extension>& extension) { |
361 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 362 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
362 if (frontend_.get()) | 363 if (frontend_.get()) |
363 frontend_->OnLoadSingleExtension(extension); | 364 frontend_->OnLoadSingleExtension(extension); |
364 } | 365 } |
365 | 366 |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 event_routers_initialized_(false) { | 555 event_routers_initialized_(false) { |
555 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 556 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
556 | 557 |
557 // Figure out if extension installation should be enabled. | 558 // Figure out if extension installation should be enabled. |
558 if (command_line->HasSwitch(switches::kDisableExtensions)) { | 559 if (command_line->HasSwitch(switches::kDisableExtensions)) { |
559 extensions_enabled_ = false; | 560 extensions_enabled_ = false; |
560 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { | 561 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { |
561 extensions_enabled_ = false; | 562 extensions_enabled_ = false; |
562 } | 563 } |
563 | 564 |
564 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, | 565 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
565 NotificationService::AllSources()); | 566 NotificationService::AllSources()); |
566 registrar_.Add(this, NotificationType::RENDERER_PROCESS_CREATED, | 567 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
567 NotificationService::AllSources()); | 568 NotificationService::AllSources()); |
568 registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED, | 569 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
569 NotificationService::AllSources()); | 570 NotificationService::AllSources()); |
570 pref_change_registrar_.Init(profile->GetPrefs()); | 571 pref_change_registrar_.Init(profile->GetPrefs()); |
571 pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, this); | 572 pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, this); |
572 pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, this); | 573 pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, this); |
573 | 574 |
574 // Set up the ExtensionUpdater | 575 // Set up the ExtensionUpdater |
575 if (autoupdate_enabled) { | 576 if (autoupdate_enabled) { |
576 int update_frequency = kDefaultUpdateFrequencySeconds; | 577 int update_frequency = kDefaultUpdateFrequencySeconds; |
577 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { | 578 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { |
578 base::StringToInt(command_line->GetSwitchValueASCII( | 579 base::StringToInt(command_line->GetSwitchValueASCII( |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
827 // Get hold of information we need after unloading, since the extension | 828 // Get hold of information we need after unloading, since the extension |
828 // pointer will be invalid then. | 829 // pointer will be invalid then. |
829 GURL extension_url(extension->url()); | 830 GURL extension_url(extension->url()); |
830 Extension::Location location(extension->location()); | 831 Extension::Location location(extension->location()); |
831 | 832 |
832 // Policy change which triggers an uninstall will always set | 833 // Policy change which triggers an uninstall will always set |
833 // |external_uninstall| to true so this is the only way to uninstall | 834 // |external_uninstall| to true so this is the only way to uninstall |
834 // managed extensions. | 835 // managed extensions. |
835 if (!Extension::UserMayDisable(location) && !external_uninstall) { | 836 if (!Extension::UserMayDisable(location) && !external_uninstall) { |
836 NotificationService::current()->Notify( | 837 NotificationService::current()->Notify( |
837 NotificationType::EXTENSION_UNINSTALL_NOT_ALLOWED, | 838 chrome::NOTIFICATION_EXTENSION_UNINSTALL_NOT_ALLOWED, |
838 Source<Profile>(profile_), | 839 Source<Profile>(profile_), |
839 Details<const Extension>(extension)); | 840 Details<const Extension>(extension)); |
840 if (error != NULL) { | 841 if (error != NULL) { |
841 *error = errors::kCannotUninstallManagedExtension; | 842 *error = errors::kCannotUninstallManagedExtension; |
842 } | 843 } |
843 return false; | 844 return false; |
844 } | 845 } |
845 | 846 |
846 UninstalledExtensionInfo uninstalled_extension_info(*extension); | 847 UninstalledExtensionInfo uninstalled_extension_info(*extension); |
847 | 848 |
(...skipping 23 matching lines...) Expand all Loading... |
871 install_directory_, | 872 install_directory_, |
872 extension_id))) | 873 extension_id))) |
873 NOTREACHED(); | 874 NOTREACHED(); |
874 } | 875 } |
875 | 876 |
876 ClearExtensionData(extension_url); | 877 ClearExtensionData(extension_url); |
877 UntrackTerminatedExtension(extension_id); | 878 UntrackTerminatedExtension(extension_id); |
878 | 879 |
879 // Notify interested parties that we've uninstalled this extension. | 880 // Notify interested parties that we've uninstalled this extension. |
880 NotificationService::current()->Notify( | 881 NotificationService::current()->Notify( |
881 NotificationType::EXTENSION_UNINSTALLED, | 882 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, |
882 Source<Profile>(profile_), | 883 Source<Profile>(profile_), |
883 Details<UninstalledExtensionInfo>(&uninstalled_extension_info)); | 884 Details<UninstalledExtensionInfo>(&uninstalled_extension_info)); |
884 | 885 |
885 return true; | 886 return true; |
886 } | 887 } |
887 | 888 |
888 void ExtensionService::ClearExtensionData(const GURL& extension_url) { | 889 void ExtensionService::ClearExtensionData(const GURL& extension_url) { |
889 scoped_refptr<ExtensionDataDeleter> deleter( | 890 scoped_refptr<ExtensionDataDeleter> deleter( |
890 new ExtensionDataDeleter(profile_, extension_url)); | 891 new ExtensionDataDeleter(profile_, extension_url)); |
891 deleter->StartDeleting(); | 892 deleter->StartDeleting(); |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 *info.extension_manifest, | 1247 *info.extension_manifest, |
1247 flags, | 1248 flags, |
1248 &error); | 1249 &error); |
1249 } else { | 1250 } else { |
1250 error = errors::kManifestUnreadable; | 1251 error = errors::kManifestUnreadable; |
1251 } | 1252 } |
1252 | 1253 |
1253 if (!extension) { | 1254 if (!extension) { |
1254 ReportExtensionLoadError(info.extension_path, | 1255 ReportExtensionLoadError(info.extension_path, |
1255 error, | 1256 error, |
1256 NotificationType::EXTENSION_INSTALL_ERROR, | 1257 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
1257 false); | 1258 false); |
1258 return; | 1259 return; |
1259 } | 1260 } |
1260 | 1261 |
1261 if (write_to_prefs) | 1262 if (write_to_prefs) |
1262 extension_prefs_->UpdateManifest(extension); | 1263 extension_prefs_->UpdateManifest(extension); |
1263 | 1264 |
1264 AddExtension(extension); | 1265 AddExtension(extension); |
1265 } | 1266 } |
1266 | 1267 |
1267 void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { | 1268 void ExtensionService::NotifyExtensionLoaded(const Extension* extension) { |
1268 // The ChromeURLRequestContexts need to be first to know that the extension | 1269 // The ChromeURLRequestContexts need to be first to know that the extension |
1269 // was loaded, otherwise a race can arise where a renderer that is created | 1270 // was loaded, otherwise a race can arise where a renderer that is created |
1270 // for the extension may try to load an extension URL with an extension id | 1271 // for the extension may try to load an extension URL with an extension id |
1271 // that the request context doesn't yet know about. The profile is responsible | 1272 // that the request context doesn't yet know about. The profile is responsible |
1272 // for ensuring its URLRequestContexts appropriately discover the loaded | 1273 // for ensuring its URLRequestContexts appropriately discover the loaded |
1273 // extension. | 1274 // extension. |
1274 profile_->RegisterExtensionWithRequestContexts(extension); | 1275 profile_->RegisterExtensionWithRequestContexts(extension); |
1275 | 1276 |
1276 // Tell subsystems that use the EXTENSION_LOADED notification about the new | 1277 // Tell subsystems that use the EXTENSION_LOADED notification about the new |
1277 // extension. | 1278 // extension. |
1278 NotificationService::current()->Notify( | 1279 NotificationService::current()->Notify( |
1279 NotificationType::EXTENSION_LOADED, | 1280 chrome::NOTIFICATION_EXTENSION_LOADED, |
1280 Source<Profile>(profile_), | 1281 Source<Profile>(profile_), |
1281 Details<const Extension>(extension)); | 1282 Details<const Extension>(extension)); |
1282 | 1283 |
1283 // Tell renderers about the new extension. | 1284 // Tell renderers about the new extension. |
1284 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); | 1285 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); |
1285 !i.IsAtEnd(); i.Advance()) { | 1286 !i.IsAtEnd(); i.Advance()) { |
1286 RenderProcessHost* host = i.GetCurrentValue(); | 1287 RenderProcessHost* host = i.GetCurrentValue(); |
1287 if (host->profile()->GetOriginalProfile() == | 1288 if (host->profile()->GetOriginalProfile() == |
1288 profile_->GetOriginalProfile()) { | 1289 profile_->GetOriginalProfile()) { |
1289 host->Send( | 1290 host->Send( |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 is_system); | 1367 is_system); |
1367 } | 1368 } |
1368 } | 1369 } |
1369 #endif | 1370 #endif |
1370 } | 1371 } |
1371 | 1372 |
1372 void ExtensionService::NotifyExtensionUnloaded( | 1373 void ExtensionService::NotifyExtensionUnloaded( |
1373 const Extension* extension, UnloadedExtensionInfo::Reason reason) { | 1374 const Extension* extension, UnloadedExtensionInfo::Reason reason) { |
1374 UnloadedExtensionInfo details(extension, reason); | 1375 UnloadedExtensionInfo details(extension, reason); |
1375 NotificationService::current()->Notify( | 1376 NotificationService::current()->Notify( |
1376 NotificationType::EXTENSION_UNLOADED, | 1377 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
1377 Source<Profile>(profile_), | 1378 Source<Profile>(profile_), |
1378 Details<UnloadedExtensionInfo>(&details)); | 1379 Details<UnloadedExtensionInfo>(&details)); |
1379 | 1380 |
1380 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); | 1381 for (RenderProcessHost::iterator i(RenderProcessHost::AllHostsIterator()); |
1381 !i.IsAtEnd(); i.Advance()) { | 1382 !i.IsAtEnd(); i.Advance()) { |
1382 RenderProcessHost* host = i.GetCurrentValue(); | 1383 RenderProcessHost* host = i.GetCurrentValue(); |
1383 if (host->profile()->GetOriginalProfile() == | 1384 if (host->profile()->GetOriginalProfile() == |
1384 profile_->GetOriginalProfile()) { | 1385 profile_->GetOriginalProfile()) { |
1385 host->Send(new ExtensionMsg_Unloaded(extension->id())); | 1386 host->Send(new ExtensionMsg_Unloaded(extension->id())); |
1386 } | 1387 } |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 extension_runtime_data_.erase(extension_id); | 1785 extension_runtime_data_.erase(extension_id); |
1785 | 1786 |
1786 ExtensionList::iterator iter = std::find(disabled_extensions_.begin(), | 1787 ExtensionList::iterator iter = std::find(disabled_extensions_.begin(), |
1787 disabled_extensions_.end(), | 1788 disabled_extensions_.end(), |
1788 extension.get()); | 1789 extension.get()); |
1789 if (iter != disabled_extensions_.end()) { | 1790 if (iter != disabled_extensions_.end()) { |
1790 UnloadedExtensionInfo details(extension, reason); | 1791 UnloadedExtensionInfo details(extension, reason); |
1791 details.already_disabled = true; | 1792 details.already_disabled = true; |
1792 disabled_extensions_.erase(iter); | 1793 disabled_extensions_.erase(iter); |
1793 NotificationService::current()->Notify( | 1794 NotificationService::current()->Notify( |
1794 NotificationType::EXTENSION_UNLOADED, | 1795 chrome::NOTIFICATION_EXTENSION_UNLOADED, |
1795 Source<Profile>(profile_), | 1796 Source<Profile>(profile_), |
1796 Details<UnloadedExtensionInfo>(&details)); | 1797 Details<UnloadedExtensionInfo>(&details)); |
1797 // Make sure the profile cleans up its RequestContexts when an already | 1798 // Make sure the profile cleans up its RequestContexts when an already |
1798 // disabled extension is unloaded (since they are also tracking the disabled | 1799 // disabled extension is unloaded (since they are also tracking the disabled |
1799 // extensions). | 1800 // extensions). |
1800 profile_->UnregisterExtensionWithRequestContexts(extension_id, reason); | 1801 profile_->UnregisterExtensionWithRequestContexts(extension_id, reason); |
1801 return; | 1802 return; |
1802 } | 1803 } |
1803 | 1804 |
1804 iter = std::find(extensions_.begin(), extensions_.end(), extension.get()); | 1805 iter = std::find(extensions_.begin(), extensions_.end(), extension.get()); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1856 } | 1857 } |
1857 } | 1858 } |
1858 | 1859 |
1859 void ExtensionService::OnLoadedInstalledExtensions() { | 1860 void ExtensionService::OnLoadedInstalledExtensions() { |
1860 if (updater_.get()) { | 1861 if (updater_.get()) { |
1861 updater_->Start(); | 1862 updater_->Start(); |
1862 } | 1863 } |
1863 | 1864 |
1864 ready_ = true; | 1865 ready_ = true; |
1865 NotificationService::current()->Notify( | 1866 NotificationService::current()->Notify( |
1866 NotificationType::EXTENSIONS_READY, | 1867 chrome::NOTIFICATION_EXTENSIONS_READY, |
1867 Source<Profile>(profile_), | 1868 Source<Profile>(profile_), |
1868 NotificationService::NoDetails()); | 1869 NotificationService::NoDetails()); |
1869 } | 1870 } |
1870 | 1871 |
1871 void ExtensionService::AddExtension(const Extension* extension) { | 1872 void ExtensionService::AddExtension(const Extension* extension) { |
1872 // Ensure extension is deleted unless we transfer ownership. | 1873 // Ensure extension is deleted unless we transfer ownership. |
1873 scoped_refptr<const Extension> scoped_extension(extension); | 1874 scoped_refptr<const Extension> scoped_extension(extension); |
1874 | 1875 |
1875 // TODO(jstritar): We may be able to get rid of this branch by overriding the | 1876 // TODO(jstritar): We may be able to get rid of this branch by overriding the |
1876 // default extension state to DISABLED when the --disable-extensions flag | 1877 // default extension state to DISABLED when the --disable-extensions flag |
(...skipping 20 matching lines...) Expand all Loading... |
1897 // extension if necessary. | 1898 // extension if necessary. |
1898 DisableIfPrivilegeIncrease(extension); | 1899 DisableIfPrivilegeIncrease(extension); |
1899 | 1900 |
1900 Extension::State state = extension_prefs_->GetExtensionState(extension->id()); | 1901 Extension::State state = extension_prefs_->GetExtensionState(extension->id()); |
1901 if (state == Extension::DISABLED) { | 1902 if (state == Extension::DISABLED) { |
1902 disabled_extensions_.push_back(scoped_extension); | 1903 disabled_extensions_.push_back(scoped_extension); |
1903 // TODO(aa): This seems dodgy. It seems that AddExtension() could get called | 1904 // TODO(aa): This seems dodgy. It seems that AddExtension() could get called |
1904 // with a disabled extension for other reasons other than that an update was | 1905 // with a disabled extension for other reasons other than that an update was |
1905 // disabled. | 1906 // disabled. |
1906 NotificationService::current()->Notify( | 1907 NotificationService::current()->Notify( |
1907 NotificationType::EXTENSION_UPDATE_DISABLED, | 1908 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
1908 Source<Profile>(profile_), | 1909 Source<Profile>(profile_), |
1909 Details<const Extension>(extension)); | 1910 Details<const Extension>(extension)); |
1910 return; | 1911 return; |
1911 } | 1912 } |
1912 | 1913 |
1913 // It should not be possible to get here with EXTERNAL_EXTENSION_UNINSTALLED | 1914 // It should not be possible to get here with EXTERNAL_EXTENSION_UNINSTALLED |
1914 // because we would not have loaded the extension in that case. | 1915 // because we would not have loaded the extension in that case. |
1915 CHECK(state == Extension::ENABLED); | 1916 CHECK(state == Extension::ENABLED); |
1916 extensions_.push_back(scoped_extension); | 1917 extensions_.push_back(scoped_extension); |
1917 NotifyExtensionLoaded(extension); | 1918 NotifyExtensionLoaded(extension); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2031 pending_extension_manager()->Remove(id); | 2032 pending_extension_manager()->Remove(id); |
2032 | 2033 |
2033 if (!pending_extension_info.ShouldAllowInstall(*extension)) { | 2034 if (!pending_extension_info.ShouldAllowInstall(*extension)) { |
2034 LOG(WARNING) | 2035 LOG(WARNING) |
2035 << "ShouldAllowInstall() returned false for " | 2036 << "ShouldAllowInstall() returned false for " |
2036 << id << " of type " << extension->GetType() | 2037 << id << " of type " << extension->GetType() |
2037 << " and update URL " << extension->update_url().spec() | 2038 << " and update URL " << extension->update_url().spec() |
2038 << "; not installing"; | 2039 << "; not installing"; |
2039 | 2040 |
2040 NotificationService::current()->Notify( | 2041 NotificationService::current()->Notify( |
2041 NotificationType::EXTENSION_INSTALL_NOT_ALLOWED, | 2042 chrome::NOTIFICATION_EXTENSION_INSTALL_NOT_ALLOWED, |
2042 Source<Profile>(profile_), | 2043 Source<Profile>(profile_), |
2043 Details<const Extension>(extension)); | 2044 Details<const Extension>(extension)); |
2044 | 2045 |
2045 // Delete the extension directory since we're not going to | 2046 // Delete the extension directory since we're not going to |
2046 // load it. | 2047 // load it. |
2047 if (!BrowserThread::PostTask( | 2048 if (!BrowserThread::PostTask( |
2048 BrowserThread::FILE, FROM_HERE, | 2049 BrowserThread::FILE, FROM_HERE, |
2049 NewRunnableFunction(&extension_file_util::DeleteFile, | 2050 NewRunnableFunction(&extension_file_util::DeleteFile, |
2050 extension->path(), true))) | 2051 extension->path(), true))) |
2051 NOTREACHED(); | 2052 NOTREACHED(); |
(...skipping 21 matching lines...) Expand all Loading... |
2073 extension, initial_enable ? Extension::ENABLED : Extension::DISABLED); | 2074 extension, initial_enable ? Extension::ENABLED : Extension::DISABLED); |
2074 | 2075 |
2075 // Unpacked extensions default to allowing file access, but if that has been | 2076 // Unpacked extensions default to allowing file access, but if that has been |
2076 // overridden, don't reset the value. | 2077 // overridden, don't reset the value. |
2077 if (Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD) && | 2078 if (Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD) && |
2078 !extension_prefs_->HasAllowFileAccessSetting(id)) { | 2079 !extension_prefs_->HasAllowFileAccessSetting(id)) { |
2079 extension_prefs_->SetAllowFileAccess(id, true); | 2080 extension_prefs_->SetAllowFileAccess(id, true); |
2080 } | 2081 } |
2081 | 2082 |
2082 NotificationService::current()->Notify( | 2083 NotificationService::current()->Notify( |
2083 NotificationType::EXTENSION_INSTALLED, | 2084 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
2084 Source<Profile>(profile_), | 2085 Source<Profile>(profile_), |
2085 Details<const Extension>(extension)); | 2086 Details<const Extension>(extension)); |
2086 | 2087 |
2087 // Transfer ownership of |extension| to AddExtension. | 2088 // Transfer ownership of |extension| to AddExtension. |
2088 AddExtension(scoped_extension); | 2089 AddExtension(scoped_extension); |
2089 } | 2090 } |
2090 | 2091 |
2091 const Extension* ExtensionService::GetExtensionByIdInternal( | 2092 const Extension* ExtensionService::GetExtensionByIdInternal( |
2092 const std::string& id, bool include_enabled, bool include_disabled, | 2093 const std::string& id, bool include_enabled, bool include_disabled, |
2093 bool include_terminated) const { | 2094 bool include_terminated) const { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2232 installer->set_install_source(location); | 2233 installer->set_install_source(location); |
2233 installer->set_expected_id(id); | 2234 installer->set_expected_id(id); |
2234 installer->set_expected_version(*version); | 2235 installer->set_expected_version(*version); |
2235 installer->set_install_cause(extension_misc::INSTALL_CAUSE_EXTERNAL_FILE); | 2236 installer->set_install_cause(extension_misc::INSTALL_CAUSE_EXTERNAL_FILE); |
2236 installer->InstallCrx(path); | 2237 installer->InstallCrx(path); |
2237 } | 2238 } |
2238 | 2239 |
2239 void ExtensionService::ReportExtensionLoadError( | 2240 void ExtensionService::ReportExtensionLoadError( |
2240 const FilePath& extension_path, | 2241 const FilePath& extension_path, |
2241 const std::string &error, | 2242 const std::string &error, |
2242 NotificationType type, | 2243 int type, |
2243 bool be_noisy) { | 2244 bool be_noisy) { |
2244 NotificationService* service = NotificationService::current(); | 2245 NotificationService* service = NotificationService::current(); |
2245 service->Notify(type, | 2246 service->Notify(type, |
2246 Source<Profile>(profile_), | 2247 Source<Profile>(profile_), |
2247 Details<const std::string>(&error)); | 2248 Details<const std::string>(&error)); |
2248 | 2249 |
2249 std::string path_str = UTF16ToUTF8(extension_path.LossyDisplayName()); | 2250 std::string path_str = UTF16ToUTF8(extension_path.LossyDisplayName()); |
2250 std::string message = base::StringPrintf( | 2251 std::string message = base::StringPrintf( |
2251 "Could not load extension from '%s'. %s", | 2252 "Could not load extension from '%s'. %s", |
2252 path_str.c_str(), error.c_str()); | 2253 path_str.c_str(), error.c_str()); |
2253 ExtensionErrorReporter::GetInstance()->ReportError(message, be_noisy); | 2254 ExtensionErrorReporter::GetInstance()->ReportError(message, be_noisy); |
2254 } | 2255 } |
2255 | 2256 |
2256 void ExtensionService::DidCreateRenderViewForBackgroundPage( | 2257 void ExtensionService::DidCreateRenderViewForBackgroundPage( |
2257 ExtensionHost* host) { | 2258 ExtensionHost* host) { |
2258 OrphanedDevTools::iterator iter = | 2259 OrphanedDevTools::iterator iter = |
2259 orphaned_dev_tools_.find(host->extension_id()); | 2260 orphaned_dev_tools_.find(host->extension_id()); |
2260 if (iter == orphaned_dev_tools_.end()) | 2261 if (iter == orphaned_dev_tools_.end()) |
2261 return; | 2262 return; |
2262 | 2263 |
2263 DevToolsManager::GetInstance()->AttachClientHost( | 2264 DevToolsManager::GetInstance()->AttachClientHost( |
2264 iter->second, host->render_view_host()); | 2265 iter->second, host->render_view_host()); |
2265 orphaned_dev_tools_.erase(iter); | 2266 orphaned_dev_tools_.erase(iter); |
2266 } | 2267 } |
2267 | 2268 |
2268 void ExtensionService::Observe(NotificationType type, | 2269 void ExtensionService::Observe(int type, |
2269 const NotificationSource& source, | 2270 const NotificationSource& source, |
2270 const NotificationDetails& details) { | 2271 const NotificationDetails& details) { |
2271 switch (type.value) { | 2272 switch (type) { |
2272 case NotificationType::EXTENSION_PROCESS_TERMINATED: { | 2273 case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: { |
2273 if (profile_ != Source<Profile>(source).ptr()->GetOriginalProfile()) | 2274 if (profile_ != Source<Profile>(source).ptr()->GetOriginalProfile()) |
2274 break; | 2275 break; |
2275 | 2276 |
2276 ExtensionHost* host = Details<ExtensionHost>(details).ptr(); | 2277 ExtensionHost* host = Details<ExtensionHost>(details).ptr(); |
2277 | 2278 |
2278 // Mark the extension as terminated and Unload it. We want it to | 2279 // Mark the extension as terminated and Unload it. We want it to |
2279 // be in a consistent state: either fully working or not loaded | 2280 // be in a consistent state: either fully working or not loaded |
2280 // at all, but never half-crashed. We do it in a PostTask so | 2281 // at all, but never half-crashed. We do it in a PostTask so |
2281 // that other handlers of this notification will still have | 2282 // that other handlers of this notification will still have |
2282 // access to the Extension and ExtensionHost. | 2283 // access to the Extension and ExtensionHost. |
2283 MessageLoop::current()->PostTask( | 2284 MessageLoop::current()->PostTask( |
2284 FROM_HERE, | 2285 FROM_HERE, |
2285 method_factory_.NewRunnableMethod( | 2286 method_factory_.NewRunnableMethod( |
2286 &ExtensionService::TrackTerminatedExtension, | 2287 &ExtensionService::TrackTerminatedExtension, |
2287 host->extension())); | 2288 host->extension())); |
2288 break; | 2289 break; |
2289 } | 2290 } |
2290 case NotificationType::RENDERER_PROCESS_CREATED: { | 2291 case content::NOTIFICATION_RENDERER_PROCESS_CREATED: { |
2291 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr(); | 2292 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr(); |
2292 // Valid extension function names, used to setup bindings in renderer. | 2293 // Valid extension function names, used to setup bindings in renderer. |
2293 std::vector<std::string> function_names; | 2294 std::vector<std::string> function_names; |
2294 ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names); | 2295 ExtensionFunctionDispatcher::GetAllFunctionNames(&function_names); |
2295 process->Send(new ExtensionMsg_SetFunctionNames(function_names)); | 2296 process->Send(new ExtensionMsg_SetFunctionNames(function_names)); |
2296 | 2297 |
2297 // Scripting whitelist. This is modified by tests and must be communicated | 2298 // Scripting whitelist. This is modified by tests and must be communicated |
2298 // to renderers. | 2299 // to renderers. |
2299 process->Send(new ExtensionMsg_SetScriptingWhitelist( | 2300 process->Send(new ExtensionMsg_SetScriptingWhitelist( |
2300 *Extension::GetScriptingWhitelist())); | 2301 *Extension::GetScriptingWhitelist())); |
2301 | 2302 |
2302 // Loaded extensions. | 2303 // Loaded extensions. |
2303 for (size_t i = 0; i < extensions_.size(); ++i) { | 2304 for (size_t i = 0; i < extensions_.size(); ++i) { |
2304 process->Send(new ExtensionMsg_Loaded( | 2305 process->Send(new ExtensionMsg_Loaded( |
2305 ExtensionMsg_Loaded_Params(extensions_[i]))); | 2306 ExtensionMsg_Loaded_Params(extensions_[i]))); |
2306 } | 2307 } |
2307 break; | 2308 break; |
2308 } | 2309 } |
2309 case NotificationType::RENDERER_PROCESS_TERMINATED: { | 2310 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: { |
2310 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr(); | 2311 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr(); |
2311 installed_app_hosts_.erase(process->id()); | 2312 installed_app_hosts_.erase(process->id()); |
2312 break; | 2313 break; |
2313 } | 2314 } |
2314 case NotificationType::PREF_CHANGED: { | 2315 case chrome::NOTIFICATION_PREF_CHANGED: { |
2315 std::string* pref_name = Details<std::string>(details).ptr(); | 2316 std::string* pref_name = Details<std::string>(details).ptr(); |
2316 if (*pref_name == prefs::kExtensionInstallAllowList || | 2317 if (*pref_name == prefs::kExtensionInstallAllowList || |
2317 *pref_name == prefs::kExtensionInstallDenyList) { | 2318 *pref_name == prefs::kExtensionInstallDenyList) { |
2318 CheckAdminBlacklist(); | 2319 CheckAdminBlacklist(); |
2319 } else { | 2320 } else { |
2320 NOTREACHED() << "Unexpected preference name."; | 2321 NOTREACHED() << "Unexpected preference name."; |
2321 } | 2322 } |
2322 break; | 2323 break; |
2323 } | 2324 } |
2324 | 2325 |
(...skipping 24 matching lines...) Expand all Loading... |
2349 | 2350 |
2350 bool ExtensionService::IsBackgroundPageReady(const Extension* extension) { | 2351 bool ExtensionService::IsBackgroundPageReady(const Extension* extension) { |
2351 return (extension->background_url().is_empty() || | 2352 return (extension->background_url().is_empty() || |
2352 extension_runtime_data_[extension->id()].background_page_ready); | 2353 extension_runtime_data_[extension->id()].background_page_ready); |
2353 } | 2354 } |
2354 | 2355 |
2355 void ExtensionService::SetBackgroundPageReady(const Extension* extension) { | 2356 void ExtensionService::SetBackgroundPageReady(const Extension* extension) { |
2356 DCHECK(!extension->background_url().is_empty()); | 2357 DCHECK(!extension->background_url().is_empty()); |
2357 extension_runtime_data_[extension->id()].background_page_ready = true; | 2358 extension_runtime_data_[extension->id()].background_page_ready = true; |
2358 NotificationService::current()->Notify( | 2359 NotificationService::current()->Notify( |
2359 NotificationType::EXTENSION_BACKGROUND_PAGE_READY, | 2360 chrome::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY, |
2360 Source<const Extension>(extension), | 2361 Source<const Extension>(extension), |
2361 NotificationService::NoDetails()); | 2362 NotificationService::NoDetails()); |
2362 } | 2363 } |
2363 | 2364 |
2364 bool ExtensionService::IsBeingUpgraded(const Extension* extension) { | 2365 bool ExtensionService::IsBeingUpgraded(const Extension* extension) { |
2365 return extension_runtime_data_[extension->id()].being_upgraded; | 2366 return extension_runtime_data_[extension->id()].being_upgraded; |
2366 } | 2367 } |
2367 | 2368 |
2368 void ExtensionService::SetBeingUpgraded(const Extension* extension, | 2369 void ExtensionService::SetBeingUpgraded(const Extension* extension, |
2369 bool value) { | 2370 bool value) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2425 | 2426 |
2426 ExtensionService::NaClModuleInfoList::iterator | 2427 ExtensionService::NaClModuleInfoList::iterator |
2427 ExtensionService::FindNaClModule(const GURL& url) { | 2428 ExtensionService::FindNaClModule(const GURL& url) { |
2428 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2429 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
2429 iter != nacl_module_list_.end(); ++iter) { | 2430 iter != nacl_module_list_.end(); ++iter) { |
2430 if (iter->url == url) | 2431 if (iter->url == url) |
2431 return iter; | 2432 return iter; |
2432 } | 2433 } |
2433 return nacl_module_list_.end(); | 2434 return nacl_module_list_.end(); |
2434 } | 2435 } |
OLD | NEW |