[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 1 | // Copyright 2014 The Chromium Authors. All rights reserved. |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 5 | #include "chrome/browser/extensions/extension_system_impl.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 6 | |
[email protected] | 53603d2 | 2012-11-14 08:31:11 | [diff] [blame] | 7 | #include "base/base_switches.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 8 | #include "base/bind.h" |
| 9 | #include "base/command_line.h" |
[email protected] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 10 | #include "base/files/file_path.h" |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 11 | #include "base/memory/weak_ptr.h" |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 12 | #include "base/metrics/field_trial.h" |
[email protected] | ef5a999 | 2014-07-25 21:45:24 | [diff] [blame] | 13 | #include "base/metrics/histogram.h" |
[email protected] | f4ebe77 | 2013-02-02 00:21:39 | [diff] [blame] | 14 | #include "base/strings/string_tokenizer.h" |
[email protected] | 15ad2ee | 2014-08-15 19:15:26 | [diff] [blame] | 15 | #include "base/strings/string_util.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 16 | #include "chrome/browser/browser_process.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 17 | #include "chrome/browser/content_settings/cookie_settings.h" |
[email protected] | 931186e0 | 2012-07-20 01:22:06 | [diff] [blame] | 18 | #include "chrome/browser/extensions/component_loader.h" |
hanxi | 6d9b43a | 2014-12-12 21:53:46 | [diff] [blame] | 19 | #include "chrome/browser/extensions/declarative_user_script_manager.h" |
[email protected] | 1b66fdb | 2013-07-26 09:57:28 | [diff] [blame] | 20 | #include "chrome/browser/extensions/error_console/error_console.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 21 | #include "chrome/browser/extensions/extension_error_reporter.h" |
binjin | 1569c9b | 2014-09-05 13:33:18 | [diff] [blame] | 22 | #include "chrome/browser/extensions/extension_management.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 23 | #include "chrome/browser/extensions/extension_service.h" |
| 24 | #include "chrome/browser/extensions/extension_system_factory.h" |
[email protected] | a7ff4b7 | 2013-10-17 20:56:02 | [diff] [blame] | 25 | #include "chrome/browser/extensions/extension_util.h" |
[email protected] | ffd2f79e | 2013-11-14 00:11:46 | [diff] [blame] | 26 | #include "chrome/browser/extensions/install_verifier.h" |
[email protected] | d9ede58 | 2012-08-14 19:21:38 | [diff] [blame] | 27 | #include "chrome/browser/extensions/navigation_observer.h" |
[email protected] | f698c16 | 2014-06-13 00:46:26 | [diff] [blame] | 28 | #include "chrome/browser/extensions/shared_module_service.h" |
[email protected] | 15ad2ee | 2014-08-15 19:15:26 | [diff] [blame] | 29 | #include "chrome/browser/extensions/shared_user_script_master.h" |
[email protected] | 479e392 | 2014-07-30 07:12:57 | [diff] [blame] | 30 | #include "chrome/browser/extensions/state_store_notification_observer.h" |
[email protected] | 13e062e | 2014-08-09 10:21:55 | [diff] [blame] | 31 | #include "chrome/browser/extensions/unpacked_installer.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 32 | #include "chrome/browser/profiles/profile.h" |
| 33 | #include "chrome/browser/profiles/profile_manager.h" |
[email protected] | 13e062e | 2014-08-09 10:21:55 | [diff] [blame] | 34 | #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 35 | #include "chrome/common/chrome_switches.h" |
[email protected] | d69d7b17 | 2012-08-09 04:17:26 | [diff] [blame] | 36 | #include "chrome/common/chrome_version_info.h" |
[email protected] | dccba4f8 | 2014-05-29 00:52:56 | [diff] [blame] | 37 | #include "chrome/common/extensions/extension_constants.h" |
[email protected] | 15d4d2d | 2013-08-09 06:49:03 | [diff] [blame] | 38 | #include "chrome/common/extensions/features/feature_channel.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 39 | #include "content/public/browser/browser_thread.h" |
[email protected] | 24ea7a1 | 2013-01-27 23:54:53 | [diff] [blame] | 40 | #include "content/public/browser/url_data_source.h" |
[email protected] | fd3df778 | 2014-05-08 23:54:27 | [diff] [blame] | 41 | #include "extensions/browser/content_verifier.h" |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 42 | #include "extensions/browser/content_verifier_delegate.h" |
[email protected] | 3442353 | 2013-11-21 18:13:10 | [diff] [blame] | 43 | #include "extensions/browser/event_router.h" |
[email protected] | 489db084 | 2014-01-22 18:20:03 | [diff] [blame] | 44 | #include "extensions/browser/extension_pref_store.h" |
| 45 | #include "extensions/browser/extension_pref_value_map.h" |
| 46 | #include "extensions/browser/extension_pref_value_map_factory.h" |
| 47 | #include "extensions/browser/extension_prefs.h" |
[email protected] | 45f5b7d | 2014-01-22 23:47:13 | [diff] [blame] | 48 | #include "extensions/browser/extension_registry.h" |
[email protected] | 38427a1 | 2013-11-09 17:34:20 | [diff] [blame] | 49 | #include "extensions/browser/info_map.h" |
[email protected] | 9fe4204 | 2013-10-29 21:13:33 | [diff] [blame] | 50 | #include "extensions/browser/lazy_background_task_queue.h" |
[email protected] | 301116c6 | 2013-11-26 10:37:45 | [diff] [blame] | 51 | #include "extensions/browser/management_policy.h" |
[email protected] | aab2310 | 2014-02-05 18:57:55 | [diff] [blame] | 52 | #include "extensions/browser/quota_service.h" |
[email protected] | 45f5b7d | 2014-01-22 23:47:13 | [diff] [blame] | 53 | #include "extensions/browser/runtime_data.h" |
[email protected] | daf3ffda | 2014-06-25 06:44:57 | [diff] [blame] | 54 | #include "extensions/browser/state_store.h" |
[email protected] | 836e298 | 2013-05-16 08:07:42 | [diff] [blame] | 55 | #include "extensions/common/constants.h" |
[email protected] | e4452d3 | 2013-11-15 23:07:41 | [diff] [blame] | 56 | #include "extensions/common/extension.h" |
rockot | 9065985 | 2014-09-18 19:31:52 | [diff] [blame] | 57 | #include "extensions/common/extension_urls.h" |
rockot | ec1e64b | 2014-11-13 22:06:51 | [diff] [blame] | 58 | #include "extensions/common/extensions_client.h" |
[email protected] | d42c1115 | 2013-08-22 19:36:32 | [diff] [blame] | 59 | #include "extensions/common/manifest.h" |
rockot | d554614 | 2014-10-15 00:29:08 | [diff] [blame] | 60 | #include "extensions/common/manifest_url_handlers.h" |
[email protected] | abd4cb2 | 2014-05-16 05:22:56 | [diff] [blame] | 61 | #include "net/base/escape.h" |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 62 | |
[email protected] | 9afacd2 | 2013-11-13 20:23:31 | [diff] [blame] | 63 | #if defined(ENABLE_NOTIFICATIONS) |
| 64 | #include "chrome/browser/notifications/desktop_notification_service.h" |
| 65 | #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
| 66 | #include "ui/message_center/notifier_settings.h" |
| 67 | #endif |
| 68 | |
[email protected] | bb12148 | 2012-12-08 06:49:38 | [diff] [blame] | 69 | #if defined(OS_CHROMEOS) |
[email protected] | 6ed2e0c | 2013-04-09 04:48:13 | [diff] [blame] | 70 | #include "chrome/browser/app_mode/app_mode_utils.h" |
[email protected] | 1a643611 | 2013-10-09 02:49:58 | [diff] [blame] | 71 | #include "chrome/browser/chromeos/extensions/device_local_account_management_policy_provider.h" |
[email protected] | 1a643611 | 2013-10-09 02:49:58 | [diff] [blame] | 72 | #include "chrome/browser/chromeos/policy/device_local_account.h" |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 73 | #include "chrome/browser/extensions/extension_assets_manager_chromeos.h" |
[email protected] | 931d104 | 2013-04-05 17:50:44 | [diff] [blame] | 74 | #include "chromeos/chromeos_switches.h" |
[email protected] | c57397a | 2013-04-18 19:41:11 | [diff] [blame] | 75 | #include "chromeos/login/login_state.h" |
[email protected] | 2fda997 | 2014-07-23 14:51:59 | [diff] [blame] | 76 | #include "components/user_manager/user.h" |
[email protected] | 4d39078 | 2014-08-15 09:22:58 | [diff] [blame] | 77 | #include "components/user_manager/user_manager.h" |
[email protected] | bb12148 | 2012-12-08 06:49:38 | [diff] [blame] | 78 | #endif |
| 79 | |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 80 | using content::BrowserThread; |
| 81 | |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 82 | namespace { |
| 83 | |
| 84 | const char kContentVerificationExperimentName[] = |
| 85 | "ExtensionContentVerification"; |
| 86 | |
| 87 | } // namespace |
| 88 | |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 89 | namespace extensions { |
| 90 | |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 91 | // |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 92 | // ExtensionSystemImpl::Shared |
| 93 | // |
| 94 | |
| 95 | ExtensionSystemImpl::Shared::Shared(Profile* profile) |
| 96 | : profile_(profile) { |
| 97 | } |
| 98 | |
| 99 | ExtensionSystemImpl::Shared::~Shared() { |
| 100 | } |
| 101 | |
| 102 | void ExtensionSystemImpl::Shared::InitPrefs() { |
[email protected] | c4dc5cc | 2012-11-09 08:48:39 | [diff] [blame] | 103 | lazy_background_task_queue_.reset(new LazyBackgroundTaskQueue(profile_)); |
[email protected] | 836e298 | 2013-05-16 08:07:42 | [diff] [blame] | 104 | event_router_.reset(new EventRouter(profile_, ExtensionPrefs::Get(profile_))); |
[email protected] | a690e29 | 2012-12-19 19:22:49 | [diff] [blame] | 105 | // Two state stores. The latter, which contains declarative rules, must be |
| 106 | // loaded immediately so that the rules are ready before we issue network |
| 107 | // requests. |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 108 | state_store_.reset(new StateStore( |
[email protected] | 90e800c | 2012-06-12 23:11:00 | [diff] [blame] | 109 | profile_, |
[email protected] | 501105b | 2013-09-26 05:42:02 | [diff] [blame] | 110 | profile_->GetPath().AppendASCII(extensions::kStateStoreName), |
[email protected] | a690e29 | 2012-12-19 19:22:49 | [diff] [blame] | 111 | true)); |
[email protected] | 479e392 | 2014-07-30 07:12:57 | [diff] [blame] | 112 | state_store_notification_observer_.reset( |
| 113 | new StateStoreNotificationObserver(state_store_.get())); |
[email protected] | d3bd607 | 2013-07-26 18:32:14 | [diff] [blame] | 114 | |
[email protected] | a690e29 | 2012-12-19 19:22:49 | [diff] [blame] | 115 | rules_store_.reset(new StateStore( |
| 116 | profile_, |
[email protected] | 501105b | 2013-09-26 05:42:02 | [diff] [blame] | 117 | profile_->GetPath().AppendASCII(extensions::kRulesStoreName), |
[email protected] | a690e29 | 2012-12-19 19:22:49 | [diff] [blame] | 118 | false)); |
[email protected] | cb610dc | 2012-08-31 17:16:56 | [diff] [blame] | 119 | |
[email protected] | 13e062e | 2014-08-09 10:21:55 | [diff] [blame] | 120 | #if defined(OS_CHROMEOS) |
[email protected] | 2fda997 | 2014-07-23 14:51:59 | [diff] [blame] | 121 | const user_manager::User* user = |
[email protected] | 4d39078 | 2014-08-15 09:22:58 | [diff] [blame] | 122 | user_manager::UserManager::Get()->GetActiveUser(); |
[email protected] | 1a643611 | 2013-10-09 02:49:58 | [diff] [blame] | 123 | policy::DeviceLocalAccount::Type device_local_account_type; |
| 124 | if (user && policy::IsDeviceLocalAccountUser(user->email(), |
| 125 | &device_local_account_type)) { |
| 126 | device_local_account_management_policy_provider_.reset( |
| 127 | new chromeos::DeviceLocalAccountManagementPolicyProvider( |
| 128 | device_local_account_type)); |
| 129 | } |
[email protected] | 13e062e | 2014-08-09 10:21:55 | [diff] [blame] | 130 | #endif // defined(OS_CHROMEOS) |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 131 | } |
| 132 | |
[email protected] | 6518715 | 2012-06-02 13:14:14 | [diff] [blame] | 133 | void ExtensionSystemImpl::Shared::RegisterManagementPolicyProviders() { |
binjin | e6b58b5 | 2014-10-31 01:55:57 | [diff] [blame] | 134 | management_policy_->RegisterProviders( |
binjin | 1569c9b | 2014-09-05 13:33:18 | [diff] [blame] | 135 | ExtensionManagementFactory::GetForBrowserContext(profile_) |
binjin | e6b58b5 | 2014-10-31 01:55:57 | [diff] [blame] | 136 | ->GetProviders()); |
[email protected] | 1a643611 | 2013-10-09 02:49:58 | [diff] [blame] | 137 | |
[email protected] | 13e062e | 2014-08-09 10:21:55 | [diff] [blame] | 138 | #if defined(OS_CHROMEOS) |
[email protected] | 1a643611 | 2013-10-09 02:49:58 | [diff] [blame] | 139 | if (device_local_account_management_policy_provider_) { |
| 140 | management_policy_->RegisterProvider( |
| 141 | device_local_account_management_policy_provider_.get()); |
| 142 | } |
[email protected] | 13e062e | 2014-08-09 10:21:55 | [diff] [blame] | 143 | #endif // defined(OS_CHROMEOS) |
[email protected] | 1a643611 | 2013-10-09 02:49:58 | [diff] [blame] | 144 | |
[email protected] | ffd2f79e | 2013-11-14 00:11:46 | [diff] [blame] | 145 | management_policy_->RegisterProvider(install_verifier_.get()); |
[email protected] | 6518715 | 2012-06-02 13:14:14 | [diff] [blame] | 146 | } |
| 147 | |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 148 | namespace { |
| 149 | |
| 150 | class ContentVerifierDelegateImpl : public ContentVerifierDelegate { |
| 151 | public: |
| 152 | explicit ContentVerifierDelegateImpl(ExtensionService* service) |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 153 | : service_(service->AsWeakPtr()), default_mode_(GetDefaultMode()) {} |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 154 | |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 155 | ~ContentVerifierDelegateImpl() override {} |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 156 | |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 157 | Mode ShouldBeVerified(const Extension& extension) override { |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 158 | #if defined(OS_CHROMEOS) |
| 159 | if (ExtensionAssetsManagerChromeOS::IsSharedInstall(&extension)) |
| 160 | return ContentVerifierDelegate::ENFORCE_STRICT; |
| 161 | #endif |
| 162 | |
[email protected] | abd4cb2 | 2014-05-16 05:22:56 | [diff] [blame] | 163 | if (!extension.is_extension() && !extension.is_legacy_packaged_app()) |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 164 | return ContentVerifierDelegate::NONE; |
[email protected] | abd4cb2 | 2014-05-16 05:22:56 | [diff] [blame] | 165 | if (!Manifest::IsAutoUpdateableLocation(extension.location())) |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 166 | return ContentVerifierDelegate::NONE; |
[email protected] | abd4cb2 | 2014-05-16 05:22:56 | [diff] [blame] | 167 | |
| 168 | if (!ManifestURL::UpdatesFromGallery(&extension)) { |
| 169 | // It's possible that the webstore update url was overridden for testing |
| 170 | // so also consider extensions with the default (production) update url |
| 171 | // to be from the store as well. |
| 172 | GURL default_webstore_url = extension_urls::GetDefaultWebstoreUpdateUrl(); |
| 173 | if (ManifestURL::GetUpdateURL(&extension) != default_webstore_url) |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 174 | return ContentVerifierDelegate::NONE; |
[email protected] | abd4cb2 | 2014-05-16 05:22:56 | [diff] [blame] | 175 | } |
| 176 | |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 177 | return default_mode_; |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 178 | } |
| 179 | |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 180 | const ContentVerifierKey& PublicKey() override { |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 181 | static ContentVerifierKey key( |
| 182 | extension_misc::kWebstoreSignaturesPublicKey, |
| 183 | extension_misc::kWebstoreSignaturesPublicKeySize); |
| 184 | return key; |
| 185 | } |
| 186 | |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 187 | GURL GetSignatureFetchUrl(const std::string& extension_id, |
| 188 | const base::Version& version) override { |
[email protected] | abd4cb2 | 2014-05-16 05:22:56 | [diff] [blame] | 189 | // TODO(asargent) Factor out common code from the extension updater's |
| 190 | // ManifestFetchData class that can be shared for use here. |
| 191 | std::vector<std::string> parts; |
| 192 | parts.push_back("uc"); |
| 193 | parts.push_back("installsource=signature"); |
| 194 | parts.push_back("id=" + extension_id); |
| 195 | parts.push_back("v=" + version.GetString()); |
| 196 | std::string x_value = |
| 197 | net::EscapeQueryParamValue(JoinString(parts, "&"), true); |
| 198 | std::string query = "response=redirect&x=" + x_value; |
| 199 | |
| 200 | GURL base_url = extension_urls::GetWebstoreUpdateUrl(); |
| 201 | GURL::Replacements replacements; |
| 202 | replacements.SetQuery(query.c_str(), url::Component(0, query.length())); |
| 203 | return base_url.ReplaceComponents(replacements); |
| 204 | } |
| 205 | |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 206 | std::set<base::FilePath> GetBrowserImagePaths( |
mostynb | a15bee1 | 2014-10-04 00:40:32 | [diff] [blame] | 207 | const extensions::Extension* extension) override { |
rockot | ec1e64b | 2014-11-13 22:06:51 | [diff] [blame] | 208 | return ExtensionsClient::Get()->GetBrowserImagePaths(extension); |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 209 | } |
| 210 | |
dcheng | ae36a4a | 2014-10-21 12:36:36 | [diff] [blame] | 211 | void VerifyFailed(const std::string& extension_id, |
| 212 | ContentVerifyJob::FailureReason reason) override { |
[email protected] | 6a5898e | 2014-07-22 23:33:54 | [diff] [blame] | 213 | if (!service_) |
| 214 | return; |
| 215 | ExtensionRegistry* registry = ExtensionRegistry::Get(service_->profile()); |
| 216 | const Extension* extension = |
[email protected] | ef5a999 | 2014-07-25 21:45:24 | [diff] [blame] | 217 | registry->GetExtensionById(extension_id, ExtensionRegistry::ENABLED); |
[email protected] | 6a5898e | 2014-07-22 23:33:54 | [diff] [blame] | 218 | if (!extension) |
| 219 | return; |
| 220 | Mode mode = ShouldBeVerified(*extension); |
[email protected] | ef5a999 | 2014-07-25 21:45:24 | [diff] [blame] | 221 | if (mode >= ContentVerifierDelegate::ENFORCE) { |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 222 | service_->DisableExtension(extension_id, Extension::DISABLE_CORRUPTED); |
[email protected] | ef5a999 | 2014-07-25 21:45:24 | [diff] [blame] | 223 | ExtensionPrefs::Get(service_->profile()) |
| 224 | ->IncrementCorruptedDisableCount(); |
| 225 | UMA_HISTOGRAM_BOOLEAN("Extensions.CorruptExtensionBecameDisabled", true); |
rockot | eb1491d | 2014-10-07 03:56:40 | [diff] [blame] | 226 | UMA_HISTOGRAM_ENUMERATION("Extensions.CorruptExtensionDisabledReason", |
| 227 | reason, ContentVerifyJob::FAILURE_REASON_MAX); |
[email protected] | ef5a999 | 2014-07-25 21:45:24 | [diff] [blame] | 228 | } else if (!ContainsKey(would_be_disabled_ids_, extension_id)) { |
| 229 | UMA_HISTOGRAM_BOOLEAN("Extensions.CorruptExtensionWouldBeDisabled", true); |
| 230 | would_be_disabled_ids_.insert(extension_id); |
| 231 | } |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 232 | } |
| 233 | |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 234 | static Mode GetDefaultMode() { |
| 235 | base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 236 | |
| 237 | Mode experiment_value = NONE; |
| 238 | const std::string group = base::FieldTrialList::FindFullName( |
| 239 | kContentVerificationExperimentName); |
| 240 | if (group == "EnforceStrict") |
| 241 | experiment_value = ContentVerifierDelegate::ENFORCE_STRICT; |
| 242 | else if (group == "Enforce") |
| 243 | experiment_value = ContentVerifierDelegate::ENFORCE; |
| 244 | else if (group == "Bootstrap") |
| 245 | experiment_value = ContentVerifierDelegate::BOOTSTRAP; |
| 246 | |
| 247 | // The field trial value that normally comes from the server can be |
| 248 | // overridden on the command line, which we don't want to allow since |
| 249 | // malware can set chrome command line flags. There isn't currently a way |
| 250 | // to find out what the server-provided value is in this case, so we |
| 251 | // conservatively default to the strictest mode if we detect our experiment |
| 252 | // name being overridden. |
| 253 | if (command_line->HasSwitch(switches::kForceFieldTrials)) { |
| 254 | std::string forced_trials = |
| 255 | command_line->GetSwitchValueASCII(switches::kForceFieldTrials); |
| 256 | if (forced_trials.find(kContentVerificationExperimentName) != |
| 257 | std::string::npos) |
| 258 | experiment_value = ContentVerifierDelegate::ENFORCE_STRICT; |
| 259 | } |
| 260 | |
| 261 | Mode cmdline_value = NONE; |
| 262 | if (command_line->HasSwitch(switches::kExtensionContentVerification)) { |
| 263 | std::string switch_value = command_line->GetSwitchValueASCII( |
| 264 | switches::kExtensionContentVerification); |
| 265 | if (switch_value == switches::kExtensionContentVerificationBootstrap) |
| 266 | cmdline_value = ContentVerifierDelegate::BOOTSTRAP; |
| 267 | else if (switch_value == switches::kExtensionContentVerificationEnforce) |
| 268 | cmdline_value = ContentVerifierDelegate::ENFORCE; |
| 269 | else if (switch_value == |
| 270 | switches::kExtensionContentVerificationEnforceStrict) |
| 271 | cmdline_value = ContentVerifierDelegate::ENFORCE_STRICT; |
| 272 | else |
| 273 | // If no value was provided (or the wrong one), just default to enforce. |
| 274 | cmdline_value = ContentVerifierDelegate::ENFORCE; |
| 275 | } |
| 276 | |
| 277 | // We don't want to allow the command-line flags to eg disable enforcement |
| 278 | // if the experiment group says it should be on, or malware may just modify |
| 279 | // the command line flags. So return the more restrictive of the 2 values. |
| 280 | return std::max(experiment_value, cmdline_value); |
| 281 | } |
| 282 | |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 283 | private: |
| 284 | base::WeakPtr<ExtensionService> service_; |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 285 | ContentVerifierDelegate::Mode default_mode_; |
[email protected] | ef5a999 | 2014-07-25 21:45:24 | [diff] [blame] | 286 | |
| 287 | // For reporting metrics in BOOTSTRAP mode, when an extension would be |
| 288 | // disabled if content verification was in ENFORCE mode. |
| 289 | std::set<std::string> would_be_disabled_ids_; |
| 290 | |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 291 | DISALLOW_COPY_AND_ASSIGN(ContentVerifierDelegateImpl); |
| 292 | }; |
| 293 | |
| 294 | } // namespace |
[email protected] | fd3df778 | 2014-05-08 23:54:27 | [diff] [blame] | 295 | |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 296 | void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame^] | 297 | const base::CommandLine* command_line = |
| 298 | base::CommandLine::ForCurrentProcess(); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 299 | |
[email protected] | d9ede58 | 2012-08-14 19:21:38 | [diff] [blame] | 300 | navigation_observer_.reset(new NavigationObserver(profile_)); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 301 | |
[email protected] | 53603d2 | 2012-11-14 08:31:11 | [diff] [blame] | 302 | bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs); |
| 303 | ExtensionErrorReporter::Init(allow_noisy_errors); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 304 | |
[email protected] | 15ad2ee | 2014-08-15 19:15:26 | [diff] [blame] | 305 | shared_user_script_master_.reset(new SharedUserScriptMaster(profile_)); |
hanxi | 6d9b43a | 2014-12-12 21:53:46 | [diff] [blame] | 306 | declarative_user_script_manager_.reset( |
| 307 | new DeclarativeUserScriptManager(profile_)); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 308 | |
[email protected] | 45f5b7d | 2014-01-22 23:47:13 | [diff] [blame] | 309 | // ExtensionService depends on RuntimeData. |
| 310 | runtime_data_.reset(new RuntimeData(ExtensionRegistry::Get(profile_))); |
| 311 | |
[email protected] | acb3f66 | 2014-02-18 19:07:10 | [diff] [blame] | 312 | bool autoupdate_enabled = !profile_->IsGuestSession(); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 313 | #if defined(OS_CHROMEOS) |
| 314 | if (!extensions_enabled) |
| 315 | autoupdate_enabled = false; |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 316 | #endif |
| 317 | extension_service_.reset(new ExtensionService( |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame^] | 318 | profile_, base::CommandLine::ForCurrentProcess(), |
[email protected] | 836e298 | 2013-05-16 08:07:42 | [diff] [blame] | 319 | profile_->GetPath().AppendASCII(extensions::kInstallDirectoryName), |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame^] | 320 | ExtensionPrefs::Get(profile_), Blacklist::Get(profile_), |
| 321 | autoupdate_enabled, extensions_enabled, &ready_)); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 322 | |
[email protected] | d7fbc09 | 2012-06-18 22:52:00 | [diff] [blame] | 323 | // These services must be registered before the ExtensionService tries to |
| 324 | // load any extensions. |
| 325 | { |
[email protected] | 913ffca9 | 2014-03-27 15:26:16 | [diff] [blame] | 326 | install_verifier_.reset( |
| 327 | new InstallVerifier(ExtensionPrefs::Get(profile_), profile_)); |
[email protected] | ffd2f79e | 2013-11-14 00:11:46 | [diff] [blame] | 328 | install_verifier_->Init(); |
[email protected] | f83bd43 | 2014-05-10 20:44:40 | [diff] [blame] | 329 | content_verifier_ = new ContentVerifier( |
| 330 | profile_, new ContentVerifierDelegateImpl(extension_service_.get())); |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 331 | ContentVerifierDelegate::Mode mode = |
| 332 | ContentVerifierDelegateImpl::GetDefaultMode(); |
| 333 | #if defined(OS_CHROMEOS) |
| 334 | mode = std::max(mode, ContentVerifierDelegate::BOOTSTRAP); |
| 335 | #endif |
[email protected] | 6a5898e | 2014-07-22 23:33:54 | [diff] [blame] | 336 | if (mode >= ContentVerifierDelegate::BOOTSTRAP) |
[email protected] | 8bb6216 | 2014-06-23 09:45:50 | [diff] [blame] | 337 | content_verifier_->Start(); |
[email protected] | fd3df778 | 2014-05-08 23:54:27 | [diff] [blame] | 338 | info_map()->SetContentVerifier(content_verifier_.get()); |
[email protected] | ffd2f79e | 2013-11-14 00:11:46 | [diff] [blame] | 339 | |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 340 | management_policy_.reset(new ManagementPolicy); |
[email protected] | d7fbc09 | 2012-06-18 22:52:00 | [diff] [blame] | 341 | RegisterManagementPolicyProviders(); |
| 342 | } |
[email protected] | 6518715 | 2012-06-02 13:14:14 | [diff] [blame] | 343 | |
[email protected] | bb12148 | 2012-12-08 06:49:38 | [diff] [blame] | 344 | bool skip_session_extensions = false; |
| 345 | #if defined(OS_CHROMEOS) |
| 346 | // Skip loading session extensions if we are not in a user session. |
[email protected] | c57397a | 2013-04-18 19:41:11 | [diff] [blame] | 347 | skip_session_extensions = !chromeos::LoginState::Get()->IsUserLoggedIn(); |
[email protected] | 531593d | 2014-01-08 18:48:31 | [diff] [blame] | 348 | if (chrome::IsRunningInForcedAppMode()) { |
| 349 | extension_service_->component_loader()-> |
| 350 | AddDefaultComponentExtensionsForKioskMode(skip_session_extensions); |
| 351 | } else { |
[email protected] | 6ed2e0c | 2013-04-09 04:48:13 | [diff] [blame] | 352 | extension_service_->component_loader()->AddDefaultComponentExtensions( |
| 353 | skip_session_extensions); |
| 354 | } |
| 355 | #else |
[email protected] | bb12148 | 2012-12-08 06:49:38 | [diff] [blame] | 356 | extension_service_->component_loader()->AddDefaultComponentExtensions( |
| 357 | skip_session_extensions); |
[email protected] | 6ed2e0c | 2013-04-09 04:48:13 | [diff] [blame] | 358 | #endif |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 359 | if (command_line->HasSwitch(switches::kLoadComponentExtension)) { |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame^] | 360 | base::CommandLine::StringType path_list = |
| 361 | command_line->GetSwitchValueNative(switches::kLoadComponentExtension); |
| 362 | base::StringTokenizerT<base::CommandLine::StringType, |
| 363 | base::CommandLine::StringType::const_iterator> |
| 364 | t(path_list, FILE_PATH_LITERAL(",")); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 365 | while (t.GetNext()) { |
| 366 | // Load the component extension manifest synchronously. |
| 367 | // Blocking the UI thread is acceptable here since |
| 368 | // this flag designated for developers. |
| 369 | base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 370 | extension_service_->component_loader()->AddOrReplace( |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 371 | base::FilePath(t.token())); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 372 | } |
| 373 | } |
| 374 | extension_service_->Init(); |
| 375 | |
[email protected] | c1909afb | 2013-11-13 21:12:51 | [diff] [blame] | 376 | // Make the chrome://extension-icon/ resource available. |
| 377 | content::URLDataSource::Add(profile_, new ExtensionIconSource(profile_)); |
| 378 | |
[email protected] | 0659dc9 | 2014-04-01 19:23:37 | [diff] [blame] | 379 | error_console_.reset(new ErrorConsole(profile_)); |
[email protected] | aab2310 | 2014-02-05 18:57:55 | [diff] [blame] | 380 | quota_service_.reset(new QuotaService); |
[email protected] | c1909afb | 2013-11-13 21:12:51 | [diff] [blame] | 381 | |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 382 | if (extensions_enabled) { |
| 383 | // Load any extensions specified with --load-extension. |
| 384 | // TODO(yoz): Seems like this should move into ExtensionService::Init. |
| 385 | // But maybe it's no longer important. |
| 386 | if (command_line->HasSwitch(switches::kLoadExtension)) { |
avi | 3ef9ec9e | 2014-12-22 22:50:17 | [diff] [blame^] | 387 | base::CommandLine::StringType path_list = |
| 388 | command_line->GetSwitchValueNative(switches::kLoadExtension); |
| 389 | base::StringTokenizerT<base::CommandLine::StringType, |
| 390 | base::CommandLine::StringType::const_iterator> |
| 391 | t(path_list, FILE_PATH_LITERAL(",")); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 392 | while (t.GetNext()) { |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 393 | std::string extension_id; |
[email protected] | 9827043 | 2012-09-11 20:51:24 | [diff] [blame] | 394 | UnpackedInstaller::Create(extension_service_.get())-> |
[email protected] | 2a69b94 | 2013-05-31 09:37:53 | [diff] [blame] | 395 | LoadFromCommandLine(base::FilePath(t.token()), &extension_id); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 396 | } |
| 397 | } |
| 398 | } |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 399 | } |
| 400 | |
[email protected] | 47b89656 | 2012-08-22 23:55:15 | [diff] [blame] | 401 | void ExtensionSystemImpl::Shared::Shutdown() { |
dcheng | c704794 | 2014-08-26 05:05:31 | [diff] [blame] | 402 | if (content_verifier_.get()) |
[email protected] | fd3df778 | 2014-05-08 23:54:27 | [diff] [blame] | 403 | content_verifier_->Shutdown(); |
[email protected] | 3eeddd89 | 2013-04-17 17:00:11 | [diff] [blame] | 404 | if (extension_service_) |
[email protected] | 47b89656 | 2012-08-22 23:55:15 | [diff] [blame] | 405 | extension_service_->Shutdown(); |
| 406 | } |
| 407 | |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 408 | StateStore* ExtensionSystemImpl::Shared::state_store() { |
[email protected] | 90e800c | 2012-06-12 23:11:00 | [diff] [blame] | 409 | return state_store_.get(); |
| 410 | } |
| 411 | |
[email protected] | a690e29 | 2012-12-19 19:22:49 | [diff] [blame] | 412 | StateStore* ExtensionSystemImpl::Shared::rules_store() { |
| 413 | return rules_store_.get(); |
| 414 | } |
| 415 | |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 416 | ExtensionService* ExtensionSystemImpl::Shared::extension_service() { |
| 417 | return extension_service_.get(); |
| 418 | } |
| 419 | |
[email protected] | 45f5b7d | 2014-01-22 23:47:13 | [diff] [blame] | 420 | RuntimeData* ExtensionSystemImpl::Shared::runtime_data() { |
| 421 | return runtime_data_.get(); |
| 422 | } |
| 423 | |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 424 | ManagementPolicy* ExtensionSystemImpl::Shared::management_policy() { |
[email protected] | 6518715 | 2012-06-02 13:14:14 | [diff] [blame] | 425 | return management_policy_.get(); |
| 426 | } |
| 427 | |
[email protected] | 15ad2ee | 2014-08-15 19:15:26 | [diff] [blame] | 428 | SharedUserScriptMaster* |
| 429 | ExtensionSystemImpl::Shared::shared_user_script_master() { |
| 430 | return shared_user_script_master_.get(); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 431 | } |
| 432 | |
hanxi | 6d9b43a | 2014-12-12 21:53:46 | [diff] [blame] | 433 | DeclarativeUserScriptManager* |
| 434 | ExtensionSystemImpl::Shared::declarative_user_script_manager() { |
| 435 | return declarative_user_script_manager_.get(); |
| 436 | } |
| 437 | |
[email protected] | 38427a1 | 2013-11-09 17:34:20 | [diff] [blame] | 438 | InfoMap* ExtensionSystemImpl::Shared::info_map() { |
[email protected] | dc24976f | 2013-06-02 21:15:09 | [diff] [blame] | 439 | if (!extension_info_map_.get()) |
[email protected] | 38427a1 | 2013-11-09 17:34:20 | [diff] [blame] | 440 | extension_info_map_ = new InfoMap(); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 441 | return extension_info_map_.get(); |
| 442 | } |
| 443 | |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 444 | LazyBackgroundTaskQueue* |
| 445 | ExtensionSystemImpl::Shared::lazy_background_task_queue() { |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 446 | return lazy_background_task_queue_.get(); |
| 447 | } |
| 448 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 449 | EventRouter* ExtensionSystemImpl::Shared::event_router() { |
[email protected] | c4dc5cc | 2012-11-09 08:48:39 | [diff] [blame] | 450 | return event_router_.get(); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 451 | } |
| 452 | |
[email protected] | 1b66fdb | 2013-07-26 09:57:28 | [diff] [blame] | 453 | ErrorConsole* ExtensionSystemImpl::Shared::error_console() { |
| 454 | return error_console_.get(); |
| 455 | } |
| 456 | |
[email protected] | ffd2f79e | 2013-11-14 00:11:46 | [diff] [blame] | 457 | InstallVerifier* ExtensionSystemImpl::Shared::install_verifier() { |
| 458 | return install_verifier_.get(); |
| 459 | } |
| 460 | |
[email protected] | aab2310 | 2014-02-05 18:57:55 | [diff] [blame] | 461 | QuotaService* ExtensionSystemImpl::Shared::quota_service() { |
| 462 | return quota_service_.get(); |
| 463 | } |
| 464 | |
[email protected] | fd3df778 | 2014-05-08 23:54:27 | [diff] [blame] | 465 | ContentVerifier* ExtensionSystemImpl::Shared::content_verifier() { |
| 466 | return content_verifier_.get(); |
| 467 | } |
| 468 | |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 469 | // |
| 470 | // ExtensionSystemImpl |
| 471 | // |
| 472 | |
| 473 | ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile) |
[email protected] | 98b67303 | 2012-12-11 10:26:02 | [diff] [blame] | 474 | : profile_(profile) { |
[email protected] | 59b0e60 | 2014-01-30 00:41:24 | [diff] [blame] | 475 | shared_ = ExtensionSystemSharedFactory::GetForBrowserContext(profile); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 476 | |
reillyg | 0ea3fa90 | 2014-10-28 15:30:23 | [diff] [blame] | 477 | if (!profile->IsOffTheRecord()) { |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 478 | shared_->InitPrefs(); |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | ExtensionSystemImpl::~ExtensionSystemImpl() { |
| 483 | } |
| 484 | |
| 485 | void ExtensionSystemImpl::Shutdown() { |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 486 | } |
| 487 | |
[email protected] | 7cf1ee4 | 2013-12-11 09:13:49 | [diff] [blame] | 488 | void ExtensionSystemImpl::InitForRegularProfile(bool extensions_enabled) { |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 489 | DCHECK(!profile_->IsOffTheRecord()); |
[email protected] | 15ad2ee | 2014-08-15 19:15:26 | [diff] [blame] | 490 | if (shared_user_script_master() || extension_service()) |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 491 | return; // Already initialized. |
| 492 | |
[email protected] | 98b6d94 | 2013-11-10 00:34:07 | [diff] [blame] | 493 | // The InfoMap needs to be created before the ProcessManager. |
[email protected] | 9656bc5 | 2012-08-13 17:05:33 | [diff] [blame] | 494 | shared_->info_map(); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 495 | shared_->Init(extensions_enabled); |
| 496 | } |
| 497 | |
| 498 | ExtensionService* ExtensionSystemImpl::extension_service() { |
| 499 | return shared_->extension_service(); |
| 500 | } |
| 501 | |
[email protected] | 45f5b7d | 2014-01-22 23:47:13 | [diff] [blame] | 502 | RuntimeData* ExtensionSystemImpl::runtime_data() { |
| 503 | return shared_->runtime_data(); |
| 504 | } |
| 505 | |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 506 | ManagementPolicy* ExtensionSystemImpl::management_policy() { |
[email protected] | 6518715 | 2012-06-02 13:14:14 | [diff] [blame] | 507 | return shared_->management_policy(); |
| 508 | } |
| 509 | |
[email protected] | 15ad2ee | 2014-08-15 19:15:26 | [diff] [blame] | 510 | SharedUserScriptMaster* ExtensionSystemImpl::shared_user_script_master() { |
| 511 | return shared_->shared_user_script_master(); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 512 | } |
| 513 | |
hanxi | 6d9b43a | 2014-12-12 21:53:46 | [diff] [blame] | 514 | DeclarativeUserScriptManager* |
| 515 | ExtensionSystemImpl::declarative_user_script_manager() { |
| 516 | return shared_->declarative_user_script_manager(); |
| 517 | } |
| 518 | |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 519 | StateStore* ExtensionSystemImpl::state_store() { |
[email protected] | 90e800c | 2012-06-12 23:11:00 | [diff] [blame] | 520 | return shared_->state_store(); |
| 521 | } |
| 522 | |
[email protected] | a690e29 | 2012-12-19 19:22:49 | [diff] [blame] | 523 | StateStore* ExtensionSystemImpl::rules_store() { |
| 524 | return shared_->rules_store(); |
| 525 | } |
| 526 | |
[email protected] | 38427a1 | 2013-11-09 17:34:20 | [diff] [blame] | 527 | InfoMap* ExtensionSystemImpl::info_map() { return shared_->info_map(); } |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 528 | |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 529 | LazyBackgroundTaskQueue* ExtensionSystemImpl::lazy_background_task_queue() { |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 530 | return shared_->lazy_background_task_queue(); |
| 531 | } |
| 532 | |
[email protected] | 5a38dfd | 2012-07-23 23:22:10 | [diff] [blame] | 533 | EventRouter* ExtensionSystemImpl::event_router() { |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 534 | return shared_->event_router(); |
| 535 | } |
| 536 | |
[email protected] | 4a10006a | 2013-05-17 23:18:35 | [diff] [blame] | 537 | const OneShotEvent& ExtensionSystemImpl::ready() const { |
| 538 | return shared_->ready(); |
| 539 | } |
| 540 | |
[email protected] | 1b66fdb | 2013-07-26 09:57:28 | [diff] [blame] | 541 | ErrorConsole* ExtensionSystemImpl::error_console() { |
| 542 | return shared_->error_console(); |
| 543 | } |
| 544 | |
[email protected] | ffd2f79e | 2013-11-14 00:11:46 | [diff] [blame] | 545 | InstallVerifier* ExtensionSystemImpl::install_verifier() { |
| 546 | return shared_->install_verifier(); |
| 547 | } |
| 548 | |
[email protected] | aab2310 | 2014-02-05 18:57:55 | [diff] [blame] | 549 | QuotaService* ExtensionSystemImpl::quota_service() { |
| 550 | return shared_->quota_service(); |
| 551 | } |
| 552 | |
[email protected] | fd3df778 | 2014-05-08 23:54:27 | [diff] [blame] | 553 | ContentVerifier* ExtensionSystemImpl::content_verifier() { |
| 554 | return shared_->content_verifier(); |
| 555 | } |
| 556 | |
[email protected] | f698c16 | 2014-06-13 00:46:26 | [diff] [blame] | 557 | scoped_ptr<ExtensionSet> ExtensionSystemImpl::GetDependentExtensions( |
| 558 | const Extension* extension) { |
| 559 | return extension_service()->shared_module_service()->GetDependentExtensions( |
| 560 | extension); |
| 561 | } |
| 562 | |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 563 | void ExtensionSystemImpl::RegisterExtensionWithRequestContexts( |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 564 | const Extension* extension) { |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 565 | base::Time install_time; |
[email protected] | 1d5e58b | 2013-01-31 08:41:40 | [diff] [blame] | 566 | if (extension->location() != Manifest::COMPONENT) { |
[email protected] | 836e298 | 2013-05-16 08:07:42 | [diff] [blame] | 567 | install_time = ExtensionPrefs::Get(profile_)-> |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 568 | GetInstallTime(extension->id()); |
| 569 | } |
[email protected] | 1d5cf414 | 2014-01-24 18:25:22 | [diff] [blame] | 570 | bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_); |
[email protected] | 9afacd2 | 2013-11-13 20:23:31 | [diff] [blame] | 571 | |
| 572 | bool notifications_disabled = false; |
| 573 | #if defined(ENABLE_NOTIFICATIONS) |
| 574 | message_center::NotifierId notifier_id( |
| 575 | message_center::NotifierId::APPLICATION, |
| 576 | extension->id()); |
| 577 | |
| 578 | DesktopNotificationService* notification_service = |
| 579 | DesktopNotificationServiceFactory::GetForProfile(profile_); |
| 580 | notifications_disabled = |
| 581 | !notification_service->IsNotifierEnabled(notifier_id); |
| 582 | #endif |
| 583 | |
| 584 | BrowserThread::PostTask( |
| 585 | BrowserThread::IO, FROM_HERE, |
| 586 | base::Bind(&InfoMap::AddExtension, info_map(), |
| 587 | make_scoped_refptr(extension), install_time, |
| 588 | incognito_enabled, notifications_disabled)); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 589 | } |
| 590 | |
| 591 | void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( |
| 592 | const std::string& extension_id, |
[email protected] | b0af479 | 2013-10-23 09:12:13 | [diff] [blame] | 593 | const UnloadedExtensionInfo::Reason reason) { |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 594 | BrowserThread::PostTask( |
[email protected] | 38427a1 | 2013-11-09 17:34:20 | [diff] [blame] | 595 | BrowserThread::IO, |
| 596 | FROM_HERE, |
| 597 | base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); |
[email protected] | 31d8f5f2 | 2012-04-02 15:22:08 | [diff] [blame] | 598 | } |
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 599 | |
| 600 | } // namespace extensions |