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

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

Issue 6880089: Don't hold the installed app in BrowserProcessRenderHost, since that's in content layer now. Ext... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix browser tests Created 9 years, 8 months 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) 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
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
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(int renderer_child_id,
392 const Extension* app) {
393 installed_app_hosts_[renderer_child_id] = app;
394 }
395
396 const Extension* ExtensionService::GetInstalledAppForRenderer(
397 int renderer_child_id) {
398 InstalledAppMap::iterator i = installed_app_hosts_.find(renderer_child_id);
399 if (i == installed_app_hosts_.end())
400 return NULL;
401 return i->second;
402 }
403
390 // static 404 // static
391 // This function is used to implement the command-line switch 405 // This function is used to implement the command-line switch
392 // --uninstall-extension. The LOG statements within this function are used to 406 // --uninstall-extension. The LOG statements within this function are used to
393 // inform the user if the uninstall cannot be done. 407 // inform the user if the uninstall cannot be done.
394 bool ExtensionService::UninstallExtensionHelper( 408 bool ExtensionService::UninstallExtensionHelper(
395 ExtensionService* extensions_service, 409 ExtensionService* extensions_service,
396 const std::string& extension_id) { 410 const std::string& extension_id) {
397 411
398 const Extension* extension = 412 const Extension* extension =
399 extensions_service->GetExtensionById(extension_id, true); 413 extensions_service->GetExtensionById(extension_id, true);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 455
442 // Figure out if extension installation should be enabled. 456 // Figure out if extension installation should be enabled.
443 if (command_line->HasSwitch(switches::kDisableExtensions)) { 457 if (command_line->HasSwitch(switches::kDisableExtensions)) {
444 extensions_enabled_ = false; 458 extensions_enabled_ = false;
445 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { 459 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) {
446 extensions_enabled_ = false; 460 extensions_enabled_ = false;
447 } 461 }
448 462
449 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED, 463 registrar_.Add(this, NotificationType::EXTENSION_PROCESS_TERMINATED,
450 NotificationService::AllSources()); 464 NotificationService::AllSources());
465 registrar_.Add(this, NotificationType::RENDERER_PROCESS_TERMINATED,
466 NotificationService::AllSources());
451 pref_change_registrar_.Init(profile->GetPrefs()); 467 pref_change_registrar_.Init(profile->GetPrefs());
452 pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, this); 468 pref_change_registrar_.Add(prefs::kExtensionInstallAllowList, this);
453 pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, this); 469 pref_change_registrar_.Add(prefs::kExtensionInstallDenyList, this);
454 470
455 // Set up the ExtensionUpdater 471 // Set up the ExtensionUpdater
456 if (autoupdate_enabled) { 472 if (autoupdate_enabled) {
457 int update_frequency = kDefaultUpdateFrequencySeconds; 473 int update_frequency = kDefaultUpdateFrequencySeconds;
458 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) { 474 if (command_line->HasSwitch(switches::kExtensionsUpdateFrequency)) {
459 base::StringToInt(command_line->GetSwitchValueASCII( 475 base::StringToInt(command_line->GetSwitchValueASCII(
460 switches::kExtensionsUpdateFrequency), 476 switches::kExtensionsUpdateFrequency),
(...skipping 1522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 // We do it in a PostTask so that other handlers of this notification will 1999 // We do it in a PostTask so that other handlers of this notification will
1984 // still have access to the Extension and ExtensionHost. 2000 // still have access to the Extension and ExtensionHost.
1985 MessageLoop::current()->PostTask( 2001 MessageLoop::current()->PostTask(
1986 FROM_HERE, 2002 FROM_HERE,
1987 method_factory_.NewRunnableMethod( 2003 method_factory_.NewRunnableMethod(
1988 &ExtensionService::UnloadExtension, 2004 &ExtensionService::UnloadExtension,
1989 host->extension()->id(), 2005 host->extension()->id(),
1990 UnloadedExtensionInfo::DISABLE)); 2006 UnloadedExtensionInfo::DISABLE));
1991 break; 2007 break;
1992 } 2008 }
1993 2009 case NotificationType::RENDERER_PROCESS_TERMINATED: {
2010 RenderProcessHost* process = Source<RenderProcessHost>(source).ptr();
2011 installed_app_hosts_.erase(process->id());
2012 break;
2013 }
1994 case NotificationType::PREF_CHANGED: { 2014 case NotificationType::PREF_CHANGED: {
1995 std::string* pref_name = Details<std::string>(details).ptr(); 2015 std::string* pref_name = Details<std::string>(details).ptr();
1996 if (*pref_name == prefs::kExtensionInstallAllowList || 2016 if (*pref_name == prefs::kExtensionInstallAllowList ||
1997 *pref_name == prefs::kExtensionInstallDenyList) { 2017 *pref_name == prefs::kExtensionInstallDenyList) {
1998 CheckAdminBlacklist(); 2018 CheckAdminBlacklist();
1999 } else { 2019 } else {
2000 NOTREACHED() << "Unexpected preference name."; 2020 NOTREACHED() << "Unexpected preference name.";
2001 } 2021 }
2002 break; 2022 break;
2003 } 2023 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2097 2117
2098 ExtensionService::NaClModuleInfoList::iterator 2118 ExtensionService::NaClModuleInfoList::iterator
2099 ExtensionService::FindNaClModule(const GURL& url) { 2119 ExtensionService::FindNaClModule(const GURL& url) {
2100 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2120 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2101 iter != nacl_module_list_.end(); ++iter) { 2121 iter != nacl_module_list_.end(); ++iter) {
2102 if (iter->url == url) 2122 if (iter->url == url)
2103 return iter; 2123 return iter;
2104 } 2124 }
2105 return nacl_module_list_.end(); 2125 return nacl_module_list_.end();
2106 } 2126 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/isolated_app_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698