OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 const Extension* extension = blacklisted_extensions_.GetByID(lowercase_id); | 501 const Extension* extension = blacklisted_extensions_.GetByID(lowercase_id); |
502 if (extension) | 502 if (extension) |
503 return extension; | 503 return extension; |
504 } | 504 } |
505 return NULL; | 505 return NULL; |
506 } | 506 } |
507 | 507 |
508 void ExtensionService::Init() { | 508 void ExtensionService::Init() { |
509 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 509 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
510 | 510 |
| 511 base::Time begin_time = base::Time::Now(); |
| 512 |
511 DCHECK(!is_ready()); // Can't redo init. | 513 DCHECK(!is_ready()); // Can't redo init. |
512 DCHECK_EQ(extensions_.size(), 0u); | 514 DCHECK_EQ(extensions_.size(), 0u); |
513 | 515 |
514 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 516 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
515 if (cmd_line->HasSwitch(switches::kInstallFromWebstore) || | 517 if (cmd_line->HasSwitch(switches::kInstallFromWebstore) || |
516 cmd_line->HasSwitch(switches::kLimitedInstallFromWebstore)) { | 518 cmd_line->HasSwitch(switches::kLimitedInstallFromWebstore)) { |
517 // The sole purpose of this launch is to install a new extension from CWS | 519 // The sole purpose of this launch is to install a new extension from CWS |
518 // and immediately terminate: loading already installed extensions is | 520 // and immediately terminate: loading already installed extensions is |
519 // unnecessary and may interfere with the inline install dialog (e.g. if an | 521 // unnecessary and may interfere with the inline install dialog (e.g. if an |
520 // extension listens to onStartup and opens a window). | 522 // extension listens to onStartup and opens a window). |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 base::Bind(&ExtensionService::GarbageCollectExtensions, AsWeakPtr()), | 582 base::Bind(&ExtensionService::GarbageCollectExtensions, AsWeakPtr()), |
581 base::TimeDelta::FromSeconds(kGarbageCollectStartupDelay)); | 583 base::TimeDelta::FromSeconds(kGarbageCollectStartupDelay)); |
582 | 584 |
583 if (extension_prefs_->NeedsStorageGarbageCollection()) { | 585 if (extension_prefs_->NeedsStorageGarbageCollection()) { |
584 GarbageCollectIsolatedStorage(); | 586 GarbageCollectIsolatedStorage(); |
585 extension_prefs_->SetNeedsStorageGarbageCollection(false); | 587 extension_prefs_->SetNeedsStorageGarbageCollection(false); |
586 } | 588 } |
587 system_->management_policy()->RegisterProvider( | 589 system_->management_policy()->RegisterProvider( |
588 shared_module_policy_provider_.get()); | 590 shared_module_policy_provider_.get()); |
589 } | 591 } |
| 592 |
| 593 UMA_HISTOGRAM_TIMES("Extensions.ExtensionServiceInitTime", |
| 594 base::Time::Now() - begin_time); |
590 } | 595 } |
591 | 596 |
592 bool ExtensionService::UpdateExtension(const std::string& id, | 597 bool ExtensionService::UpdateExtension(const std::string& id, |
593 const base::FilePath& extension_path, | 598 const base::FilePath& extension_path, |
594 const GURL& download_url, | 599 const GURL& download_url, |
595 CrxInstaller** out_crx_installer) { | 600 CrxInstaller** out_crx_installer) { |
596 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 601 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
597 if (browser_terminating_) { | 602 if (browser_terminating_) { |
598 LOG(WARNING) << "Skipping UpdateExtension due to browser shutdown"; | 603 LOG(WARNING) << "Skipping UpdateExtension due to browser shutdown"; |
599 // Leak the temp file at extension_path. We don't want to add to the disk | 604 // Leak the temp file at extension_path. We don't want to add to the disk |
(...skipping 2214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2814 } | 2819 } |
2815 | 2820 |
2816 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { | 2821 void ExtensionService::AddUpdateObserver(extensions::UpdateObserver* observer) { |
2817 update_observers_.AddObserver(observer); | 2822 update_observers_.AddObserver(observer); |
2818 } | 2823 } |
2819 | 2824 |
2820 void ExtensionService::RemoveUpdateObserver( | 2825 void ExtensionService::RemoveUpdateObserver( |
2821 extensions::UpdateObserver* observer) { | 2826 extensions::UpdateObserver* observer) { |
2822 update_observers_.RemoveObserver(observer); | 2827 update_observers_.RemoveObserver(observer); |
2823 } | 2828 } |
OLD | NEW |