[OriginChip] Show the default search provider in the Omnibox hint text.
[chromium-blink-merge.git] / apps / shell / browser / shell_extensions_browser_client.cc
blob0ed1f1b64386d816c762dad50a8e4b6b12149672
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.
5 #include "apps/shell/browser/shell_extensions_browser_client.h"
7 #include "apps/shell/browser/shell_app_sorting.h"
8 #include "apps/shell/browser/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"
17 using content::BrowserContext;
19 namespace extensions {
20 namespace {
22 // See chrome::RegisterProfilePrefs() in chrome/browser/prefs/browser_prefs.cc
23 void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) {
24 ExtensionPrefs::RegisterProfilePrefs(registry);
27 } // namespace
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());
48 ShellExtensionsBrowserClient::~ShellExtensionsBrowserClient() {}
50 bool ShellExtensionsBrowserClient::IsShuttingDown() {
51 return false;
54 bool ShellExtensionsBrowserClient::AreExtensionsDisabled(
55 const CommandLine& command_line,
56 BrowserContext* context) {
57 return false;
60 bool ShellExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
61 return context == browser_context_;
64 bool ShellExtensionsBrowserClient::IsSameContext(BrowserContext* first,
65 BrowserContext* second) {
66 return first == second;
69 bool ShellExtensionsBrowserClient::HasOffTheRecordContext(
70 BrowserContext* context) {
71 return false;
74 BrowserContext* ShellExtensionsBrowserClient::GetOffTheRecordContext(
75 BrowserContext* context) {
76 // app_shell only supports a single context.
77 return NULL;
80 BrowserContext* ShellExtensionsBrowserClient::GetOriginalContext(
81 BrowserContext* context) {
82 return context;
85 PrefService* ShellExtensionsBrowserClient::GetPrefServiceForContext(
86 BrowserContext* context) {
87 return prefs_.get();
90 bool ShellExtensionsBrowserClient::DeferLoadingBackgroundHosts(
91 BrowserContext* context) const {
92 return false;
95 bool ShellExtensionsBrowserClient::IsBackgroundPageAllowed(
96 BrowserContext* context) const {
97 return true;
100 void ShellExtensionsBrowserClient::OnExtensionHostCreated(
101 content::WebContents* web_contents) {
104 bool ShellExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
105 // TODO(jamescook): We might want to tell extensions when app_shell updates.
106 return false;
109 scoped_ptr<AppSorting> ShellExtensionsBrowserClient::CreateAppSorting() {
110 return scoped_ptr<AppSorting>(new apps::ShellAppSorting).Pass();
113 bool ShellExtensionsBrowserClient::IsRunningInForcedAppMode() {
114 return false;
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;
125 std::vector<BrowserContextKeyedServiceFactory*>
126 ShellExtensionsBrowserClient::GetExtensionSystemDependencies() {
127 return ShellExtensionSystem::GetDependencies();
130 ExtensionSystem* ShellExtensionsBrowserClient::CreateExtensionSystem(
131 BrowserContext* context) {
132 return new ShellExtensionSystem(context);
135 } // namespace extensions