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 "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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 | 107 |
108 AppViewGuest::~AppViewGuest() { | 108 AppViewGuest::~AppViewGuest() { |
109 } | 109 } |
110 | 110 |
111 WindowController* AppViewGuest::GetExtensionWindowController() const { | 111 WindowController* AppViewGuest::GetExtensionWindowController() const { |
112 return NULL; | 112 return NULL; |
113 } | 113 } |
114 | 114 |
115 content::WebContents* AppViewGuest::GetAssociatedWebContents() const { | 115 content::WebContents* AppViewGuest::GetAssociatedWebContents() const { |
116 return guest_web_contents(); | 116 return web_contents(); |
117 } | 117 } |
118 | 118 |
119 bool AppViewGuest::OnMessageReceived(const IPC::Message& message) { | 119 bool AppViewGuest::OnMessageReceived(const IPC::Message& message) { |
120 bool handled = true; | 120 bool handled = true; |
121 IPC_BEGIN_MESSAGE_MAP(AppViewGuest, message) | 121 IPC_BEGIN_MESSAGE_MAP(AppViewGuest, message) |
122 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) | 122 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) |
123 IPC_MESSAGE_UNHANDLED(handled = false) | 123 IPC_MESSAGE_UNHANDLED(handled = false) |
124 IPC_END_MESSAGE_MAP() | 124 IPC_END_MESSAGE_MAP() |
125 return handled; | 125 return handled; |
126 } | 126 } |
127 | 127 |
128 bool AppViewGuest::HandleContextMenu(const content::ContextMenuParams& params) { | 128 bool AppViewGuest::HandleContextMenu(const content::ContextMenuParams& params) { |
129 if (app_view_guest_delegate_) { | 129 if (app_view_guest_delegate_) { |
130 return app_view_guest_delegate_->HandleContextMenu(guest_web_contents(), | 130 return app_view_guest_delegate_->HandleContextMenu(web_contents(), params); |
131 params); | |
132 } | 131 } |
133 return false; | 132 return false; |
134 } | 133 } |
135 | 134 |
136 const char* AppViewGuest::GetAPINamespace() const { | 135 const char* AppViewGuest::GetAPINamespace() const { |
137 return appview::kEmbedderAPINamespace; | 136 return appview::kEmbedderAPINamespace; |
138 } | 137 } |
139 | 138 |
140 int AppViewGuest::GetTaskPrefix() const { | 139 int AppViewGuest::GetTaskPrefix() const { |
141 return IDS_EXTENSION_TASK_MANAGER_APPVIEW_TAG_PREFIX; | 140 return IDS_EXTENSION_TASK_MANAGER_APPVIEW_TAG_PREFIX; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 process_manager->GetBackgroundHostForExtension(guest_extension->id()); | 195 process_manager->GetBackgroundHostForExtension(guest_extension->id()); |
197 DCHECK(host); | 196 DCHECK(host); |
198 LaunchAppAndFireEvent(make_scoped_ptr(data->DeepCopy()), callback, host); | 197 LaunchAppAndFireEvent(make_scoped_ptr(data->DeepCopy()), callback, host); |
199 } | 198 } |
200 | 199 |
201 void AppViewGuest::DidAttachToEmbedder() { | 200 void AppViewGuest::DidAttachToEmbedder() { |
202 // This is called after the guest process has been attached to a host | 201 // This is called after the guest process has been attached to a host |
203 // element. This means that the host element knows how to route input | 202 // element. This means that the host element knows how to route input |
204 // events to the guest, and the guest knows how to get frames to the | 203 // events to the guest, and the guest knows how to get frames to the |
205 // embedder. | 204 // embedder. |
206 guest_web_contents()->GetController().LoadURL( | 205 web_contents()->GetController().LoadURL( |
207 url_, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); | 206 url_, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); |
208 } | 207 } |
209 | 208 |
210 void AppViewGuest::DidInitialize() { | 209 void AppViewGuest::DidInitialize() { |
211 extension_function_dispatcher_.reset( | 210 extension_function_dispatcher_.reset( |
212 new ExtensionFunctionDispatcher(browser_context(), this)); | 211 new ExtensionFunctionDispatcher(browser_context(), this)); |
213 } | 212 } |
214 | 213 |
215 void AppViewGuest::OnRequest(const ExtensionHostMsg_Request_Params& params) { | 214 void AppViewGuest::OnRequest(const ExtensionHostMsg_Request_Params& params) { |
216 extension_function_dispatcher_->Dispatch( | 215 extension_function_dispatcher_->Dispatch(params, |
217 params, guest_web_contents()->GetRenderViewHost()); | 216 web_contents()->GetRenderViewHost()); |
218 } | 217 } |
219 | 218 |
220 void AppViewGuest::CompleteCreateWebContents( | 219 void AppViewGuest::CompleteCreateWebContents( |
221 const GURL& url, | 220 const GURL& url, |
222 const Extension* guest_extension, | 221 const Extension* guest_extension, |
223 const WebContentsCreatedCallback& callback) { | 222 const WebContentsCreatedCallback& callback) { |
224 if (!url.is_valid()) { | 223 if (!url.is_valid()) { |
225 callback.Run(NULL); | 224 callback.Run(NULL); |
226 return; | 225 return; |
227 } | 226 } |
(...skipping 23 matching lines...) Expand all Loading... |
251 | 250 |
252 scoped_ptr<base::DictionaryValue> embed_request(new base::DictionaryValue()); | 251 scoped_ptr<base::DictionaryValue> embed_request(new base::DictionaryValue()); |
253 embed_request->SetInteger(appview::kGuestInstanceID, guest_instance_id()); | 252 embed_request->SetInteger(appview::kGuestInstanceID, guest_instance_id()); |
254 embed_request->SetString(appview::kEmbedderID, embedder_extension_id()); | 253 embed_request->SetString(appview::kEmbedderID, embedder_extension_id()); |
255 embed_request->Set(appview::kData, data.release()); | 254 embed_request->Set(appview::kData, data.release()); |
256 AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent( | 255 AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent( |
257 browser_context(), embed_request.Pass(), extension_host->extension()); | 256 browser_context(), embed_request.Pass(), extension_host->extension()); |
258 } | 257 } |
259 | 258 |
260 } // namespace extensions | 259 } // namespace extensions |
OLD | NEW |