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" |
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 "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/content_settings/cookie_settings.h" | 17 #include "chrome/browser/content_settings/cookie_settings.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/declarative_user_script_manager.h" |
20 #include "chrome/browser/extensions/error_console/error_console.h" | 20 #include "chrome/browser/extensions/error_console/error_console.h" |
21 #include "chrome/browser/extensions/extension_error_reporter.h" | 21 #include "chrome/browser/extensions/extension_error_reporter.h" |
22 #include "chrome/browser/extensions/extension_management.h" | 22 #include "chrome/browser/extensions/extension_management.h" |
23 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
24 #include "chrome/browser/extensions/extension_system_factory.h" | 24 #include "chrome/browser/extensions/extension_system_factory.h" |
25 #include "chrome/browser/extensions/extension_util.h" | 25 #include "chrome/browser/extensions/extension_util.h" |
26 #include "chrome/browser/extensions/install_verifier.h" | 26 #include "chrome/browser/extensions/install_verifier.h" |
27 #include "chrome/browser/extensions/navigation_observer.h" | 27 #include "chrome/browser/extensions/navigation_observer.h" |
28 #include "chrome/browser/extensions/shared_module_service.h" | 28 #include "chrome/browser/extensions/shared_module_service.h" |
29 #include "chrome/browser/extensions/shared_user_script_master.h" | 29 #include "chrome/browser/extensions/shared_user_script_master.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 | 295 |
296 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { | 296 void ExtensionSystemImpl::Shared::Init(bool extensions_enabled) { |
297 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 297 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
298 | 298 |
299 navigation_observer_.reset(new NavigationObserver(profile_)); | 299 navigation_observer_.reset(new NavigationObserver(profile_)); |
300 | 300 |
301 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs); | 301 bool allow_noisy_errors = !command_line->HasSwitch(switches::kNoErrorDialogs); |
302 ExtensionErrorReporter::Init(allow_noisy_errors); | 302 ExtensionErrorReporter::Init(allow_noisy_errors); |
303 | 303 |
304 shared_user_script_master_.reset(new SharedUserScriptMaster(profile_)); | 304 shared_user_script_master_.reset(new SharedUserScriptMaster(profile_)); |
| 305 declarative_user_script_manager_.reset( |
| 306 new DeclarativeUserScriptManager(profile_)); |
305 | 307 |
306 // ExtensionService depends on RuntimeData. | 308 // ExtensionService depends on RuntimeData. |
307 runtime_data_.reset(new RuntimeData(ExtensionRegistry::Get(profile_))); | 309 runtime_data_.reset(new RuntimeData(ExtensionRegistry::Get(profile_))); |
308 | 310 |
309 bool autoupdate_enabled = !profile_->IsGuestSession(); | 311 bool autoupdate_enabled = !profile_->IsGuestSession(); |
310 #if defined(OS_CHROMEOS) | 312 #if defined(OS_CHROMEOS) |
311 if (!extensions_enabled) | 313 if (!extensions_enabled) |
312 autoupdate_enabled = false; | 314 autoupdate_enabled = false; |
313 #endif | 315 #endif |
314 extension_service_.reset(new ExtensionService( | 316 extension_service_.reset(new ExtensionService( |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 426 |
425 ManagementPolicy* ExtensionSystemImpl::Shared::management_policy() { | 427 ManagementPolicy* ExtensionSystemImpl::Shared::management_policy() { |
426 return management_policy_.get(); | 428 return management_policy_.get(); |
427 } | 429 } |
428 | 430 |
429 SharedUserScriptMaster* | 431 SharedUserScriptMaster* |
430 ExtensionSystemImpl::Shared::shared_user_script_master() { | 432 ExtensionSystemImpl::Shared::shared_user_script_master() { |
431 return shared_user_script_master_.get(); | 433 return shared_user_script_master_.get(); |
432 } | 434 } |
433 | 435 |
| 436 DeclarativeUserScriptManager* |
| 437 ExtensionSystemImpl::Shared::declarative_user_script_manager() { |
| 438 return declarative_user_script_manager_.get(); |
| 439 } |
| 440 |
434 InfoMap* ExtensionSystemImpl::Shared::info_map() { | 441 InfoMap* ExtensionSystemImpl::Shared::info_map() { |
435 if (!extension_info_map_.get()) | 442 if (!extension_info_map_.get()) |
436 extension_info_map_ = new InfoMap(); | 443 extension_info_map_ = new InfoMap(); |
437 return extension_info_map_.get(); | 444 return extension_info_map_.get(); |
438 } | 445 } |
439 | 446 |
440 LazyBackgroundTaskQueue* | 447 LazyBackgroundTaskQueue* |
441 ExtensionSystemImpl::Shared::lazy_background_task_queue() { | 448 ExtensionSystemImpl::Shared::lazy_background_task_queue() { |
442 return lazy_background_task_queue_.get(); | 449 return lazy_background_task_queue_.get(); |
443 } | 450 } |
(...skipping 11 matching lines...) Expand all Loading... |
455 } | 462 } |
456 | 463 |
457 QuotaService* ExtensionSystemImpl::Shared::quota_service() { | 464 QuotaService* ExtensionSystemImpl::Shared::quota_service() { |
458 return quota_service_.get(); | 465 return quota_service_.get(); |
459 } | 466 } |
460 | 467 |
461 ContentVerifier* ExtensionSystemImpl::Shared::content_verifier() { | 468 ContentVerifier* ExtensionSystemImpl::Shared::content_verifier() { |
462 return content_verifier_.get(); | 469 return content_verifier_.get(); |
463 } | 470 } |
464 | 471 |
465 DeclarativeUserScriptMaster* | |
466 ExtensionSystemImpl::Shared::GetDeclarativeUserScriptMasterByExtension( | |
467 const ExtensionId& extension_id) { | |
468 DCHECK(ready().is_signaled()); | |
469 DeclarativeUserScriptMaster* master = NULL; | |
470 for (ScopedVector<DeclarativeUserScriptMaster>::iterator it = | |
471 declarative_user_script_masters_.begin(); | |
472 it != declarative_user_script_masters_.end(); | |
473 ++it) { | |
474 if ((*it)->extension_id() == extension_id) { | |
475 master = *it; | |
476 break; | |
477 } | |
478 } | |
479 if (!master) { | |
480 master = new DeclarativeUserScriptMaster(profile_, extension_id); | |
481 declarative_user_script_masters_.push_back(master); | |
482 } | |
483 return master; | |
484 } | |
485 | |
486 // | 472 // |
487 // ExtensionSystemImpl | 473 // ExtensionSystemImpl |
488 // | 474 // |
489 | 475 |
490 ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile) | 476 ExtensionSystemImpl::ExtensionSystemImpl(Profile* profile) |
491 : profile_(profile) { | 477 : profile_(profile) { |
492 shared_ = ExtensionSystemSharedFactory::GetForBrowserContext(profile); | 478 shared_ = ExtensionSystemSharedFactory::GetForBrowserContext(profile); |
493 | 479 |
494 if (!profile->IsOffTheRecord()) { | 480 if (!profile->IsOffTheRecord()) { |
495 shared_->InitPrefs(); | 481 shared_->InitPrefs(); |
(...skipping 25 matching lines...) Expand all Loading... |
521 } | 507 } |
522 | 508 |
523 ManagementPolicy* ExtensionSystemImpl::management_policy() { | 509 ManagementPolicy* ExtensionSystemImpl::management_policy() { |
524 return shared_->management_policy(); | 510 return shared_->management_policy(); |
525 } | 511 } |
526 | 512 |
527 SharedUserScriptMaster* ExtensionSystemImpl::shared_user_script_master() { | 513 SharedUserScriptMaster* ExtensionSystemImpl::shared_user_script_master() { |
528 return shared_->shared_user_script_master(); | 514 return shared_->shared_user_script_master(); |
529 } | 515 } |
530 | 516 |
| 517 DeclarativeUserScriptManager* |
| 518 ExtensionSystemImpl::declarative_user_script_manager() { |
| 519 return shared_->declarative_user_script_manager(); |
| 520 } |
| 521 |
531 StateStore* ExtensionSystemImpl::state_store() { | 522 StateStore* ExtensionSystemImpl::state_store() { |
532 return shared_->state_store(); | 523 return shared_->state_store(); |
533 } | 524 } |
534 | 525 |
535 StateStore* ExtensionSystemImpl::rules_store() { | 526 StateStore* ExtensionSystemImpl::rules_store() { |
536 return shared_->rules_store(); | 527 return shared_->rules_store(); |
537 } | 528 } |
538 | 529 |
539 InfoMap* ExtensionSystemImpl::info_map() { return shared_->info_map(); } | 530 InfoMap* ExtensionSystemImpl::info_map() { return shared_->info_map(); } |
540 | 531 |
(...skipping 24 matching lines...) Expand all Loading... |
565 ContentVerifier* ExtensionSystemImpl::content_verifier() { | 556 ContentVerifier* ExtensionSystemImpl::content_verifier() { |
566 return shared_->content_verifier(); | 557 return shared_->content_verifier(); |
567 } | 558 } |
568 | 559 |
569 scoped_ptr<ExtensionSet> ExtensionSystemImpl::GetDependentExtensions( | 560 scoped_ptr<ExtensionSet> ExtensionSystemImpl::GetDependentExtensions( |
570 const Extension* extension) { | 561 const Extension* extension) { |
571 return extension_service()->shared_module_service()->GetDependentExtensions( | 562 return extension_service()->shared_module_service()->GetDependentExtensions( |
572 extension); | 563 extension); |
573 } | 564 } |
574 | 565 |
575 DeclarativeUserScriptMaster* | |
576 ExtensionSystemImpl::GetDeclarativeUserScriptMasterByExtension( | |
577 const ExtensionId& extension_id) { | |
578 return shared_->GetDeclarativeUserScriptMasterByExtension(extension_id); | |
579 } | |
580 | |
581 void ExtensionSystemImpl::RegisterExtensionWithRequestContexts( | 566 void ExtensionSystemImpl::RegisterExtensionWithRequestContexts( |
582 const Extension* extension) { | 567 const Extension* extension) { |
583 base::Time install_time; | 568 base::Time install_time; |
584 if (extension->location() != Manifest::COMPONENT) { | 569 if (extension->location() != Manifest::COMPONENT) { |
585 install_time = ExtensionPrefs::Get(profile_)-> | 570 install_time = ExtensionPrefs::Get(profile_)-> |
586 GetInstallTime(extension->id()); | 571 GetInstallTime(extension->id()); |
587 } | 572 } |
588 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_); | 573 bool incognito_enabled = util::IsIncognitoEnabled(extension->id(), profile_); |
589 | 574 |
590 bool notifications_disabled = false; | 575 bool notifications_disabled = false; |
(...skipping 18 matching lines...) Expand all Loading... |
609 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( | 594 void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( |
610 const std::string& extension_id, | 595 const std::string& extension_id, |
611 const UnloadedExtensionInfo::Reason reason) { | 596 const UnloadedExtensionInfo::Reason reason) { |
612 BrowserThread::PostTask( | 597 BrowserThread::PostTask( |
613 BrowserThread::IO, | 598 BrowserThread::IO, |
614 FROM_HERE, | 599 FROM_HERE, |
615 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); | 600 base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); |
616 } | 601 } |
617 | 602 |
618 } // namespace extensions | 603 } // namespace extensions |
OLD | NEW |