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

Side by Side Diff: apps/shell/browser/shell_extensions_browser_client.cc

Issue 412713002: Move apps/shell to extensions/shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 40% Created 6 years, 5 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
(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/browser/shell_extensions_browser_client.h"
6
7 #include "apps/shell/browser/shell_app_sorting.h"
8 #include "apps/shell/browser/shell_extension_system_factory.h"
9 #include "apps/shell/browser/shell_extension_web_contents_observer.h"
10 #include "apps/shell/browser/shell_runtime_api_delegate.h"
11 #include "apps/shell/common/api/generated_api.h"
12 #include "base/prefs/pref_service.h"
13 #include "base/prefs/pref_service_factory.h"
14 #include "base/prefs/testing_pref_store.h"
15 #include "components/pref_registry/pref_registry_syncable.h"
16 #include "components/user_prefs/user_prefs.h"
17 #include "extensions/browser/api/extensions_api_client.h"
18 #include "extensions/browser/app_sorting.h"
19 #include "extensions/browser/extension_function_registry.h"
20 #include "extensions/browser/extension_host_delegate.h"
21 #include "extensions/browser/extension_prefs.h"
22 #include "extensions/common/api/generated_api.h"
23
24 using content::BrowserContext;
25
26 namespace extensions {
27 namespace {
28
29 // See chrome::RegisterProfilePrefs() in chrome/browser/prefs/browser_prefs.cc
30 void RegisterPrefs(user_prefs::PrefRegistrySyncable* registry) {
31 ExtensionPrefs::RegisterProfilePrefs(registry);
32 }
33
34 // A minimal ExtensionHostDelegate.
35 class ShellExtensionHostDelegate : public ExtensionHostDelegate {
36 public:
37 ShellExtensionHostDelegate() {}
38 virtual ~ShellExtensionHostDelegate() {}
39
40 // ExtensionHostDelegate implementation.
41 virtual void OnExtensionHostCreated(content::WebContents* web_contents)
42 OVERRIDE;
43
44 virtual void OnRenderViewCreatedForBackgroundPage(ExtensionHost* host)
45 OVERRIDE {}
46
47 virtual content::JavaScriptDialogManager* GetJavaScriptDialogManager()
48 OVERRIDE {
49 // TODO(jamescook): Create a JavaScriptDialogManager or reuse the one from
50 // content_shell.
51 NOTREACHED();
52 return NULL;
53 }
54
55 virtual void CreateTab(content::WebContents* web_contents,
56 const std::string& extension_id,
57 WindowOpenDisposition disposition,
58 const gfx::Rect& initial_pos,
59 bool user_gesture) OVERRIDE {
60 // TODO(jamescook): Should app_shell support opening popup windows?
61 NOTREACHED();
62 }
63
64 virtual void ProcessMediaAccessRequest(
65 content::WebContents* web_contents,
66 const content::MediaStreamRequest& request,
67 const content::MediaResponseCallback& callback,
68 const Extension* extension) OVERRIDE {
69 // app_shell does not support media capture.
70 NOTREACHED();
71 }
72 };
73
74 void ShellExtensionHostDelegate::OnExtensionHostCreated(
75 content::WebContents* web_contents) {
76 ShellExtensionWebContentsObserver::CreateForWebContents(web_contents);
77 }
78
79 } // namespace
80
81 ShellExtensionsBrowserClient::ShellExtensionsBrowserClient(
82 BrowserContext* context)
83 : browser_context_(context), api_client_(new ExtensionsAPIClient) {
84 // Set up the preferences service.
85 base::PrefServiceFactory factory;
86 factory.set_user_prefs(new TestingPrefStore);
87 factory.set_extension_prefs(new TestingPrefStore);
88 // app_shell should not require syncable preferences, but for now we need to
89 // recycle some of the RegisterProfilePrefs() code in Chrome.
90 // TODO(jamescook): Convert this to PrefRegistrySimple.
91 user_prefs::PrefRegistrySyncable* pref_registry =
92 new user_prefs::PrefRegistrySyncable;
93 // Prefs should be registered before the PrefService is created.
94 RegisterPrefs(pref_registry);
95 prefs_ = factory.Create(pref_registry).Pass();
96 user_prefs::UserPrefs::Set(browser_context_, prefs_.get());
97 }
98
99 ShellExtensionsBrowserClient::~ShellExtensionsBrowserClient() {}
100
101 bool ShellExtensionsBrowserClient::IsShuttingDown() {
102 return false;
103 }
104
105 bool ShellExtensionsBrowserClient::AreExtensionsDisabled(
106 const base::CommandLine& command_line,
107 BrowserContext* context) {
108 return false;
109 }
110
111 bool ShellExtensionsBrowserClient::IsValidContext(BrowserContext* context) {
112 return context == browser_context_;
113 }
114
115 bool ShellExtensionsBrowserClient::IsSameContext(BrowserContext* first,
116 BrowserContext* second) {
117 return first == second;
118 }
119
120 bool ShellExtensionsBrowserClient::HasOffTheRecordContext(
121 BrowserContext* context) {
122 return false;
123 }
124
125 BrowserContext* ShellExtensionsBrowserClient::GetOffTheRecordContext(
126 BrowserContext* context) {
127 // app_shell only supports a single context.
128 return NULL;
129 }
130
131 BrowserContext* ShellExtensionsBrowserClient::GetOriginalContext(
132 BrowserContext* context) {
133 return context;
134 }
135
136 bool ShellExtensionsBrowserClient::IsGuestSession(
137 BrowserContext* context) const {
138 return false;
139 }
140
141 bool ShellExtensionsBrowserClient::IsExtensionIncognitoEnabled(
142 const std::string& extension_id,
143 content::BrowserContext* context) const {
144 return false;
145 }
146
147 bool ShellExtensionsBrowserClient::CanExtensionCrossIncognito(
148 const extensions::Extension* extension,
149 content::BrowserContext* context) const {
150 return false;
151 }
152
153 bool ShellExtensionsBrowserClient::IsWebViewRequest(
154 net::URLRequest* request) const {
155 return false;
156 }
157
158 net::URLRequestJob*
159 ShellExtensionsBrowserClient::MaybeCreateResourceBundleRequestJob(
160 net::URLRequest* request,
161 net::NetworkDelegate* network_delegate,
162 const base::FilePath& directory_path,
163 const std::string& content_security_policy,
164 bool send_cors_header) {
165 return NULL;
166 }
167
168 bool ShellExtensionsBrowserClient::AllowCrossRendererResourceLoad(
169 net::URLRequest* request,
170 bool is_incognito,
171 const Extension* extension,
172 InfoMap* extension_info_map) {
173 // Note: This may need to change if app_shell supports webview.
174 return false;
175 }
176
177 PrefService* ShellExtensionsBrowserClient::GetPrefServiceForContext(
178 BrowserContext* context) {
179 return prefs_.get();
180 }
181
182 void ShellExtensionsBrowserClient::GetEarlyExtensionPrefsObservers(
183 content::BrowserContext* context,
184 std::vector<ExtensionPrefsObserver*>* observers) const {}
185
186 ProcessManagerDelegate*
187 ShellExtensionsBrowserClient::GetProcessManagerDelegate() const {
188 return NULL;
189 }
190
191 scoped_ptr<ExtensionHostDelegate>
192 ShellExtensionsBrowserClient::CreateExtensionHostDelegate() {
193 return scoped_ptr<ExtensionHostDelegate>(new ShellExtensionHostDelegate);
194 }
195
196 bool ShellExtensionsBrowserClient::DidVersionUpdate(BrowserContext* context) {
197 // TODO(jamescook): We might want to tell extensions when app_shell updates.
198 return false;
199 }
200
201 scoped_ptr<AppSorting> ShellExtensionsBrowserClient::CreateAppSorting() {
202 return scoped_ptr<AppSorting>(new apps::ShellAppSorting);
203 }
204
205 bool ShellExtensionsBrowserClient::IsRunningInForcedAppMode() {
206 return false;
207 }
208
209 ApiActivityMonitor* ShellExtensionsBrowserClient::GetApiActivityMonitor(
210 BrowserContext* context) {
211 // app_shell doesn't monitor API function calls or events.
212 return NULL;
213 }
214
215 ExtensionSystemProvider*
216 ShellExtensionsBrowserClient::GetExtensionSystemFactory() {
217 return ShellExtensionSystemFactory::GetInstance();
218 }
219
220 void ShellExtensionsBrowserClient::RegisterExtensionFunctions(
221 ExtensionFunctionRegistry* registry) const {
222 // Register core extension-system APIs.
223 extensions::core_api::GeneratedFunctionRegistry::RegisterAll(registry);
224
225 // Register chrome.shell APIs.
226 apps::shell_api::GeneratedFunctionRegistry::RegisterAll(registry);
227 }
228
229 scoped_ptr<RuntimeAPIDelegate>
230 ShellExtensionsBrowserClient::CreateRuntimeAPIDelegate(
231 content::BrowserContext* context) const {
232 return scoped_ptr<RuntimeAPIDelegate>(new apps::ShellRuntimeAPIDelegate());
233 }
234
235 ComponentExtensionResourceManager*
236 ShellExtensionsBrowserClient::GetComponentExtensionResourceManager() {
237 return NULL;
238 }
239
240 } // namespace extensions
OLDNEW
« no previous file with comments | « apps/shell/browser/shell_extensions_browser_client.h ('k') | apps/shell/browser/shell_network_controller_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698