Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_system_impl.h" | 5 #include "chrome/browser/extensions/extension_system_impl.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 #include "chrome/browser/extensions/standard_management_policy_provider.h" | 25 #include "chrome/browser/extensions/standard_management_policy_provider.h" |
| 26 #include "chrome/browser/extensions/state_store.h" | 26 #include "chrome/browser/extensions/state_store.h" |
| 27 #include "chrome/browser/extensions/unpacked_installer.h" | 27 #include "chrome/browser/extensions/unpacked_installer.h" |
| 28 #include "chrome/browser/extensions/user_script_master.h" | 28 #include "chrome/browser/extensions/user_script_master.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
| 31 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 31 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 32 #include "chrome/common/chrome_switches.h" | 32 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/chrome_version_info.h" | 33 #include "chrome/common/chrome_version_info.h" |
| 34 #include "chrome/common/extensions/features/feature_channel.h" | 34 #include "chrome/common/extensions/features/feature_channel.h" |
| 35 #include "chrome/common/extensions/manifest_url_handler.h" | |
| 35 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 36 #include "content/public/browser/url_data_source.h" | 37 #include "content/public/browser/url_data_source.h" |
| 37 #include "extensions/browser/event_router.h" | 38 #include "extensions/browser/event_router.h" |
| 38 #include "extensions/browser/extension_pref_store.h" | 39 #include "extensions/browser/extension_pref_store.h" |
| 39 #include "extensions/browser/extension_pref_value_map.h" | 40 #include "extensions/browser/extension_pref_value_map.h" |
| 40 #include "extensions/browser/extension_pref_value_map_factory.h" | 41 #include "extensions/browser/extension_pref_value_map_factory.h" |
| 41 #include "extensions/browser/extension_prefs.h" | 42 #include "extensions/browser/extension_prefs.h" |
| 42 #include "extensions/browser/extension_registry.h" | 43 #include "extensions/browser/extension_registry.h" |
| 43 #include "extensions/browser/info_map.h" | 44 #include "extensions/browser/info_map.h" |
| 44 #include "extensions/browser/lazy_background_task_queue.h" | 45 #include "extensions/browser/lazy_background_task_queue.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 management_policy_->RegisterProvider( | 131 management_policy_->RegisterProvider( |
| 131 device_local_account_management_policy_provider_.get()); | 132 device_local_account_management_policy_provider_.get()); |
| 132 } | 133 } |
| 133 #endif // defined (OS_CHROMEOS) | 134 #endif // defined (OS_CHROMEOS) |
| 134 | 135 |
| 135 management_policy_->RegisterProvider(install_verifier_.get()); | 136 management_policy_->RegisterProvider(install_verifier_.get()); |
| 136 | 137 |
| 137 #endif // defined(ENABLE_EXTENSIONS) | 138 #endif // defined(ENABLE_EXTENSIONS) |
| 138 } | 139 } |
| 139 | 140 |
| 141 static bool VerifyExtensionContentFilter(const Extension* extension) { | |
|
Yoyo Zhou
2014/05/07 02:25:59
I'd find this clearer with a name like ShouldVerif
asargent_no_longer_on_chrome
2014/05/07 06:56:42
Good suggestion, done.
| |
| 142 return ((extension->is_extension() || extension->is_legacy_packaged_app()) && | |
| 143 ManifestURL::UpdatesFromGallery(extension) && | |
| 144 Manifest::IsAutoUpdateableLocation(extension->location())); | |
| 145 } | |
| 146 | |
| 140 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { | 147 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { |
| 141 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 148 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 142 | 149 |
| 143 navigation_observer_.reset(new NavigationObserver(profile_)); | 150 navigation_observer_.reset(new NavigationObserver(profile_)); |
| 144 | 151 |
| 145 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs); | 152 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs); |
| 146 ExtensionErrorReporter::Init(allow_noisy_errors); | 153 ExtensionErrorReporter::Init(allow_noisy_errors); |
| 147 | 154 |
| 148 user_script_master_ = new UserScriptMaster(profile_); | 155 user_script_master_ = new UserScriptMaster(profile_); |
| 149 | 156 |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 164 autoupdate_enabled, | 171 autoupdate_enabled, |
| 165 extensions_enabled, | 172 extensions_enabled, |
| 166 &ready_)); | 173 &ready_)); |
| 167 | 174 |
| 168 // These services must be registered before the ExtensionService tries to | 175 // These services must be registered before the ExtensionService tries to |
| 169 // load any extensions. | 176 // load any extensions. |
| 170 { | 177 { |
| 171 install_verifier_.reset( | 178 install_verifier_.reset( |
| 172 new InstallVerifier(ExtensionPrefs::Get(profile_), profile_)); | 179 new InstallVerifier(ExtensionPrefs::Get(profile_), profile_)); |
| 173 install_verifier_->Init(); | 180 install_verifier_->Init(); |
| 181 ContentVerifierFilter filter = base::Bind(&VerifyExtensionContentFilter); | |
| 182 content_verifier_ = new ContentVerifier(profile_, filter); | |
| 183 content_verifier_->AddObserver(this); | |
| 184 content_verifier_->Start(); | |
| 185 info_map()->SetContentVerifier(content_verifier_.get()); | |
| 174 | 186 |
| 175 management_policy_.reset(new ManagementPolicy); | 187 management_policy_.reset(new ManagementPolicy); |
| 176 RegisterManagementPolicyProviders(); | 188 RegisterManagementPolicyProviders(); |
| 177 } | 189 } |
| 178 | 190 |
| 179 bool skip_session_extensions = false; | 191 bool skip_session_extensions = false; |
| 180 #if defined(OS_CHROMEOS) | 192 #if defined(OS_CHROMEOS) |
| 181 // Skip loading session extensions if we are not in a user session. | 193 // Skip loading session extensions if we are not in a user session. |
| 182 skip_session_extensions = !chromeos::LoginState::Get()->IsUserLoggedIn(); | 194 skip_session_extensions = !chromeos::LoginState::Get()->IsUserLoggedIn(); |
| 183 if (chrome::IsRunningInForcedAppMode()) { | 195 if (chrome::IsRunningInForcedAppMode()) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 236 } | 248 } |
| 237 } | 249 } |
| 238 } | 250 } |
| 239 } | 251 } |
| 240 | 252 |
| 241 void ExtensionSystemImpl::Shared::Shutdown() { | 253 void ExtensionSystemImpl::Shared::Shutdown() { |
| 242 if (extension_warning_service_) { | 254 if (extension_warning_service_) { |
| 243 extension_warning_service_->RemoveObserver( | 255 extension_warning_service_->RemoveObserver( |
| 244 extension_warning_badge_service_.get()); | 256 extension_warning_badge_service_.get()); |
| 245 } | 257 } |
| 258 content_verifier_->RemoveObserver(this); | |
| 259 content_verifier_->Shutdown(); | |
| 246 if (extension_service_) | 260 if (extension_service_) |
| 247 extension_service_->Shutdown(); | 261 extension_service_->Shutdown(); |
| 248 } | 262 } |
| 249 | 263 |
| 264 void ExtensionSystemImpl::Shared::ContentVerifyFailed( | |
|
Yoyo Zhou
2014/05/07 02:25:59
Should ExtensionService be the observer instead?
asargent_no_longer_on_chrome
2014/05/07 06:56:42
Yeah, I think I like that better. Done.
| |
| 265 const std::string& extension_id) { | |
| 266 extension_service_->DisableExtension(extension_id, | |
| 267 Extension::DISABLE_CORRUPTED); | |
| 268 } | |
| 269 | |
| 250 StateStore* ExtensionSystemImpl::Shared::state_store() { | 270 StateStore* ExtensionSystemImpl::Shared::state_store() { |
| 251 return state_store_.get(); | 271 return state_store_.get(); |
| 252 } | 272 } |
| 253 | 273 |
| 254 StateStore* ExtensionSystemImpl::Shared::rules_store() { | 274 StateStore* ExtensionSystemImpl::Shared::rules_store() { |
| 255 return rules_store_.get(); | 275 return rules_store_.get(); |
| 256 } | 276 } |
| 257 | 277 |
| 258 ExtensionService* ExtensionSystemImpl::Shared::extension_service() { | 278 ExtensionService* ExtensionSystemImpl::Shared::extension_service() { |
| 259 return extension_service_.get(); | 279 return extension_service_.get(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 } | 319 } |
| 300 | 320 |
| 301 InstallVerifier* ExtensionSystemImpl::Shared::install_verifier() { | 321 InstallVerifier* ExtensionSystemImpl::Shared::install_verifier() { |
| 302 return install_verifier_.get(); | 322 return install_verifier_.get(); |
| 303 } | 323 } |
| 304 | 324 |
| 305 QuotaService* ExtensionSystemImpl::Shared::quota_service() { | 325 QuotaService* ExtensionSystemImpl::Shared::quota_service() { |
| 306 return quota_service_.get(); | 326 return quota_service_.get(); |
| 307 } | 327 } |
| 308 | 328 |
| 329 ContentVerifier* ExtensionSystemImpl::Shared::content_verifier() { | |
| 330 return content_verifier_.get(); | |
| 331 } | |
| 332 | |
| 309 // | 333 // |
| 310 // ExtensionSystemImpl | 334 // ExtensionSystemImpl |
| 311 // | 335 // |
| 312 | 336 |
| 313 ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile) | 337 ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile) |
| 314 : profile_(profile) { | 338 : profile_(profile) { |
| 315 shared_ = ExtensionSystemSharedFactory::GetForBrowserContext(profile); | 339 shared_ = ExtensionSystemSharedFactory::GetForBrowserContext(profile); |
| 316 | 340 |
| 317 if (profile->IsOffTheRecord()) { | 341 if (profile->IsOffTheRecord()) { |
| 318 process_manager_.reset(ProcessManager::Create(profile)); | 342 process_manager_.reset(ProcessManager::Create(profile)); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 } | 420 } |
| 397 | 421 |
| 398 InstallVerifier* ExtensionSystemImpl::install_verifier() { | 422 InstallVerifier* ExtensionSystemImpl::install_verifier() { |
| 399 return shared_->install_verifier(); | 423 return shared_->install_verifier(); |
| 400 } | 424 } |
| 401 | 425 |
| 402 QuotaService* ExtensionSystemImpl::quota_service() { | 426 QuotaService* ExtensionSystemImpl::quota_service() { |
| 403 return shared_->quota_service(); | 427 return shared_->quota_service(); |
| 404 } | 428 } |
| 405 | 429 |
| 430 ContentVerifier* ExtensionSystemImpl::content_verifier() { | |
| 431 return shared_->content_verifier(); | |
| 432 } | |
| 433 | |
| 406 void ExtensionSystemImpl::RegisterExtensionWithRequestContexts( | 434 void ExtensionSystemImpl::RegisterExtensionWithRequestContexts( |
| 407 const Extension* extension) { | 435 const Extension* extension) { |
| 408 base::Time install_time; | 436 base::Time install_time; |
| 409 if (extension->location() != Manifest::COMPONENT) { | 437 if (extension->location() != Manifest::COMPONENT) { |
| 410 install_time = ExtensionPrefs::Get(profile_)-> | 438 install_time = ExtensionPrefs::Get(profile_)-> |
| 411 GetInstallTime(extension->id()); | 439 GetInstallTime(extension->id()); |
| 412 } | 440 } |
| 413 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_); | 441 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_); |
| 414 | 442 |
| 415 bool notifications_disabled = false; | 443 bool notifications_disabled = false; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 434 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( | 462 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( |
| 435 const std::string& extension_id, | 463 const std::string& extension_id, |
| 436 const UnloadedExtensionInfo::Reason reason) { | 464 const UnloadedExtensionInfo::Reason reason) { |
| 437 BrowserThread::PostTask( | 465 BrowserThread::PostTask( |
| 438 BrowserThread::IO, | 466 BrowserThread::IO, |
| 439 FROM_HERE, | 467 FROM_HERE, |
| 440 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); | 468 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); |
| 441 } | 469 } |
| 442 | 470 |
| 443 } // namespace extensions | 471 } // namespace extensions |
| OLD | NEW |