OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 #include "chrome/browser/extensions/extension_sorting.h" | 56 #include "chrome/browser/extensions/extension_sorting.h" |
57 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 57 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
58 #include "chrome/browser/extensions/extension_sync_data.h" | 58 #include "chrome/browser/extensions/extension_sync_data.h" |
59 #include "chrome/browser/extensions/extension_system.h" | 59 #include "chrome/browser/extensions/extension_system.h" |
60 #include "chrome/browser/extensions/extension_web_ui.h" | 60 #include "chrome/browser/extensions/extension_web_ui.h" |
61 #include "chrome/browser/extensions/external_provider_impl.h" | 61 #include "chrome/browser/extensions/external_provider_impl.h" |
62 #include "chrome/browser/extensions/external_provider_interface.h" | 62 #include "chrome/browser/extensions/external_provider_interface.h" |
63 #include "chrome/browser/extensions/installed_loader.h" | 63 #include "chrome/browser/extensions/installed_loader.h" |
64 #include "chrome/browser/extensions/pending_extension_manager.h" | 64 #include "chrome/browser/extensions/pending_extension_manager.h" |
65 #include "chrome/browser/extensions/permissions_updater.h" | 65 #include "chrome/browser/extensions/permissions_updater.h" |
66 #include "chrome/browser/extensions/requirements_provider.h" | |
66 #include "chrome/browser/extensions/settings/settings_frontend.h" | 67 #include "chrome/browser/extensions/settings/settings_frontend.h" |
67 #include "chrome/browser/extensions/unpacked_installer.h" | 68 #include "chrome/browser/extensions/unpacked_installer.h" |
68 #include "chrome/browser/extensions/updater/extension_updater.h" | 69 #include "chrome/browser/extensions/updater/extension_updater.h" |
69 #include "chrome/browser/history/history_extension_api.h" | 70 #include "chrome/browser/history/history_extension_api.h" |
70 #include "chrome/browser/net/chrome_url_request_context.h" | 71 #include "chrome/browser/net/chrome_url_request_context.h" |
71 #include "chrome/browser/prefs/pref_service.h" | 72 #include "chrome/browser/prefs/pref_service.h" |
72 #include "chrome/browser/profiles/profile.h" | 73 #include "chrome/browser/profiles/profile.h" |
73 #include "chrome/browser/profiles/profile_manager.h" | 74 #include "chrome/browser/profiles/profile_manager.h" |
74 #include "chrome/browser/search_engines/template_url_service.h" | 75 #include "chrome/browser/search_engines/template_url_service.h" |
75 #include "chrome/browser/search_engines/template_url_service_factory.h" | 76 #include "chrome/browser/search_engines/template_url_service_factory.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 #include "webkit/database/database_tracker.h" | 110 #include "webkit/database/database_tracker.h" |
110 #include "webkit/database/database_util.h" | 111 #include "webkit/database/database_util.h" |
111 | 112 |
112 #if defined(OS_CHROMEOS) | 113 #if defined(OS_CHROMEOS) |
113 #include "chrome/browser/chromeos/cros/cros_library.h" | 114 #include "chrome/browser/chromeos/cros/cros_library.h" |
114 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" | 115 #include "chrome/browser/chromeos/extensions/bluetooth_event_router.h" |
115 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" | 116 #include "chrome/browser/chromeos/extensions/file_browser_event_router.h" |
116 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" | 117 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" |
117 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" | 118 #include "chrome/browser/chromeos/extensions/media_player_event_router.h" |
118 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 119 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
119 #include "chrome/browser/extensions/extension_input_ime_api.h" | |
120 #include "webkit/fileapi/file_system_context.h" | 120 #include "webkit/fileapi/file_system_context.h" |
121 #include "webkit/fileapi/file_system_mount_point_provider.h" | 121 #include "webkit/fileapi/file_system_mount_point_provider.h" |
122 #endif | 122 #endif |
123 | 123 |
124 using base::Time; | 124 using base::Time; |
125 using content::BrowserContext; | 125 using content::BrowserContext; |
126 using content::BrowserThread; | 126 using content::BrowserThread; |
127 using content::DevToolsAgentHost; | 127 using content::DevToolsAgentHost; |
128 using content::DevToolsAgentHostRegistry; | 128 using content::DevToolsAgentHostRegistry; |
129 using content::PluginService; | 129 using content::PluginService; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
336 app_notification_manager_(new AppNotificationManager(profile)), | 336 app_notification_manager_(new AppNotificationManager(profile)), |
337 apps_promo_(profile->GetPrefs()), | 337 apps_promo_(profile->GetPrefs()), |
338 event_routers_initialized_(false), | 338 event_routers_initialized_(false), |
339 update_once_all_providers_are_ready_(false), | 339 update_once_all_providers_are_ready_(false), |
340 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 340 app_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
341 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 341 extension_sync_bundle_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
342 extension_warnings_(profile), | 342 extension_warnings_(profile), |
343 api_resource_controller_(NULL), | 343 api_resource_controller_(NULL), |
344 app_shortcut_manager_(profile) { | 344 app_shortcut_manager_(profile) { |
345 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 345 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
346 | 346 requirements_provider_.reset(new extensions::RequirementsProvider()); |
347 // Figure out if extension installation should be enabled. | 347 // Figure out if extension installation should be enabled. |
348 if (command_line->HasSwitch(switches::kDisableExtensions)) { | 348 if (command_line->HasSwitch(switches::kDisableExtensions)) { |
349 extensions_enabled_ = false; | 349 extensions_enabled_ = false; |
350 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { | 350 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { |
351 extensions_enabled_ = false; | 351 extensions_enabled_ = false; |
352 } | 352 } |
353 | 353 |
354 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 354 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
355 content::NotificationService::AllBrowserContextsAndSources()); | 355 content::NotificationService::AllBrowserContextsAndSources()); |
356 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 356 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
602 } | 602 } |
603 | 603 |
604 // Bookmark apps being updated is kind of a contradiction, but that's because | 604 // Bookmark apps being updated is kind of a contradiction, but that's because |
605 // we mark the default apps as bookmark apps, and they're hosted in the web | 605 // we mark the default apps as bookmark apps, and they're hosted in the web |
606 // store, thus they can get updated. See http://crbug.com/101605 for more | 606 // store, thus they can get updated. See http://crbug.com/101605 for more |
607 // details. | 607 // details. |
608 if (extension && extension->from_bookmark()) | 608 if (extension && extension->from_bookmark()) |
609 creation_flags |= Extension::FROM_BOOKMARK; | 609 creation_flags |= Extension::FROM_BOOKMARK; |
610 | 610 |
611 installer->set_creation_flags(creation_flags); | 611 installer->set_creation_flags(creation_flags); |
612 | |
613 installer->set_delete_source(true); | 612 installer->set_delete_source(true); |
614 installer->set_download_url(download_url); | 613 installer->set_download_url(download_url); |
615 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); | 614 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); |
616 installer->InstallCrx(extension_path); | 615 installer->InstallCrx(extension_path); |
617 | 616 |
618 if (out_crx_installer) | 617 if (out_crx_installer) |
619 *out_crx_installer = installer; | 618 *out_crx_installer = installer; |
620 | 619 |
621 return true; | 620 return true; |
622 } | 621 } |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
876 | 875 |
877 SyncExtensionChangeIfNeeded(*extension); | 876 SyncExtensionChangeIfNeeded(*extension); |
878 | 877 |
879 // Deactivating one extension might have solved the problems of others. | 878 // Deactivating one extension might have solved the problems of others. |
880 // Therefore, we clear warnings of this type for all extensions. | 879 // Therefore, we clear warnings of this type for all extensions. |
881 std::set<ExtensionWarningSet::WarningType> warnings; | 880 std::set<ExtensionWarningSet::WarningType> warnings; |
882 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); | 881 extension_warnings_.GetWarningsAffectingExtension(extension_id, &warnings); |
883 extension_warnings_.ClearWarnings(warnings); | 882 extension_warnings_.ClearWarnings(warnings); |
884 } | 883 } |
885 | 884 |
885 void ExtensionService::UnsupportedRequirements(const std::string& extension_id, | |
886 const string16& error, | |
887 bool disable_extension) { | |
888 if (disable_extension) | |
889 DisableExtension(extension_id, Extension::DISABLE_UNSUPPORTED_REQUIREMENTS); | |
890 Extension::InstallWarningVector warnings; | |
891 warnings.push_back(Extension::InstallWarning( | |
892 Extension::InstallWarning::FORMAT_TEXT, UTF16ToUTF8(error))); | |
893 const Extension* extension = GetExtensionById(extension_id, true); | |
894 if (extension) | |
895 const_cast<Extension*>(extension)->AddInstallWarnings(warnings); | |
896 } | |
897 | |
886 void ExtensionService::GrantPermissionsAndEnableExtension( | 898 void ExtensionService::GrantPermissionsAndEnableExtension( |
887 const Extension* extension, bool record_oauth2_grant) { | 899 const Extension* extension, bool record_oauth2_grant) { |
888 CHECK(extension); | 900 CHECK(extension); |
889 RecordPermissionMessagesHistogram( | 901 RecordPermissionMessagesHistogram( |
890 extension, "Extensions.Permissions_ReEnable"); | 902 extension, "Extensions.Permissions_ReEnable"); |
891 extensions::PermissionsUpdater perms_updater(profile()); | 903 extensions::PermissionsUpdater perms_updater(profile()); |
892 perms_updater.GrantActivePermissions(extension, record_oauth2_grant); | 904 perms_updater.GrantActivePermissions(extension, record_oauth2_grant); |
893 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false); | 905 extension_prefs_->SetDidExtensionEscalatePermissions(extension, false); |
894 EnableExtension(extension->id()); | 906 EnableExtension(extension->id()); |
895 } | 907 } |
(...skipping 1021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1917 | 1929 |
1918 // If the extension was disabled for a reload, then enable it. | 1930 // If the extension was disabled for a reload, then enable it. |
1919 if (disabled_extension_paths_.erase(extension->id()) > 0) | 1931 if (disabled_extension_paths_.erase(extension->id()) > 0) |
1920 EnableExtension(extension->id()); | 1932 EnableExtension(extension->id()); |
1921 | 1933 |
1922 // Check if the extension's privileges have changed and disable the | 1934 // Check if the extension's privileges have changed and disable the |
1923 // extension if necessary. | 1935 // extension if necessary. |
1924 InitializePermissions(extension); | 1936 InitializePermissions(extension); |
1925 | 1937 |
1926 bool disabled = extension_prefs_->IsExtensionDisabled(extension->id()); | 1938 bool disabled = extension_prefs_->IsExtensionDisabled(extension->id()); |
1939 | |
1940 std::list<string16> errors; | |
1941 bool async; | |
1942 if (!requirements_provider_->Supports(extension, &errors, &async, this)) { | |
Aaron Boodman
2012/07/22 17:46:25
I think that this is going to result in a GPU proc
| |
1943 disabled = true; | |
1944 Extension::InstallWarningVector warnings; | |
1945 std::list<string16>::iterator it; | |
1946 for (it = errors.begin(); it != errors.end(); ++it) { | |
1947 warnings.push_back(Extension::InstallWarning( | |
1948 Extension::InstallWarning::FORMAT_TEXT, UTF16ToUTF8(*it))); | |
1949 } | |
1950 const_cast<Extension*>(extension)->AddInstallWarnings(warnings); | |
1951 } | |
1952 | |
1927 if (disabled) { | 1953 if (disabled) { |
1928 disabled_extensions_.Insert(scoped_extension); | 1954 disabled_extensions_.Insert(scoped_extension); |
1929 SyncExtensionChangeIfNeeded(*extension); | 1955 SyncExtensionChangeIfNeeded(*extension); |
1930 content::NotificationService::current()->Notify( | 1956 content::NotificationService::current()->Notify( |
1931 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, | 1957 chrome::NOTIFICATION_EXTENSION_UPDATE_DISABLED, |
1932 content::Source<Profile>(profile_), | 1958 content::Source<Profile>(profile_), |
1933 content::Details<const Extension>(extension)); | 1959 content::Details<const Extension>(extension)); |
1934 | 1960 |
1935 if (extension_prefs_->GetDisableReason(extension->id()) == | 1961 if (extension_prefs_->GetDisableReason(extension->id()) == |
1936 Extension::DISABLE_PERMISSIONS_INCREASE) { | 1962 Extension::DISABLE_PERMISSIONS_INCREASE) { |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2553 | 2579 |
2554 // To coexist with certain unit tests that don't have a work-thread message | 2580 // To coexist with certain unit tests that don't have a work-thread message |
2555 // loop available at ExtensionService shutdown, we lazy-initialize this | 2581 // loop available at ExtensionService shutdown, we lazy-initialize this |
2556 // object so that those cases neither create nor destroy an | 2582 // object so that those cases neither create nor destroy an |
2557 // APIResourceController. | 2583 // APIResourceController. |
2558 if (!api_resource_controller_.get()) { | 2584 if (!api_resource_controller_.get()) { |
2559 api_resource_controller_.reset(new extensions::APIResourceController()); | 2585 api_resource_controller_.reset(new extensions::APIResourceController()); |
2560 } | 2586 } |
2561 return api_resource_controller_.get(); | 2587 return api_resource_controller_.get(); |
2562 } | 2588 } |
OLD | NEW |