| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #include "chrome/common/extensions/extension_constants.h" | 61 #include "chrome/common/extensions/extension_constants.h" |
| 62 #include "chrome/common/extensions/extension_error_utils.h" | 62 #include "chrome/common/extensions/extension_error_utils.h" |
| 63 #include "chrome/common/extensions/extension_file_util.h" | 63 #include "chrome/common/extensions/extension_file_util.h" |
| 64 #include "chrome/common/extensions/extension_l10n_util.h" | 64 #include "chrome/common/extensions/extension_l10n_util.h" |
| 65 #include "chrome/common/extensions/extension_resource.h" | 65 #include "chrome/common/extensions/extension_resource.h" |
| 66 #include "chrome/common/pref_names.h" | 66 #include "chrome/common/pref_names.h" |
| 67 #include "chrome/common/url_constants.h" | 67 #include "chrome/common/url_constants.h" |
| 68 #include "content/browser/browser_thread.h" | 68 #include "content/browser/browser_thread.h" |
| 69 #include "content/browser/plugin_process_host.h" | 69 #include "content/browser/plugin_process_host.h" |
| 70 #include "content/browser/plugin_service.h" | 70 #include "content/browser/plugin_service.h" |
| 71 #include "content/browser/renderer_host/render_process_host.h" |
| 71 #include "content/common/json_value_serializer.h" | 72 #include "content/common/json_value_serializer.h" |
| 72 #include "content/common/notification_service.h" | 73 #include "content/common/notification_service.h" |
| 73 #include "content/common/notification_type.h" | 74 #include "content/common/notification_type.h" |
| 74 #include "content/common/pepper_plugin_registry.h" | 75 #include "content/common/pepper_plugin_registry.h" |
| 75 #include "googleurl/src/gurl.h" | 76 #include "googleurl/src/gurl.h" |
| 76 #include "net/base/registry_controlled_domain.h" | 77 #include "net/base/registry_controlled_domain.h" |
| 77 #include "webkit/database/database_tracker.h" | 78 #include "webkit/database/database_tracker.h" |
| 78 #include "webkit/database/database_util.h" | 79 #include "webkit/database/database_util.h" |
| 79 #include "webkit/plugins/npapi/plugin_list.h" | 80 #include "webkit/plugins/npapi/plugin_list.h" |
| 80 | 81 |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 if (app && app->is_app()) | 381 if (app && app->is_app()) |
| 381 return app; | 382 return app; |
| 382 | 383 |
| 383 return NULL; | 384 return NULL; |
| 384 } | 385 } |
| 385 | 386 |
| 386 bool ExtensionService::IsInstalledApp(const GURL& url) { | 387 bool ExtensionService::IsInstalledApp(const GURL& url) { |
| 387 return !!GetInstalledApp(url); | 388 return !!GetInstalledApp(url); |
| 388 } | 389 } |
| 389 | 390 |
| 391 void ExtensionService::SetInstalledAppForRenderer(const Extension* app, |
| 392 int renderer_child_id) { |
| 393 DCHECK_EQ(installed_app_hosts_.count(renderer_child_id), 0u); |
| 394 installed_app_hosts_[renderer_child_id] = app; |
| 395 } |
| 396 |
| 397 const Extension* ExtensionService::GetInstalledAppForRenderer( |
| 398 int renderer_child_id) { |
| 399 InstalledAppMap::iterator i = installed_app_hosts_.find(renderer_child_id); |
| 400 if (i == installed_app_hosts_.end()) |
| 401 return NULL; |
| 402 return i->second; |
| 403 } |
| 404 |
| 390 // static | 405 // static |
| 391 // This function is used to implement the command-line switch | 406 // This function is used to implement the command-line switch |
| 392 // --uninstall-extension. The LOG statements within this function are used to | 407 // --uninstall-extension. The LOG statements within this function are used to |
| 393 // inform the user if the uninstall cannot be done. | 408 // inform the user if the uninstall cannot be done. |
| 394 bool ExtensionService::UninstallExtensionHelper( | 409 bool ExtensionService::UninstallExtensionHelper( |
| 395 ExtensionService* extensions_service, | 410 ExtensionService* extensions_service, |
| 396 const std::string& extension_id) { | 411 const std::string& extension_id) { |
| 397 | 412 |
| 398 const Extension* extension = | 413 const Extension* extension = |
| 399 extensions_service->GetExtensionById(extension_id, true); | 414 extensions_service->GetExtensionById(extension_id, true); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 | 456 |
| 442 // Figure out if extension installation should be enabled. | 457 // Figure out if extension installation should be enabled. |
| 443 if (command_line->HasSwitch(switches::kDisableExtensions)) { | 458 if (command_line->HasSwitch(switches::kDisableExtensions)) { |
| 444 extensions_enabled_ = false; | 459 extensions_enabled_ = false; |
| 445 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { | 460 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { |
| 446 extensions_enabled_ = false; | 461 extensions_enabled_ = false; |
| 447 } | 462 } |
| 448 | 463 |
| 449 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, | 464 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, |
| 450 NotificationService::AllSources()); | 465 NotificationService::AllSources()); |
| 466 registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED, |
| 467 NotificationService::AllSources()); |
| 451 pref_change_registrar_.Init(profile->GetPrefs()); | 468 pref_change_registrar_.Init(profile->GetPrefs()); |
| 452 pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, this); | 469 pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, this); |
| 453 pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, this); | 470 pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, this); |
| 454 | 471 |
| 455 // Set up the ExtensionUpdater | 472 // Set up the ExtensionUpdater |
| 456 if (autoupdate_enabled) { | 473 if (autoupdate_enabled) { |
| 457 int update_frequency = kDefaultUpdateFrequencySeconds; | 474 int update_frequency = kDefaultUpdateFrequencySeconds; |
| 458 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { | 475 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { |
| 459 base::StringToInt(command_line->GetSwitchValueASCII( | 476 base::StringToInt(command_line->GetSwitchValueASCII( |
| 460 switches::kExtensionsUpdateFrequency), | 477 switches::kExtensionsUpdateFrequency), |
| (...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1983 // We do it in a PostTask so that other handlers of this notification will | 2000 // We do it in a PostTask so that other handlers of this notification will |
| 1984 // still have access to the Extension and ExtensionHost. | 2001 // still have access to the Extension and ExtensionHost. |
| 1985 MessageLoop::current()->PostTask( | 2002 MessageLoop::current()->PostTask( |
| 1986 FROM_HERE, | 2003 FROM_HERE, |
| 1987 method_factory_.NewRunnableMethod( | 2004 method_factory_.NewRunnableMethod( |
| 1988 &ExtensionService::UnloadExtension, | 2005 &ExtensionService::UnloadExtension, |
| 1989 host->extension()->id(), | 2006 host->extension()->id(), |
| 1990 UnloadedExtensionInfo::DISABLE)); | 2007 UnloadedExtensionInfo::DISABLE)); |
| 1991 break; | 2008 break; |
| 1992 } | 2009 } |
| 1993 | 2010 case NotificationType::RENDERER_PROCESS_TERMINATED: { |
| 2011 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr(); |
| 2012 installed_app_hosts_.erase(process->id()); |
| 2013 break; |
| 2014 } |
| 1994 case NotificationType::PREF_CHANGED: { | 2015 case NotificationType::PREF_CHANGED: { |
| 1995 std::string* pref_name = Details<std::string>(details).ptr(); | 2016 std::string* pref_name = Details<std::string>(details).ptr(); |
| 1996 if (*pref_name == prefs::kExtensionInstallAllowList || | 2017 if (*pref_name == prefs::kExtensionInstallAllowList || |
| 1997 *pref_name == prefs::kExtensionInstallDenyList) { | 2018 *pref_name == prefs::kExtensionInstallDenyList) { |
| 1998 CheckAdminBlacklist(); | 2019 CheckAdminBlacklist(); |
| 1999 } else { | 2020 } else { |
| 2000 NOTREACHED() << "Unexpected preference name."; | 2021 NOTREACHED() << "Unexpected preference name."; |
| 2001 } | 2022 } |
| 2002 break; | 2023 break; |
| 2003 } | 2024 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 | 2118 |
| 2098 ExtensionService::NaClModuleInfoList::iterator | 2119 ExtensionService::NaClModuleInfoList::iterator |
| 2099 ExtensionService::FindNaClModule(const GURL& url) { | 2120 ExtensionService::FindNaClModule(const GURL& url) { |
| 2100 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); | 2121 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); |
| 2101 iter != nacl_module_list_.end(); ++iter) { | 2122 iter != nacl_module_list_.end(); ++iter) { |
| 2102 if (iter->url == url) | 2123 if (iter->url == url) |
| 2103 return iter; | 2124 return iter; |
| 2104 } | 2125 } |
| 2105 return nacl_module_list_.end(); | 2126 return nacl_module_list_.end(); |
| 2106 } | 2127 } |
| OLD | NEW |