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

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

Issue 5168004: Revert 66646 - Add "open as window" menu item to NTP app menu.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/extensions_service.h" 5 #include "chrome/browser/extensions/extensions_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 ExtensionsService::ExtensionsService(Profile* profile, 531 ExtensionsService::ExtensionsService(Profile* profile,
532 const CommandLine* command_line, 532 const CommandLine* command_line,
533 const FilePath& install_directory, 533 const FilePath& install_directory,
534 bool autoupdate_enabled) 534 bool autoupdate_enabled)
535 : profile_(profile), 535 : profile_(profile),
536 extension_prefs_(new ExtensionPrefs(profile->GetPrefs(), 536 extension_prefs_(new ExtensionPrefs(profile->GetPrefs(),
537 install_directory)), 537 install_directory)),
538 install_directory_(install_directory), 538 install_directory_(install_directory),
539 extensions_enabled_(true), 539 extensions_enabled_(true),
540 show_extensions_prompts_(true), 540 show_extensions_prompts_(true),
541 init_done_(false), 541 ready_(false),
542 ALLOW_THIS_IN_INITIALIZER_LIST(toolbar_model_(this)), 542 ALLOW_THIS_IN_INITIALIZER_LIST(toolbar_model_(this)),
543 default_apps_(profile->GetPrefs()), 543 default_apps_(profile->GetPrefs()),
544 event_routers_initialized_(false) { 544 event_routers_initialized_(false) {
545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
546 546
547 // Figure out if extension installation should be enabled. 547 // Figure out if extension installation should be enabled.
548 if (command_line->HasSwitch(switches::kDisableExtensions)) { 548 if (command_line->HasSwitch(switches::kDisableExtensions)) {
549 extensions_enabled_ = false; 549 extensions_enabled_ = false;
550 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { 550 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) {
551 extensions_enabled_ = false; 551 extensions_enabled_ = false;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 ExtensionCookiesEventRouter::GetInstance()->Init(); 601 ExtensionCookiesEventRouter::GetInstance()->Init();
602 ExtensionManagementEventRouter::GetInstance()->Init(); 602 ExtensionManagementEventRouter::GetInstance()->Init();
603 ExtensionProcessesEventRouter::GetInstance()->ObserveProfile(profile_); 603 ExtensionProcessesEventRouter::GetInstance()->ObserveProfile(profile_);
604 ExtensionWebNavigationEventRouter::GetInstance()->Init(); 604 ExtensionWebNavigationEventRouter::GetInstance()->Init();
605 event_routers_initialized_ = true; 605 event_routers_initialized_ = true;
606 } 606 }
607 607
608 void ExtensionsService::Init() { 608 void ExtensionsService::Init() {
609 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 609 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
610 610
611 DCHECK(!init_done_); // Can't redo init. 611 DCHECK(!ready_);
612 DCHECK_EQ(extensions_.size(), 0u); 612 DCHECK_EQ(extensions_.size(), 0u);
613 613
614 // Hack: we need to ensure the ResourceDispatcherHost is ready before we load 614 // Hack: we need to ensure the ResourceDispatcherHost is ready before we load
615 // the first extension, because its members listen for loaded notifications. 615 // the first extension, because its members listen for loaded notifications.
616 g_browser_process->resource_dispatcher_host(); 616 g_browser_process->resource_dispatcher_host();
617 617
618 LoadAllExtensions(); 618 LoadAllExtensions();
619 619
620 // TODO(erikkay) this should probably be deferred to a future point 620 // TODO(erikkay) this should probably be deferred to a future point
621 // rather than running immediately at startup. 621 // rather than running immediately at startup.
622 CheckForExternalUpdates(); 622 CheckForExternalUpdates();
623 623
624 // TODO(erikkay) this should probably be deferred as well. 624 // TODO(erikkay) this should probably be deferred as well.
625 GarbageCollectExtensions(); 625 GarbageCollectExtensions();
626
627 init_done_ = true;
628 } 626 }
629 627
630 void ExtensionsService::InstallExtension(const FilePath& extension_path) { 628 void ExtensionsService::InstallExtension(const FilePath& extension_path) {
631 scoped_refptr<CrxInstaller> installer( 629 scoped_refptr<CrxInstaller> installer(
632 new CrxInstaller(install_directory_, 630 new CrxInstaller(install_directory_,
633 this, // frontend 631 this, // frontend
634 NULL)); // no client (silent install) 632 NULL)); // no client (silent install)
635 installer->set_allow_privilege_increase(true); 633 installer->set_allow_privilege_increase(true);
636 installer->InstallCrx(extension_path); 634 installer->InstallCrx(extension_path);
637 } 635 }
(...skipping 830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 1466
1469 // Also garbage-collect themes. We check |profile_| to be 1467 // Also garbage-collect themes. We check |profile_| to be
1470 // defensive; in the future, we may call GarbageCollectExtensions() 1468 // defensive; in the future, we may call GarbageCollectExtensions()
1471 // from somewhere other than Init() (e.g., in a timer). 1469 // from somewhere other than Init() (e.g., in a timer).
1472 if (profile_) { 1470 if (profile_) {
1473 profile_->GetThemeProvider()->RemoveUnusedThemes(); 1471 profile_->GetThemeProvider()->RemoveUnusedThemes();
1474 } 1472 }
1475 } 1473 }
1476 1474
1477 void ExtensionsService::OnLoadedInstalledExtensions() { 1475 void ExtensionsService::OnLoadedInstalledExtensions() {
1476 ready_ = true;
1478 if (updater_.get()) { 1477 if (updater_.get()) {
1479 updater_->Start(); 1478 updater_->Start();
1480 } 1479 }
1481 NotificationService::current()->Notify( 1480 NotificationService::current()->Notify(
1482 NotificationType::EXTENSIONS_READY, 1481 NotificationType::EXTENSIONS_READY,
1483 Source<Profile>(profile_), 1482 Source<Profile>(profile_),
1484 NotificationService::NoDetails()); 1483 NotificationService::NoDetails());
1485 } 1484 }
1486 1485
1487 void ExtensionsService::OnExtensionLoaded(const Extension* extension, 1486 void ExtensionsService::OnExtensionLoaded(const Extension* extension,
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 } 1939 }
1941 1940
1942 bool ExtensionsService::IsBeingUpgraded(const Extension* extension) { 1941 bool ExtensionsService::IsBeingUpgraded(const Extension* extension) {
1943 return extension_runtime_data_[extension->id()].being_upgraded; 1942 return extension_runtime_data_[extension->id()].being_upgraded;
1944 } 1943 }
1945 1944
1946 void ExtensionsService::SetBeingUpgraded(const Extension* extension, 1945 void ExtensionsService::SetBeingUpgraded(const Extension* extension,
1947 bool value) { 1946 bool value) {
1948 extension_runtime_data_[extension->id()].being_upgraded = value; 1947 extension_runtime_data_[extension->id()].being_upgraded = value;
1949 } 1948 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extensions_service.h ('k') | chrome/browser/resources/new_new_tab.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698