| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "apps/shell/shell_extensions_browser_client.h" | |
| 6 | |
| 7 #include "apps/shell/shell_app_sorting.h" | |
| 8 #include "apps/shell/shell_extension_system.h" | |
| 9 #include "base/prefs/pref_service.h" | |
| 10 #include "base/prefs/pref_service_factory.h" | |
| 11 #include "base/prefs/testing_pref_store.h" | |
| 12 #include "components/user_prefs/pref_registry_syncable.h" | |
| 13 #include "components/user_prefs/user_prefs.h" | |
| 14 #include "extensions/browser/app_sorting.h" | |
| 15 #include "extensions/browser/extension_prefs.h" | |
| 16 | |
| 17 using content::BrowserContext; | |
| 18 | |
| 19 namespace extensions { | |
| 20 namespace { | |
| 21 | |
| 22 // See chrome::RegisterProfilePrefs() in chrome/browser/prefs/browser_prefs.cc | |
| 23 void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) { | |
| 24 ExtensionPrefs::RegisterProfilePrefs(registry); | |
| 25 } | |
| 26 | |
| 27 } // namespace | |
| 28 | |
| 29 | |
| 30 ShellExtensionsBrowserClient::ShellExtensionsBrowserClient( | |
| 31 BrowserContext* context) | |
| 32 : browser_context_(context) { | |
| 33 // Set up the preferences service. | |
| 34 base::PrefServiceFactory factory; | |
| 35 factory.set_user_prefs(new TestingPrefStore); | |
| 36 factory.set_extension_prefs(new TestingPrefStore); | |
| 37 // app_shell should not require syncable preferences, but for now we need to | |
| 38 // recycle some of the RegisterProfilePrefs() code in Chrome. | |
| 39 // TODO(jamescook): Convert this to user_prefs::PrefRegistrySimple. | |
| 40 user_prefs::PrefRegistrySyncable* pref_registry = | |
| 41 new user_prefs::PrefRegistrySyncable; | |
| 42 // Prefs should be registered before the PrefService is created. | |
| 43 RegisterPrefs(pref_registry); | |
| 44 prefs_ = factory.Create(pref_registry).Pass(); | |
| 45 user_prefs::UserPrefs::Set(browser_context_, prefs_.get()); | |
| 46 } | |
| 47 | |
| 48 ShellExtensionsBrowserClient::~ShellExtensionsBrowserClient() {} | |
| 49 | |
| 50 bool ShellExtensionsBrowserClient::IsShuttingDown() { | |
| 51 return false; | |
| 52 } | |
| 53 | |
| 54 bool ShellExtensionsBrowserClient::AreExtensionsDisabled( | |
| 55 const CommandLine& command_line, | |
| 56 BrowserContext* context) { | |
| 57 return false; | |
| 58 } | |
| 59 | |
| 60 bool ShellExtensionsBrowserClient::IsValidContext(BrowserContext* context) { | |
| 61 return context == browser_context_; | |
| 62 } | |
| 63 | |
| 64 bool ShellExtensionsBrowserClient::IsSameContext(BrowserContext* first, | |
| 65 BrowserContext* second) { | |
| 66 return first == second; | |
| 67 } | |
| 68 | |
| 69 bool ShellExtensionsBrowserClient::HasOffTheRecordContext( | |
| 70 BrowserContext* context) { | |
| 71 return false; | |
| 72 } | |
| 73 | |
| 74 BrowserContext* ShellExtensionsBrowserClient::GetOffTheRecordContext( | |
| 75 BrowserContext* context) { | |
| 76 // app_shell only supports a single context. | |
| 77 return NULL; | |
| 78 } | |
| 79 | |
| 80 BrowserContext* ShellExtensionsBrowserClient::GetOriginalContext( | |
| 81 BrowserContext* context) { | |
| 82 return context; | |
| 83 } | |
| 84 | |
| 85 PrefService* ShellExtensionsBrowserClient::GetPrefServiceForContext( | |
| 86 BrowserContext* context) { | |
| 87 return prefs_.get(); | |
| 88 } | |
| 89 | |
| 90 bool ShellExtensionsBrowserClient::DeferLoadingBackgroundHosts( | |
| 91 BrowserContext* context) const { | |
| 92 return false; | |
| 93 } | |
| 94 | |
| 95 bool ShellExtensionsBrowserClient::IsBackgroundPageAllowed( | |
| 96 BrowserContext* context) const { | |
| 97 return true; | |
| 98 } | |
| 99 | |
| 100 void ShellExtensionsBrowserClient::OnExtensionHostCreated( | |
| 101 content::WebContents* web_contents) { | |
| 102 } | |
| 103 | |
| 104 bool ShellExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) { | |
| 105 // TODO(jamescook): We might want to tell extensions when app_shell updates. | |
| 106 return false; | |
| 107 } | |
| 108 | |
| 109 scoped_ptr<AppSorting> ShellExtensionsBrowserClient::CreateAppSorting() { | |
| 110 return scoped_ptr<AppSorting>(new apps::ShellAppSorting).Pass(); | |
| 111 } | |
| 112 | |
| 113 bool ShellExtensionsBrowserClient::IsRunningInForcedAppMode() { | |
| 114 return false; | |
| 115 } | |
| 116 | |
| 117 content::JavaScriptDialogManager* | |
| 118 ShellExtensionsBrowserClient::GetJavaScriptDialogManager() { | |
| 119 // TODO(jamescook): Create a JavaScriptDialogManager or reuse the one from | |
| 120 // content_shell. | |
| 121 NOTREACHED(); | |
| 122 return NULL; | |
| 123 } | |
| 124 | |
| 125 std::vector<BrowserContextKeyedServiceFactory*> | |
| 126 ShellExtensionsBrowserClient::GetExtensionSystemDependencies() { | |
| 127 return ShellExtensionSystem::GetDependencies(); | |
| 128 } | |
| 129 | |
| 130 ExtensionSystem* ShellExtensionsBrowserClient::CreateExtensionSystem( | |
| 131 BrowserContext* context) { | |
| 132 return new ShellExtensionSystem(context); | |
| 133 } | |
| 134 | |
| 135 } // namespace extensions | |
| OLD | NEW |