| 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 const ExtensionSet& enabled_extensions = | 165 const ExtensionSet& enabled_extensions = |
| 166 ExtensionRegistry::Get(browser_context())->enabled_extensions(); | 166 ExtensionRegistry::Get(browser_context())->enabled_extensions(); |
| 167 const Extension* guest_extension = | 167 const Extension* guest_extension = |
| 168 enabled_extensions.GetByID(guest_extension_id_); | 168 enabled_extensions.GetByID(guest_extension_id_); |
| 169 | 169 |
| 170 return app_delegate_->CheckMediaAccessPermission( | 170 return app_delegate_->CheckMediaAccessPermission( |
| 171 web_contents, security_origin, type, guest_extension); | 171 web_contents, security_origin, type, guest_extension); |
| 172 } | 172 } |
| 173 | 173 |
| 174 const char* AppViewGuest::GetAPINamespace() const { | 174 bool AppViewGuest::CanRunInDetachedState() const { |
| 175 return appview::kEmbedderAPINamespace; | 175 return true; |
| 176 } | |
| 177 | |
| 178 int AppViewGuest::GetTaskPrefix() const { | |
| 179 return IDS_EXTENSION_TASK_MANAGER_APPVIEW_TAG_PREFIX; | |
| 180 } | 176 } |
| 181 | 177 |
| 182 void AppViewGuest::CreateWebContents( | 178 void AppViewGuest::CreateWebContents( |
| 183 const base::DictionaryValue& create_params, | 179 const base::DictionaryValue& create_params, |
| 184 const WebContentsCreatedCallback& callback) { | 180 const WebContentsCreatedCallback& callback) { |
| 185 std::string app_id; | 181 std::string app_id; |
| 186 if (!create_params.GetString(appview::kAppID, &app_id)) { | 182 if (!create_params.GetString(appview::kAppID, &app_id)) { |
| 187 callback.Run(NULL); | 183 callback.Run(NULL); |
| 188 return; | 184 return; |
| 189 } | 185 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 return; | 222 return; |
| 227 } | 223 } |
| 228 | 224 |
| 229 ProcessManager* process_manager = ProcessManager::Get(browser_context()); | 225 ProcessManager* process_manager = ProcessManager::Get(browser_context()); |
| 230 ExtensionHost* host = | 226 ExtensionHost* host = |
| 231 process_manager->GetBackgroundHostForExtension(guest_extension->id()); | 227 process_manager->GetBackgroundHostForExtension(guest_extension->id()); |
| 232 DCHECK(host); | 228 DCHECK(host); |
| 233 LaunchAppAndFireEvent(make_scoped_ptr(data->DeepCopy()), callback, host); | 229 LaunchAppAndFireEvent(make_scoped_ptr(data->DeepCopy()), callback, host); |
| 234 } | 230 } |
| 235 | 231 |
| 236 void AppViewGuest::DidAttachToEmbedder() { | 232 void AppViewGuest::DidInitialize(const base::DictionaryValue& create_params) { |
| 237 // This is called after the guest process has been attached to a host | 233 extension_function_dispatcher_.reset( |
| 238 // element. This means that the host element knows how to route input | 234 new ExtensionFunctionDispatcher(browser_context(), this)); |
| 239 // events to the guest, and the guest knows how to get frames to the | 235 |
| 240 // embedder. | |
| 241 if (!url_.is_valid()) | 236 if (!url_.is_valid()) |
| 242 return; | 237 return; |
| 243 | 238 |
| 244 web_contents()->GetController().LoadURL( | 239 web_contents()->GetController().LoadURL( |
| 245 url_, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); | 240 url_, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| 246 url_ = GURL(); | |
| 247 } | 241 } |
| 248 | 242 |
| 249 void AppViewGuest::DidInitialize(const base::DictionaryValue& create_params) { | 243 const char* AppViewGuest::GetAPINamespace() const { |
| 250 extension_function_dispatcher_.reset( | 244 return appview::kEmbedderAPINamespace; |
| 251 new ExtensionFunctionDispatcher(browser_context(), this)); | 245 } |
| 246 |
| 247 int AppViewGuest::GetTaskPrefix() const { |
| 248 return IDS_EXTENSION_TASK_MANAGER_APPVIEW_TAG_PREFIX; |
| 252 } | 249 } |
| 253 | 250 |
| 254 void AppViewGuest::OnRequest(const ExtensionHostMsg_Request_Params& params) { | 251 void AppViewGuest::OnRequest(const ExtensionHostMsg_Request_Params& params) { |
| 255 extension_function_dispatcher_->Dispatch(params, | 252 extension_function_dispatcher_->Dispatch(params, |
| 256 web_contents()->GetRenderViewHost()); | 253 web_contents()->GetRenderViewHost()); |
| 257 } | 254 } |
| 258 | 255 |
| 259 void AppViewGuest::CompleteCreateWebContents( | 256 void AppViewGuest::CompleteCreateWebContents( |
| 260 const GURL& url, | 257 const GURL& url, |
| 261 const Extension* guest_extension, | 258 const Extension* guest_extension, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 embed_request->Set(appview::kData, data.release()); | 291 embed_request->Set(appview::kData, data.release()); |
| 295 AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent( | 292 AppRuntimeEventRouter::DispatchOnEmbedRequestedEvent( |
| 296 browser_context(), embed_request.Pass(), extension_host->extension()); | 293 browser_context(), embed_request.Pass(), extension_host->extension()); |
| 297 } | 294 } |
| 298 | 295 |
| 299 void AppViewGuest::SetAppDelegateForTest(AppDelegate* delegate) { | 296 void AppViewGuest::SetAppDelegateForTest(AppDelegate* delegate) { |
| 300 app_delegate_.reset(delegate); | 297 app_delegate_.reset(delegate); |
| 301 } | 298 } |
| 302 | 299 |
| 303 } // namespace extensions | 300 } // namespace extensions |
| OLD | NEW |