| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 content::NotificationService::AllBrowserContextsAndSources()); | 381 content::NotificationService::AllBrowserContextsAndSources()); |
| 382 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 382 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |
| 383 content::NotificationService::AllBrowserContextsAndSources()); | 383 content::NotificationService::AllBrowserContextsAndSources()); |
| 384 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 384 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 385 content::NotificationService::AllBrowserContextsAndSources()); | 385 content::NotificationService::AllBrowserContextsAndSources()); |
| 386 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 386 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
| 387 content::NotificationService::AllBrowserContextsAndSources()); | 387 content::NotificationService::AllBrowserContextsAndSources()); |
| 388 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 388 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
| 389 content::NotificationService::AllBrowserContextsAndSources()); | 389 content::NotificationService::AllBrowserContextsAndSources()); |
| 390 pref_change_registrar_.Init(profile->GetPrefs()); | 390 pref_change_registrar_.Init(profile->GetPrefs()); |
| 391 pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, this); | 391 base::Closure callback = |
| 392 pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, this); | 392 base::Bind(&ExtensionService::OnExtensionInstallPrefChanged, |
| 393 base::Unretained(this)); |
| 394 pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, callback); |
| 395 pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, callback); |
| 393 | 396 |
| 394 // Set up the ExtensionUpdater | 397 // Set up the ExtensionUpdater |
| 395 if (autoupdate_enabled) { | 398 if (autoupdate_enabled) { |
| 396 int update_frequency = kDefaultUpdateFrequencySeconds; | 399 int update_frequency = kDefaultUpdateFrequencySeconds; |
| 397 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { | 400 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { |
| 398 base::StringToInt(command_line->GetSwitchValueASCII( | 401 base::StringToInt(command_line->GetSwitchValueASCII( |
| 399 switches::kExtensionsUpdateFrequency), | 402 switches::kExtensionsUpdateFrequency), |
| 400 &update_frequency); | 403 &update_frequency); |
| 401 } | 404 } |
| 402 updater_.reset(new extensions::ExtensionUpdater(this, | 405 updater_.reset(new extensions::ExtensionUpdater(this, |
| (...skipping 2303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2706 } | 2709 } |
| 2707 } | 2710 } |
| 2708 break; | 2711 break; |
| 2709 } | 2712 } |
| 2710 | 2713 |
| 2711 default: | 2714 default: |
| 2712 NOTREACHED() << "Unexpected notification type."; | 2715 NOTREACHED() << "Unexpected notification type."; |
| 2713 } | 2716 } |
| 2714 } | 2717 } |
| 2715 | 2718 |
| 2716 void ExtensionService::OnPreferenceChanged(PrefServiceBase* service, | 2719 void ExtensionService::OnExtensionInstallPrefChanged() { |
| 2717 const std::string& pref_name) { | |
| 2718 DCHECK(pref_name == prefs::kExtensionInstallAllowList || | |
| 2719 pref_name == prefs::kExtensionInstallDenyList) | |
| 2720 << "Unexpected preference name " << pref_name; | |
| 2721 IdentifyAlertableExtensions(); | 2720 IdentifyAlertableExtensions(); |
| 2722 CheckManagementPolicy(); | 2721 CheckManagementPolicy(); |
| 2723 } | 2722 } |
| 2724 | 2723 |
| 2725 bool ExtensionService::HasApps() const { | 2724 bool ExtensionService::HasApps() const { |
| 2726 return !GetAppIds().empty(); | 2725 return !GetAppIds().empty(); |
| 2727 } | 2726 } |
| 2728 | 2727 |
| 2729 ExtensionIdSet ExtensionService::GetAppIds() const { | 2728 ExtensionIdSet ExtensionService::GetAppIds() const { |
| 2730 ExtensionIdSet result; | 2729 ExtensionIdSet result; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2952 | 2951 |
| 2953 return true; | 2952 return true; |
| 2954 } | 2953 } |
| 2955 | 2954 |
| 2956 bool ExtensionService::IsExtensionIdle(const std::string& extension_id) const { | 2955 bool ExtensionService::IsExtensionIdle(const std::string& extension_id) const { |
| 2957 ExtensionProcessManager* pm = system_->process_manager(); | 2956 ExtensionProcessManager* pm = system_->process_manager(); |
| 2958 extensions::ExtensionHost* host = | 2957 extensions::ExtensionHost* host = |
| 2959 pm->GetBackgroundHostForExtension(extension_id); | 2958 pm->GetBackgroundHostForExtension(extension_id); |
| 2960 return !host; | 2959 return !host; |
| 2961 } | 2960 } |
| OLD | NEW |