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

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

Issue 9150016: Move creation and ownership of ResourceDispatcherHost and PluginService to content. This gives a ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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) 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 #include "chrome/common/chrome_switches.h" 85 #include "chrome/common/chrome_switches.h"
86 #include "chrome/common/extensions/extension.h" 86 #include "chrome/common/extensions/extension.h"
87 #include "chrome/common/extensions/extension_constants.h" 87 #include "chrome/common/extensions/extension_constants.h"
88 #include "chrome/common/extensions/extension_error_utils.h" 88 #include "chrome/common/extensions/extension_error_utils.h"
89 #include "chrome/common/extensions/extension_file_util.h" 89 #include "chrome/common/extensions/extension_file_util.h"
90 #include "chrome/common/extensions/extension_messages.h" 90 #include "chrome/common/extensions/extension_messages.h"
91 #include "chrome/common/extensions/extension_resource.h" 91 #include "chrome/common/extensions/extension_resource.h"
92 #include "chrome/common/pref_names.h" 92 #include "chrome/common/pref_names.h"
93 #include "chrome/common/url_constants.h" 93 #include "chrome/common/url_constants.h"
94 #include "content/browser/plugin_process_host.h" 94 #include "content/browser/plugin_process_host.h"
95 #include "content/browser/renderer_host/resource_dispatcher_host.h"
95 #include "content/public/browser/browser_thread.h" 96 #include "content/public/browser/browser_thread.h"
96 #include "content/public/browser/devtools_agent_host_registry.h" 97 #include "content/public/browser/devtools_agent_host_registry.h"
97 #include "content/public/browser/devtools_manager.h" 98 #include "content/public/browser/devtools_manager.h"
98 #include "content/public/browser/notification_service.h" 99 #include "content/public/browser/notification_service.h"
99 #include "content/public/browser/notification_types.h" 100 #include "content/public/browser/notification_types.h"
100 #include "content/public/browser/plugin_service.h" 101 #include "content/public/browser/plugin_service.h"
101 #include "content/public/browser/render_process_host.h" 102 #include "content/public/browser/render_process_host.h"
102 #include "content/public/common/pepper_plugin_info.h" 103 #include "content/public/common/pepper_plugin_info.h"
103 #include "googleurl/src/gurl.h" 104 #include "googleurl/src/gurl.h"
104 #include "grit/theme_resources.h" 105 #include "grit/theme_resources.h"
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 extensions_enabled_(extensions_enabled), 383 extensions_enabled_(extensions_enabled),
383 show_extensions_prompts_(true), 384 show_extensions_prompts_(true),
384 ready_(false), 385 ready_(false),
385 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), 386 toolbar_model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
386 menu_manager_(profile), 387 menu_manager_(profile),
387 app_notification_manager_(new AppNotificationManager(profile)), 388 app_notification_manager_(new AppNotificationManager(profile)),
388 apps_promo_(profile->GetPrefs()), 389 apps_promo_(profile->GetPrefs()),
389 event_routers_initialized_(false), 390 event_routers_initialized_(false),
390 extension_warnings_(profile), 391 extension_warnings_(profile),
391 socket_controller_(NULL), 392 socket_controller_(NULL),
392 tracker_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 393 tracker_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
394 use_utility_process_(true) {
393 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 395 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
394 396
395 // Figure out if extension installation should be enabled. 397 // Figure out if extension installation should be enabled.
396 if (command_line->HasSwitch(switches::kDisableExtensions)) { 398 if (command_line->HasSwitch(switches::kDisableExtensions)) {
397 extensions_enabled_ = false; 399 extensions_enabled_ = false;
398 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) { 400 } else if (profile->GetPrefs()->GetBoolean(prefs::kDisableExtensions)) {
399 extensions_enabled_ = false; 401 extensions_enabled_ = false;
400 } 402 }
401 403
402 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, 404 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED,
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 } 561 }
560 562
561 void ExtensionService::Init() { 563 void ExtensionService::Init() {
562 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 564 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
563 565
564 DCHECK(!ready_); // Can't redo init. 566 DCHECK(!ready_); // Can't redo init.
565 DCHECK_EQ(extensions_.size(), 0u); 567 DCHECK_EQ(extensions_.size(), 0u);
566 568
567 // Hack: we need to ensure the ResourceDispatcherHost is ready before we load 569 // Hack: we need to ensure the ResourceDispatcherHost is ready before we load
568 // the first extension, because its members listen for loaded notifications. 570 // the first extension, because its members listen for loaded notifications.
569 g_browser_process->resource_dispatcher_host(); 571 ResourceDispatcherHost::Get();
570 572
571 component_loader_->LoadAll(); 573 component_loader_->LoadAll();
572 extensions::InstalledLoader(this).LoadAllExtensions(); 574 extensions::InstalledLoader(this).LoadAllExtensions();
573 575
574 // If we are running in the import process, don't bother initializing the 576 // If we are running in the import process, don't bother initializing the
575 // extension service since this can interfere with the main browser process 577 // extension service since this can interfere with the main browser process
576 // that is already running an extension service for this profile. 578 // that is already running an extension service for this profile.
577 // TODO(aa): can we start up even less of ExtensionService? 579 // TODO(aa): can we start up even less of ExtensionService?
578 // http://crbug.com/107636 580 // http://crbug.com/107636
579 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kImport) && 581 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kImport) &&
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
619 return false; 621 return false;
620 } 622 }
621 623
622 // We want a silent install only for non-pending extensions and 624 // We want a silent install only for non-pending extensions and
623 // pending extensions that have install_silently set. 625 // pending extensions that have install_silently set.
624 ExtensionInstallUI* client = 626 ExtensionInstallUI* client =
625 (!is_pending_extension || pending_extension_info.install_silently()) ? 627 (!is_pending_extension || pending_extension_info.install_silently()) ?
626 NULL : new ExtensionInstallUI(profile_); 628 NULL : new ExtensionInstallUI(profile_);
627 629
628 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(this, client)); 630 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(this, client));
631 installer->set_use_utility_process(use_utility_process_);
629 installer->set_expected_id(id); 632 installer->set_expected_id(id);
630 if (is_pending_extension) 633 if (is_pending_extension)
631 installer->set_install_source(pending_extension_info.install_source()); 634 installer->set_install_source(pending_extension_info.install_source());
632 else if (extension) 635 else if (extension)
633 installer->set_install_source(extension->location()); 636 installer->set_install_source(extension->location());
634 if (pending_extension_info.install_silently()) 637 if (pending_extension_info.install_silently())
635 installer->set_allow_silent_install(true); 638 installer->set_allow_silent_install(true);
636 // If the extension came from sync and its auto-update URL is from the 639 // If the extension came from sync and its auto-update URL is from the
637 // webstore, treat it as a webstore install. Note that we ignore some older 640 // webstore, treat it as a webstore install. Note that we ignore some older
638 // extensions with blank auto-update URLs because we are mostly concerned 641 // extensions with blank auto-update URLs because we are mostly concerned
(...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 << "is: " << version->GetString() 2318 << "is: " << version->GetString()
2316 << ". Keeping current version."; 2319 << ". Keeping current version.";
2317 return; 2320 return;
2318 } 2321 }
2319 } 2322 }
2320 2323
2321 pending_extension_manager()->AddFromExternalFile(id, location); 2324 pending_extension_manager()->AddFromExternalFile(id, location);
2322 2325
2323 // no client (silent install) 2326 // no client (silent install)
2324 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(this, NULL)); 2327 scoped_refptr<CrxInstaller> installer(CrxInstaller::Create(this, NULL));
2328 installer->set_use_utility_process(use_utility_process_);
2325 installer->set_install_source(location); 2329 installer->set_install_source(location);
2326 installer->set_expected_id(id); 2330 installer->set_expected_id(id);
2327 installer->set_expected_version(*version); 2331 installer->set_expected_version(*version);
2328 installer->set_install_cause(extension_misc::INSTALL_CAUSE_EXTERNAL_FILE); 2332 installer->set_install_cause(extension_misc::INSTALL_CAUSE_EXTERNAL_FILE);
2329 installer->set_creation_flags(creation_flags); 2333 installer->set_creation_flags(creation_flags);
2330 installer->InstallCrx(path); 2334 installer->InstallCrx(path);
2331 2335
2332 // Depending on the source, a new external extension might not need a user 2336 // Depending on the source, a new external extension might not need a user
2333 // notification on installation. For such extensions, mark them acknowledged 2337 // notification on installation. For such extensions, mark them acknowledged
2334 // now to suppress the notification. 2338 // now to suppress the notification.
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2643 // 2647 //
2644 // To coexist with certain unit tests that don't have an IO thread message 2648 // To coexist with certain unit tests that don't have an IO thread message
2645 // loop available at ExtensionService shutdown, we lazy-initialize this 2649 // loop available at ExtensionService shutdown, we lazy-initialize this
2646 // object so that those cases neither create nor destroy a SocketController. 2650 // object so that those cases neither create nor destroy a SocketController.
2647 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 2651 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
2648 if (!socket_controller_) { 2652 if (!socket_controller_) {
2649 socket_controller_ = new extensions::SocketController(); 2653 socket_controller_ = new extensions::SocketController();
2650 } 2654 }
2651 return socket_controller_; 2655 return socket_controller_;
2652 } 2656 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698