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

Side by Side Diff: extensions/browser/guest_view/app_view/app_view_guest.cc

Issue 845363004: <webview>, <appview> and <extensionoptions> can run in a detached state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 5 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/guest_view/app_view/app_view_guest.h" 5 #include "extensions/browser/guest_view/app_view/app_view_guest.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "content/public/browser/render_view_host.h" 8 #include "content/public/browser/render_view_host.h"
9 #include "content/public/common/renderer_preferences.h" 9 #include "content/public/common/renderer_preferences.h"
10 #include "extensions/browser/api/app_runtime/app_runtime_api.h" 10 #include "extensions/browser/api/app_runtime/app_runtime_api.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 158 }
159 const ExtensionSet& enabled_extensions = 159 const ExtensionSet& enabled_extensions =
160 ExtensionRegistry::Get(browser_context())->enabled_extensions(); 160 ExtensionRegistry::Get(browser_context())->enabled_extensions();
161 const Extension* guest_extension = 161 const Extension* guest_extension =
162 enabled_extensions.GetByID(guest_extension_id_); 162 enabled_extensions.GetByID(guest_extension_id_);
163 163
164 return app_delegate_->CheckMediaAccessPermission( 164 return app_delegate_->CheckMediaAccessPermission(
165 web_contents, security_origin, type, guest_extension); 165 web_contents, security_origin, type, guest_extension);
166 } 166 }
167 167
168 const char* AppViewGuest::GetAPINamespace() const { 168 bool AppViewGuest::CanRunInDetachedState() const {
169 return appview::kEmbedderAPINamespace; 169 return true;
170 }
171
172 int AppViewGuest::GetTaskPrefix() const {
173 return IDS_EXTENSION_TASK_MANAGER_APPVIEW_TAG_PREFIX;
174 } 170 }
175 171
176 void AppViewGuest::CreateWebContents( 172 void AppViewGuest::CreateWebContents(
177 const base::DictionaryValue& create_params, 173 const base::DictionaryValue& create_params,
178 const WebContentsCreatedCallback& callback) { 174 const WebContentsCreatedCallback& callback) {
179 std::string app_id; 175 std::string app_id;
180 if (!create_params.GetString(appview::kAppID, &app_id)) { 176 if (!create_params.GetString(appview::kAppID, &app_id)) {
181 callback.Run(nullptr); 177 callback.Run(nullptr);
182 return; 178 return;
183 } 179 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 return; 216 return;
221 } 217 }
222 218
223 ProcessManager* process_manager = ProcessManager::Get(browser_context()); 219 ProcessManager* process_manager = ProcessManager::Get(browser_context());
224 ExtensionHost* host = 220 ExtensionHost* host =
225 process_manager->GetBackgroundHostForExtension(guest_extension->id()); 221 process_manager->GetBackgroundHostForExtension(guest_extension->id());
226 DCHECK(host); 222 DCHECK(host);
227 LaunchAppAndFireEvent(make_scoped_ptr(data->DeepCopy()), callback, host); 223 LaunchAppAndFireEvent(make_scoped_ptr(data->DeepCopy()), callback, host);
228 } 224 }
229 225
230 void AppViewGuest::DidAttachToEmbedder() { 226 void AppViewGuest::DidInitialize(const base::DictionaryValue& create_params) {
231 // This is called after the guest process has been attached to a host 227 extension_function_dispatcher_.reset(
232 // element. This means that the host element knows how to route input 228 new ExtensionFunctionDispatcher(browser_context(), this));
233 // events to the guest, and the guest knows how to get frames to the 229
234 // embedder.
235 if (!url_.is_valid()) 230 if (!url_.is_valid())
236 return; 231 return;
237 232
238 web_contents()->GetController().LoadURL( 233 web_contents()->GetController().LoadURL(
239 url_, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); 234 url_, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
240 url_ = GURL();
241 } 235 }
242 236
243 void AppViewGuest::DidInitialize(const base::DictionaryValue& create_params) { 237 const char* AppViewGuest::GetAPINamespace() const {
244 extension_function_dispatcher_.reset( 238 return appview::kEmbedderAPINamespace;
245 new ExtensionFunctionDispatcher(browser_context(), this)); 239 }
240
241 int AppViewGuest::GetTaskPrefix() const {
242 return IDS_EXTENSION_TASK_MANAGER_APPVIEW_TAG_PREFIX;
246 } 243 }
247 244
248 void AppViewGuest::OnRequest(const ExtensionHostMsg_Request_Params& params) { 245 void AppViewGuest::OnRequest(const ExtensionHostMsg_Request_Params& params) {
249 extension_function_dispatcher_->Dispatch(params, 246 extension_function_dispatcher_->Dispatch(params,
250 web_contents()->GetRenderViewHost()); 247 web_contents()->GetRenderViewHost());
251 } 248 }
252 249
253 void AppViewGuest::CompleteCreateWebContents( 250 void AppViewGuest::CompleteCreateWebContents(
254 const GURL& url, 251 const GURL& url,
255 const Extension* guest_extension, 252 const Extension* guest_extension,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 embed_request->Set(appview::kData, data.release()); 285 embed_request->Set(appview::kData, data.release());
289 AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent( 286 AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent(
290 browser_context(), embed_request.Pass(), extension_host->extension()); 287 browser_context(), embed_request.Pass(), extension_host->extension());
291 } 288 }
292 289
293 void AppViewGuest::SetAppDelegateForTest(AppDelegate* delegate) { 290 void AppViewGuest::SetAppDelegateForTest(AppDelegate* delegate) {
294 app_delegate_.reset(delegate); 291 app_delegate_.reset(delegate);
295 } 292 }
296 293
297 } // namespace extensions 294 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698