| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_util.h" | 5 #include "chrome/browser/extensions/extension_util.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 248 } |
| 249 | 249 |
| 250 bool ShouldSyncApp(const Extension* app, content::BrowserContext* context) { | 250 bool ShouldSyncApp(const Extension* app, content::BrowserContext* context) { |
| 251 return sync_helper::IsSyncableApp(app) && | 251 return sync_helper::IsSyncableApp(app) && |
| 252 !util::IsEphemeralApp(app->id(), context) && | 252 !util::IsEphemeralApp(app->id(), context) && |
| 253 !ExtensionPrefs::Get(context)->DoNotSync(app->id()); | 253 !ExtensionPrefs::Get(context)->DoNotSync(app->id()); |
| 254 } | 254 } |
| 255 | 255 |
| 256 bool IsExtensionIdle(const std::string& extension_id, | 256 bool IsExtensionIdle(const std::string& extension_id, |
| 257 content::BrowserContext* context) { | 257 content::BrowserContext* context) { |
| 258 ProcessManager* process_manager = | |
| 259 ExtensionSystem::Get(context)->process_manager(); | |
| 260 DCHECK(process_manager); | |
| 261 | |
| 262 std::vector<std::string> ids_to_check; | 258 std::vector<std::string> ids_to_check; |
| 263 ids_to_check.push_back(extension_id); | 259 ids_to_check.push_back(extension_id); |
| 264 | 260 |
| 265 const Extension* extension = | 261 const Extension* extension = |
| 266 ExtensionRegistry::Get(context) | 262 ExtensionRegistry::Get(context) |
| 267 ->GetExtensionById(extension_id, ExtensionRegistry::ENABLED); | 263 ->GetExtensionById(extension_id, ExtensionRegistry::ENABLED); |
| 268 if (extension && extension->is_shared_module()) { | 264 if (extension && extension->is_shared_module()) { |
| 269 // We have to check all the extensions that use this shared module for idle | 265 // We have to check all the extensions that use this shared module for idle |
| 270 // to tell whether it is really 'idle'. | 266 // to tell whether it is really 'idle'. |
| 271 SharedModuleService* service = ExtensionSystem::Get(context) | 267 SharedModuleService* service = ExtensionSystem::Get(context) |
| 272 ->extension_service() | 268 ->extension_service() |
| 273 ->shared_module_service(); | 269 ->shared_module_service(); |
| 274 scoped_ptr<ExtensionSet> dependents = | 270 scoped_ptr<ExtensionSet> dependents = |
| 275 service->GetDependentExtensions(extension); | 271 service->GetDependentExtensions(extension); |
| 276 for (ExtensionSet::const_iterator i = dependents->begin(); | 272 for (ExtensionSet::const_iterator i = dependents->begin(); |
| 277 i != dependents->end(); | 273 i != dependents->end(); |
| 278 i++) { | 274 i++) { |
| 279 ids_to_check.push_back((*i)->id()); | 275 ids_to_check.push_back((*i)->id()); |
| 280 } | 276 } |
| 281 } | 277 } |
| 282 | 278 |
| 279 ProcessManager* process_manager = ProcessManager::Get(context); |
| 283 for (std::vector<std::string>::const_iterator i = ids_to_check.begin(); | 280 for (std::vector<std::string>::const_iterator i = ids_to_check.begin(); |
| 284 i != ids_to_check.end(); | 281 i != ids_to_check.end(); |
| 285 i++) { | 282 i++) { |
| 286 const std::string id = (*i); | 283 const std::string id = (*i); |
| 287 ExtensionHost* host = process_manager->GetBackgroundHostForExtension(id); | 284 ExtensionHost* host = process_manager->GetBackgroundHostForExtension(id); |
| 288 if (host) | 285 if (host) |
| 289 return false; | 286 return false; |
| 290 | 287 |
| 291 content::SiteInstance* site_instance = | 288 content::SiteInstance* site_instance = |
| 292 process_manager->GetSiteInstanceForURL( | 289 process_manager->GetSiteInstanceForURL( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 IDR_EXTENSION_DEFAULT_ICON); | 359 IDR_EXTENSION_DEFAULT_ICON); |
| 363 } | 360 } |
| 364 | 361 |
| 365 bool IsStreamlinedHostedAppsEnabled() { | 362 bool IsStreamlinedHostedAppsEnabled() { |
| 366 return CommandLine::ForCurrentProcess()->HasSwitch( | 363 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 367 switches::kEnableStreamlinedHostedApps); | 364 switches::kEnableStreamlinedHostedApps); |
| 368 } | 365 } |
| 369 | 366 |
| 370 } // namespace util | 367 } // namespace util |
| 371 } // namespace extensions | 368 } // namespace extensions |
| OLD | NEW |