Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: chrome/browser/extensions/extension_system_impl.cc

Issue 420543002: Declarative content scripts: Browser-side: per-extension shared memory regions (lazily loaded) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing changes to extension systems Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/metrics/field_trial.h" 12 #include "base/metrics/field_trial.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/strings/string_tokenizer.h" 14 #include "base/strings/string_tokenizer.h"
15 #include "chrome/browser/browser_process.h" 15 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/content_settings/cookie_settings.h" 16 #include "chrome/browser/content_settings/cookie_settings.h"
17 #include "chrome/browser/extensions/blacklist.h" 17 #include "chrome/browser/extensions/blacklist.h"
18 #include "chrome/browser/extensions/component_loader.h" 18 #include "chrome/browser/extensions/component_loader.h"
19 #include "chrome/browser/extensions/declarative_user_script_master.h"
19 #include "chrome/browser/extensions/error_console/error_console.h" 20 #include "chrome/browser/extensions/error_console/error_console.h"
20 #include "chrome/browser/extensions/extension_error_reporter.h" 21 #include "chrome/browser/extensions/extension_error_reporter.h"
21 #include "chrome/browser/extensions/extension_service.h" 22 #include "chrome/browser/extensions/extension_service.h"
22 #include "chrome/browser/extensions/extension_system_factory.h" 23 #include "chrome/browser/extensions/extension_system_factory.h"
23 #include "chrome/browser/extensions/extension_util.h" 24 #include "chrome/browser/extensions/extension_util.h"
24 #include "chrome/browser/extensions/extension_warning_badge_service.h" 25 #include "chrome/browser/extensions/extension_warning_badge_service.h"
25 #include "chrome/browser/extensions/extension_warning_set.h" 26 #include "chrome/browser/extensions/extension_warning_set.h"
26 #include "chrome/browser/extensions/install_verifier.h" 27 #include "chrome/browser/extensions/install_verifier.h"
27 #include "chrome/browser/extensions/navigation_observer.h" 28 #include "chrome/browser/extensions/navigation_observer.h"
28 #include "chrome/browser/extensions/shared_module_service.h" 29 #include "chrome/browser/extensions/shared_module_service.h"
29 #include "chrome/browser/extensions/standard_management_policy_provider.h" 30 #include "chrome/browser/extensions/standard_management_policy_provider.h"
30 #include "chrome/browser/extensions/updater/manifest_fetch_data.h" 31 #include "chrome/browser/extensions/updater/manifest_fetch_data.h"
31 #include "chrome/browser/extensions/user_script_master.h" 32 #include "chrome/browser/extensions/user_script_master_manager.h"
32 #include "chrome/browser/profiles/profile.h" 33 #include "chrome/browser/profiles/profile.h"
33 #include "chrome/browser/profiles/profile_manager.h" 34 #include "chrome/browser/profiles/profile_manager.h"
34 #include "chrome/common/chrome_switches.h" 35 #include "chrome/common/chrome_switches.h"
35 #include "chrome/common/chrome_version_info.h" 36 #include "chrome/common/chrome_version_info.h"
36 #include "chrome/common/extensions/extension_constants.h" 37 #include "chrome/common/extensions/extension_constants.h"
37 #include "chrome/common/extensions/extension_file_util.h" 38 #include "chrome/common/extensions/extension_file_util.h"
38 #include "chrome/common/extensions/features/feature_channel.h" 39 #include "chrome/common/extensions/features/feature_channel.h"
39 #include "chrome/common/extensions/manifest_url_handler.h" 40 #include "chrome/common/extensions/manifest_url_handler.h"
40 #include "content/public/browser/browser_thread.h" 41 #include "content/public/browser/browser_thread.h"
41 #include "content/public/browser/url_data_source.h" 42 #include "content/public/browser/url_data_source.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 } // namespace 307 } // namespace
307 308
308 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { 309 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) {
309 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 310 const CommandLine* command_line = CommandLine::ForCurrentProcess();
310 311
311 navigation_observer_.reset(new NavigationObserver(profile_)); 312 navigation_observer_.reset(new NavigationObserver(profile_));
312 313
313 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs); 314 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs);
314 ExtensionErrorReporter::Init(allow_noisy_errors); 315 ExtensionErrorReporter::Init(allow_noisy_errors);
315 316
316 user_script_master_.reset(new UserScriptMaster(profile_)); 317 user_script_master_manager_.reset(new UserScriptMasterManager(profile_));
317 318
318 // ExtensionService depends on RuntimeData. 319 // ExtensionService depends on RuntimeData.
319 runtime_data_.reset(new RuntimeData(ExtensionRegistry::Get(profile_))); 320 runtime_data_.reset(new RuntimeData(ExtensionRegistry::Get(profile_)));
320 321
321 bool autoupdate_enabled = !profile_->IsGuestSession(); 322 bool autoupdate_enabled = !profile_->IsGuestSession();
322 #if defined(OS_CHROMEOS) 323 #if defined(OS_CHROMEOS)
323 if (!extensions_enabled) 324 if (!extensions_enabled)
324 autoupdate_enabled = false; 325 autoupdate_enabled = false;
325 #endif 326 #endif
326 extension_service_.reset(new ExtensionService( 327 extension_service_.reset(new ExtensionService(
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 448
448 RuntimeData* ExtensionSystemImpl::Shared::runtime_data() { 449 RuntimeData* ExtensionSystemImpl::Shared::runtime_data() {
449 return runtime_data_.get(); 450 return runtime_data_.get();
450 } 451 }
451 452
452 ManagementPolicy* ExtensionSystemImpl::Shared::management_policy() { 453 ManagementPolicy* ExtensionSystemImpl::Shared::management_policy() {
453 return management_policy_.get(); 454 return management_policy_.get();
454 } 455 }
455 456
456 UserScriptMaster* ExtensionSystemImpl::Shared::user_script_master() { 457 UserScriptMaster* ExtensionSystemImpl::Shared::user_script_master() {
457 return user_script_master_.get(); 458 return user_script_master_manager_.get()
459 ? user_script_master_manager_->shared_master()
460 : NULL;
458 } 461 }
459 462
460 InfoMap* ExtensionSystemImpl::Shared::info_map() { 463 InfoMap* ExtensionSystemImpl::Shared::info_map() {
461 if (!extension_info_map_.get()) 464 if (!extension_info_map_.get())
462 extension_info_map_ = new InfoMap(); 465 extension_info_map_ = new InfoMap();
463 return extension_info_map_.get(); 466 return extension_info_map_.get();
464 } 467 }
465 468
466 LazyBackgroundTaskQueue* 469 LazyBackgroundTaskQueue*
467 ExtensionSystemImpl::Shared::lazy_background_task_queue() { 470 ExtensionSystemImpl::Shared::lazy_background_task_queue() {
(...skipping 21 matching lines...) Expand all
489 } 492 }
490 493
491 QuotaService* ExtensionSystemImpl::Shared::quota_service() { 494 QuotaService* ExtensionSystemImpl::Shared::quota_service() {
492 return quota_service_.get(); 495 return quota_service_.get();
493 } 496 }
494 497
495 ContentVerifier* ExtensionSystemImpl::Shared::content_verifier() { 498 ContentVerifier* ExtensionSystemImpl::Shared::content_verifier() {
496 return content_verifier_.get(); 499 return content_verifier_.get();
497 } 500 }
498 501
502 DeclarativeUserScriptMaster*
503 ExtensionSystemImpl::Shared::GetDeclarativeUserScriptMasterByExtension(
504 const ExtensionId& extension_id) {
505 return user_script_master_manager_.get()
506 ? user_script_master_manager_->GetDeclarativeMasterByExtension(
507 extension_id)
508 : NULL;
509 }
510
499 // 511 //
500 // ExtensionSystemImpl 512 // ExtensionSystemImpl
501 // 513 //
502 514
503 ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile) 515 ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile)
504 : profile_(profile) { 516 : profile_(profile) {
505 shared_ = ExtensionSystemSharedFactory::GetForBrowserContext(profile); 517 shared_ = ExtensionSystemSharedFactory::GetForBrowserContext(profile);
506 518
507 if (profile->IsOffTheRecord()) { 519 if (profile->IsOffTheRecord()) {
508 process_manager_.reset(ProcessManager::Create(profile)); 520 process_manager_.reset(ProcessManager::Create(profile));
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 ContentVerifier* ExtensionSystemImpl::content_verifier() { 608 ContentVerifier* ExtensionSystemImpl::content_verifier() {
597 return shared_->content_verifier(); 609 return shared_->content_verifier();
598 } 610 }
599 611
600 scoped_ptr<ExtensionSet> ExtensionSystemImpl::GetDependentExtensions( 612 scoped_ptr<ExtensionSet> ExtensionSystemImpl::GetDependentExtensions(
601 const Extension* extension) { 613 const Extension* extension) {
602 return extension_service()->shared_module_service()->GetDependentExtensions( 614 return extension_service()->shared_module_service()->GetDependentExtensions(
603 extension); 615 extension);
604 } 616 }
605 617
618 DeclarativeUserScriptMaster*
619 ExtensionSystemImpl::GetDeclarativeUserScriptMasterByExtension(
620 const ExtensionId& extension_id) {
621 return shared_->GetDeclarativeUserScriptMasterByExtension(extension_id);
622 }
623
606 void ExtensionSystemImpl::RegisterExtensionWithRequestContexts( 624 void ExtensionSystemImpl::RegisterExtensionWithRequestContexts(
607 const Extension* extension) { 625 const Extension* extension) {
608 base::Time install_time; 626 base::Time install_time;
609 if (extension->location() != Manifest::COMPONENT) { 627 if (extension->location() != Manifest::COMPONENT) {
610 install_time = ExtensionPrefs::Get(profile_)-> 628 install_time = ExtensionPrefs::Get(profile_)->
611 GetInstallTime(extension->id()); 629 GetInstallTime(extension->id());
612 } 630 }
613 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_); 631 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_);
614 632
615 bool notifications_disabled = false; 633 bool notifications_disabled = false;
(...skipping 18 matching lines...) Expand all
634 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( 652 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts(
635 const std::string& extension_id, 653 const std::string& extension_id,
636 const UnloadedExtensionInfo::Reason reason) { 654 const UnloadedExtensionInfo::Reason reason) {
637 BrowserThread::PostTask( 655 BrowserThread::PostTask(
638 BrowserThread::IO, 656 BrowserThread::IO,
639 FROM_HERE, 657 FROM_HERE,
640 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); 658 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason));
641 } 659 }
642 660
643 } // namespace extensions 661 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698