| OLD | NEW |
| 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 "components/guest_view/browser/guest_view_manager.h" | 8 #include "components/guest_view/browser/guest_view_manager.h" |
| 9 #include "content/public/browser/render_view_host.h" | 9 #include "content/public/browser/render_view_host.h" |
| 10 #include "content/public/common/renderer_preferences.h" | 10 #include "content/public/common/renderer_preferences.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 app_view_guest_delegate_( | 97 app_view_guest_delegate_( |
| 98 ExtensionsAPIClient::Get()->CreateAppViewGuestDelegate()), | 98 ExtensionsAPIClient::Get()->CreateAppViewGuestDelegate()), |
| 99 weak_ptr_factory_(this) { | 99 weak_ptr_factory_(this) { |
| 100 if (app_view_guest_delegate_) | 100 if (app_view_guest_delegate_) |
| 101 app_delegate_.reset(app_view_guest_delegate_->CreateAppDelegate()); | 101 app_delegate_.reset(app_view_guest_delegate_->CreateAppDelegate()); |
| 102 } | 102 } |
| 103 | 103 |
| 104 AppViewGuest::~AppViewGuest() { | 104 AppViewGuest::~AppViewGuest() { |
| 105 } | 105 } |
| 106 | 106 |
| 107 WindowController* AppViewGuest::GetExtensionWindowController() const { | |
| 108 return nullptr; | |
| 109 } | |
| 110 | |
| 111 content::WebContents* AppViewGuest::GetAssociatedWebContents() const { | |
| 112 return web_contents(); | |
| 113 } | |
| 114 | |
| 115 bool AppViewGuest::OnMessageReceived(const IPC::Message& message) { | |
| 116 bool handled = true; | |
| 117 IPC_BEGIN_MESSAGE_MAP(AppViewGuest, message) | |
| 118 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | |
| 119 IPC_MESSAGE_UNHANDLED(handled = false) | |
| 120 IPC_END_MESSAGE_MAP() | |
| 121 return handled; | |
| 122 } | |
| 123 | |
| 124 bool AppViewGuest::HandleContextMenu(const content::ContextMenuParams& params) { | 107 bool AppViewGuest::HandleContextMenu(const content::ContextMenuParams& params) { |
| 125 if (app_view_guest_delegate_) { | 108 if (app_view_guest_delegate_) { |
| 126 return app_view_guest_delegate_->HandleContextMenu(web_contents(), params); | 109 return app_view_guest_delegate_->HandleContextMenu(web_contents(), params); |
| 127 } | 110 } |
| 128 return false; | 111 return false; |
| 129 } | 112 } |
| 130 | 113 |
| 131 void AppViewGuest::RequestMediaAccessPermission( | 114 void AppViewGuest::RequestMediaAccessPermission( |
| 132 content::WebContents* web_contents, | 115 content::WebContents* web_contents, |
| 133 const content::MediaStreamRequest& request, | 116 const content::MediaStreamRequest& request, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 } | 202 } |
| 220 | 203 |
| 221 ProcessManager* process_manager = ProcessManager::Get(browser_context()); | 204 ProcessManager* process_manager = ProcessManager::Get(browser_context()); |
| 222 ExtensionHost* host = | 205 ExtensionHost* host = |
| 223 process_manager->GetBackgroundHostForExtension(guest_extension->id()); | 206 process_manager->GetBackgroundHostForExtension(guest_extension->id()); |
| 224 DCHECK(host); | 207 DCHECK(host); |
| 225 LaunchAppAndFireEvent(make_scoped_ptr(data->DeepCopy()), callback, host); | 208 LaunchAppAndFireEvent(make_scoped_ptr(data->DeepCopy()), callback, host); |
| 226 } | 209 } |
| 227 | 210 |
| 228 void AppViewGuest::DidInitialize(const base::DictionaryValue& create_params) { | 211 void AppViewGuest::DidInitialize(const base::DictionaryValue& create_params) { |
| 229 extension_function_dispatcher_.reset( | 212 ExtensionsAPIClient::Get()->AttachWebContentsHelpers(web_contents()); |
| 230 new ExtensionFunctionDispatcher(browser_context(), this)); | |
| 231 | 213 |
| 232 if (!url_.is_valid()) | 214 if (!url_.is_valid()) |
| 233 return; | 215 return; |
| 234 | 216 |
| 235 web_contents()->GetController().LoadURL( | 217 web_contents()->GetController().LoadURL( |
| 236 url_, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 218 url_, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| 237 } | 219 } |
| 238 | 220 |
| 239 const char* AppViewGuest::GetAPINamespace() const { | 221 const char* AppViewGuest::GetAPINamespace() const { |
| 240 return appview::kEmbedderAPINamespace; | 222 return appview::kEmbedderAPINamespace; |
| 241 } | 223 } |
| 242 | 224 |
| 243 int AppViewGuest::GetTaskPrefix() const { | 225 int AppViewGuest::GetTaskPrefix() const { |
| 244 return IDS_EXTENSION_TASK_MANAGER_APPVIEW_TAG_PREFIX; | 226 return IDS_EXTENSION_TASK_MANAGER_APPVIEW_TAG_PREFIX; |
| 245 } | 227 } |
| 246 | 228 |
| 247 void AppViewGuest::OnRequest(const ExtensionHostMsg_Request_Params& params) { | |
| 248 extension_function_dispatcher_->Dispatch(params, | |
| 249 web_contents()->GetRenderViewHost()); | |
| 250 } | |
| 251 | |
| 252 void AppViewGuest::CompleteCreateWebContents( | 229 void AppViewGuest::CompleteCreateWebContents( |
| 253 const GURL& url, | 230 const GURL& url, |
| 254 const Extension* guest_extension, | 231 const Extension* guest_extension, |
| 255 const WebContentsCreatedCallback& callback) { | 232 const WebContentsCreatedCallback& callback) { |
| 256 if (!url.is_valid()) { | 233 if (!url.is_valid()) { |
| 257 callback.Run(nullptr); | 234 callback.Run(nullptr); |
| 258 return; | 235 return; |
| 259 } | 236 } |
| 260 url_ = url; | 237 url_ = url; |
| 261 guest_extension_id_ = guest_extension->id(); | 238 guest_extension_id_ = guest_extension->id(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 287 embed_request->Set(appview::kData, data.release()); | 264 embed_request->Set(appview::kData, data.release()); |
| 288 AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent( | 265 AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent( |
| 289 browser_context(), embed_request.Pass(), extension_host->extension()); | 266 browser_context(), embed_request.Pass(), extension_host->extension()); |
| 290 } | 267 } |
| 291 | 268 |
| 292 void AppViewGuest::SetAppDelegateForTest(AppDelegate* delegate) { | 269 void AppViewGuest::SetAppDelegateForTest(AppDelegate* delegate) { |
| 293 app_delegate_.reset(delegate); | 270 app_delegate_.reset(delegate); |
| 294 } | 271 } |
| 295 | 272 |
| 296 } // namespace extensions | 273 } // namespace extensions |
| OLD | NEW |