| 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 369 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   380                  content::NotificationService::AllBrowserContextsAndSources()); |   380                  content::NotificationService::AllBrowserContextsAndSources()); | 
|   381   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, |   381   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, | 
|   382                  content::NotificationService::AllBrowserContextsAndSources()); |   382                  content::NotificationService::AllBrowserContextsAndSources()); | 
|   383   registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, |   383   registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 
|   384                  content::NotificationService::AllBrowserContextsAndSources()); |   384                  content::NotificationService::AllBrowserContextsAndSources()); | 
|   385   registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |   385   registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 
|   386                  content::NotificationService::AllBrowserContextsAndSources()); |   386                  content::NotificationService::AllBrowserContextsAndSources()); | 
|   387   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, |   387   registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 
|   388                  content::NotificationService::AllBrowserContextsAndSources()); |   388                  content::NotificationService::AllBrowserContextsAndSources()); | 
|   389   pref_change_registrar_.Init(profile->GetPrefs()); |   389   pref_change_registrar_.Init(profile->GetPrefs()); | 
|   390   pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, this); |   390   base::Closure callback = | 
|   391   pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, this); |   391       base::Bind(&ExtensionService::OnExtensionInstallPrefChanged, | 
 |   392                  base::Unretained(this)); | 
 |   393   pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, callback); | 
 |   394   pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, callback); | 
|   392  |   395  | 
|   393   // Set up the ExtensionUpdater |   396   // Set up the ExtensionUpdater | 
|   394   if (autoupdate_enabled) { |   397   if (autoupdate_enabled) { | 
|   395     int update_frequency = kDefaultUpdateFrequencySeconds; |   398     int update_frequency = kDefaultUpdateFrequencySeconds; | 
|   396     if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { |   399     if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { | 
|   397       base::StringToInt(command_line->GetSwitchValueASCII( |   400       base::StringToInt(command_line->GetSwitchValueASCII( | 
|   398           switches::kExtensionsUpdateFrequency), |   401           switches::kExtensionsUpdateFrequency), | 
|   399           &update_frequency); |   402           &update_frequency); | 
|   400     } |   403     } | 
|   401     updater_.reset(new extensions::ExtensionUpdater(this, |   404     updater_.reset(new extensions::ExtensionUpdater(this, | 
| (...skipping 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2703         } |  2706         } | 
|  2704       } |  2707       } | 
|  2705       break; |  2708       break; | 
|  2706     } |  2709     } | 
|  2707  |  2710  | 
|  2708     default: |  2711     default: | 
|  2709       NOTREACHED() << "Unexpected notification type."; |  2712       NOTREACHED() << "Unexpected notification type."; | 
|  2710   } |  2713   } | 
|  2711 } |  2714 } | 
|  2712  |  2715  | 
|  2713 void ExtensionService::OnPreferenceChanged(PrefServiceBase* service, |  2716 void ExtensionService::OnExtensionInstallPrefChanged() { | 
|  2714                                            const std::string& pref_name) { |  | 
|  2715   DCHECK(pref_name == prefs::kExtensionInstallAllowList || |  | 
|  2716          pref_name == prefs::kExtensionInstallDenyList) |  | 
|  2717       << "Unexpected preference name " << pref_name; |  | 
|  2718   IdentifyAlertableExtensions(); |  2717   IdentifyAlertableExtensions(); | 
|  2719   CheckManagementPolicy(); |  2718   CheckManagementPolicy(); | 
|  2720 } |  2719 } | 
|  2721  |  2720  | 
|  2722 bool ExtensionService::HasApps() const { |  2721 bool ExtensionService::HasApps() const { | 
|  2723   return !GetAppIds().empty(); |  2722   return !GetAppIds().empty(); | 
|  2724 } |  2723 } | 
|  2725  |  2724  | 
|  2726 ExtensionIdSet ExtensionService::GetAppIds() const { |  2725 ExtensionIdSet ExtensionService::GetAppIds() const { | 
|  2727   ExtensionIdSet result; |  2726   ExtensionIdSet result; | 
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  2955  |  2954  | 
|  2956   // If there is no ExtensionProcessManager then assume the process is idle. |  2955   // If there is no ExtensionProcessManager then assume the process is idle. | 
|  2957   // This is commonly the case in unit-tests. |  2956   // This is commonly the case in unit-tests. | 
|  2958   if (process_manager == NULL) |  2957   if (process_manager == NULL) | 
|  2959     return true; |  2958     return true; | 
|  2960  |  2959  | 
|  2961   extensions::ExtensionHost* host = |  2960   extensions::ExtensionHost* host = | 
|  2962       process_manager->GetBackgroundHostForExtension(extension_id); |  2961       process_manager->GetBackgroundHostForExtension(extension_id); | 
|  2963   return !host; |  2962   return !host; | 
|  2964 } |  2963 } | 
| OLD | NEW |