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