15f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved.
25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file.
45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
55f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "extensions/shell/browser/shell_extensions_browser_client.h"
65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/prefs/pref_service.h"
85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/prefs/pref_service_factory.h"
95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/prefs/testing_pref_store.h"
10cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)#include "components/pref_registry/pref_registry_syncable.h"
115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "components/user_prefs/user_prefs.h"
121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "content/public/browser/browser_thread.h"
131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/browser/api/extensions_api_client.h"
141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/browser/api/generated_api_registration.h"
155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "extensions/browser/app_sorting.h"
161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/browser/event_router.h"
17c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch#include "extensions/browser/extension_function_registry.h"
185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "extensions/browser/extension_prefs.h"
191320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/browser/null_app_sorting.h"
201320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci#include "extensions/browser/url_request_util.h"
2103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "extensions/shell/browser/shell_extension_host_delegate.h"
225f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "extensions/shell/browser/shell_extension_system_factory.h"
235f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)#include "extensions/shell/browser/shell_runtime_api_delegate.h"
245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)using content::BrowserContext;
261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucciusing content::BrowserThread;
275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace extensions {
295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)namespace {
305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// See chrome::RegisterProfilePrefs() in chrome/browser/prefs/browser_prefs.cc
325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) {
335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  ExtensionPrefs::RegisterProfilePrefs(registry);
345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace
375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ShellExtensionsBrowserClient::ShellExtensionsBrowserClient(
395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    BrowserContext* context)
401320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    : browser_context_(context), api_client_(new ExtensionsAPIClient) {
415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Set up the preferences service.
425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  base::PrefServiceFactory factory;
435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  factory.set_user_prefs(new TestingPrefStore);
445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  factory.set_extension_prefs(new TestingPrefStore);
455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // app_shell should not require syncable preferences, but for now we need to
465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // recycle some of the RegisterProfilePrefs() code in Chrome.
475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(jamescook): Convert this to PrefRegistrySimple.
485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_prefs::PrefRegistrySyncable* pref_registry =
495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)      new user_prefs::PrefRegistrySyncable;
505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // Prefs should be registered before the PrefService is created.
515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  RegisterPrefs(pref_registry);
525d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  prefs_ = factory.Create(pref_registry).Pass();
535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  user_prefs::UserPrefs::Set(browser_context_, prefs_.get());
545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
565f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)ShellExtensionsBrowserClient::~ShellExtensionsBrowserClient() {
575f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}
585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ShellExtensionsBrowserClient::IsShuttingDown() {
605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return false;
615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
625d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
635d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ShellExtensionsBrowserClient::AreExtensionsDisabled(
64a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    const base::CommandLine& command_line,
655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    BrowserContext* context) {
665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return false;
675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ShellExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return context == browser_context_;
715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ShellExtensionsBrowserClient::IsSameContext(BrowserContext* first,
745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)                                                 BrowserContext* second) {
755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return first == second;
765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ShellExtensionsBrowserClient::HasOffTheRecordContext(
795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    BrowserContext* context) {
805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return false;
815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
835d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)BrowserContext* ShellExtensionsBrowserClient::GetOffTheRecordContext(
845d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    BrowserContext* context) {
855d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // app_shell only supports a single context.
865d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return NULL;
875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
885d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
895d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)BrowserContext* ShellExtensionsBrowserClient::GetOriginalContext(
905d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    BrowserContext* context) {
915d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return context;
925d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
935d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
94a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)bool ShellExtensionsBrowserClient::IsGuestSession(
95a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    BrowserContext* context) const {
965d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return false;
975d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
985d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
995d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ShellExtensionsBrowserClient::IsExtensionIncognitoEnabled(
1005d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    const std::string& extension_id,
1015d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    content::BrowserContext* context) const {
1025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return false;
1035d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1045d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1055d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ShellExtensionsBrowserClient::CanExtensionCrossIncognito(
1065f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    const Extension* extension,
1075d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    content::BrowserContext* context) const {
1085d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return false;
1095d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
111a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochnet::URLRequestJob*
112a02191e04bc25c4935f804f2c080ae28663d096dBen MurdochShellExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob(
113a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    net::URLRequest* request,
114a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    net::NetworkDelegate* network_delegate,
115a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    const base::FilePath& directory_path,
116a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    const std::string& content_security_policy,
117a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    bool send_cors_header) {
118a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  return NULL;
119a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch}
120a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
121a02191e04bc25c4935f804f2c080ae28663d096dBen Murdochbool ShellExtensionsBrowserClient::AllowCrossRendererResourceLoad(
122a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    net::URLRequest* request,
123a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    bool is_incognito,
124a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    const Extension* extension,
125a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch    InfoMap* extension_info_map) {
1261320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  bool allowed = false;
1271320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  if (url_request_util::AllowCrossRendererResourceLoad(
1281320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci          request, is_incognito, extension, extension_info_map, &allowed)) {
1291320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    return allowed;
1301320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  }
1311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
1321320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  // Couldn't determine if resource is allowed. Block the load.
133a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch  return false;
134a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch}
135a02191e04bc25c4935f804f2c080ae28663d096dBen Murdoch
1365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)PrefService* ShellExtensionsBrowserClient::GetPrefServiceForContext(
1375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    BrowserContext* context) {
1385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return prefs_.get();
1395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
141e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdochvoid ShellExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
142e5d81f57cb97b3b6b7fccc9c5610d21eb81db09dBen Murdoch    content::BrowserContext* context,
1435f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)    std::vector<ExtensionPrefsObserver*>* observers) const {
1445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1465f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)ProcessManagerDelegate*
1475f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)ShellExtensionsBrowserClient::GetProcessManagerDelegate() const {
1485f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  return NULL;
1495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
15123730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)scoped_ptr<ExtensionHostDelegate>
15223730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)ShellExtensionsBrowserClient::CreateExtensionHostDelegate() {
15323730a6e56a168d1879203e4b3819bb36e3d8f1fTorne (Richard Coles)  return scoped_ptr<ExtensionHostDelegate>(new ShellExtensionHostDelegate);
1545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1555d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1565d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ShellExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
1575d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // TODO(jamescook): We might want to tell extensions when app_shell updates.
1585d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return false;
1595d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1605d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1615f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)void ShellExtensionsBrowserClient::PermitExternalProtocolHandler() {
1625f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}
1635f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
1645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)scoped_ptr<AppSorting> ShellExtensionsBrowserClient::CreateAppSorting() {
1651320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  return scoped_ptr<AppSorting>(new NullAppSorting);
1665d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1685d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)bool ShellExtensionsBrowserClient::IsRunningInForcedAppMode() {
1695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return false;
1705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1715d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1725d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ApiActivityMonitor* ShellExtensionsBrowserClient::GetApiActivityMonitor(
1735d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)    BrowserContext* context) {
1745d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  // app_shell doesn't monitor API function calls or events.
1755d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return NULL;
1765d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1775d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
1785d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ExtensionSystemProvider*
1795d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)ShellExtensionsBrowserClient::GetExtensionSystemFactory() {
1805d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  return ShellExtensionSystemFactory::GetInstance();
1815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}
1825d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)
183a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)void ShellExtensionsBrowserClient::RegisterExtensionFunctions(
184a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    ExtensionFunctionRegistry* registry) const {
185c5cede9ae108bb15f6b7a8aea21c7e1fefa2834cBen Murdoch  // Register core extension-system APIs.
1865f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  core_api::GeneratedFunctionRegistry::RegisterAll(registry);
187a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)}
188a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)
189010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)scoped_ptr<RuntimeAPIDelegate>
190010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)ShellExtensionsBrowserClient::CreateRuntimeAPIDelegate(
191010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)    content::BrowserContext* context) const {
1925f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  return scoped_ptr<RuntimeAPIDelegate>(new ShellRuntimeAPIDelegate());
193010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)}
194010d83a9304c5a91596085d917d248abff47903aTorne (Richard Coles)
1956d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)ComponentExtensionResourceManager*
1966d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)ShellExtensionsBrowserClient::GetComponentExtensionResourceManager() {
1976d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)  return NULL;
1986d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)}
1996d86b77056ed63eb6871182f42a9fd5f07550f90Torne (Richard Coles)
2001320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tuccivoid ShellExtensionsBrowserClient::BroadcastEventToRenderers(
2011320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    const std::string& event_name,
2021320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    scoped_ptr<base::ListValue> args) {
2031320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
2041320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    BrowserThread::PostTask(
2051320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci        BrowserThread::UI,
2061320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci        FROM_HERE,
2071320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci        base::Bind(&ShellExtensionsBrowserClient::BroadcastEventToRenderers,
2081320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                   base::Unretained(this),
2091320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                   event_name,
2101320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci                   base::Passed(&args)));
2111320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci    return;
2121320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  }
2131320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
2141320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  scoped_ptr<Event> event(new Event(event_name, args.Pass()));
2151320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci  EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass());
2161320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci}
2171320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci
2185f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)net::NetLog* ShellExtensionsBrowserClient::GetNetLog() {
2195f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)  return NULL;
2205f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)}
2215f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles)
2225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}  // namespace extensions
223