| 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/api/guest_view/guest_view_internal_api.h" | 5 #include "extensions/browser/api/guest_view/guest_view_internal_api.h" |
| 6 | 6 |
| 7 #include "content/public/browser/render_process_host.h" | 7 #include "content/public/browser/render_process_host.h" |
| 8 #include "content/public/browser/render_view_host.h" | 8 #include "content/public/browser/render_view_host.h" |
| 9 #include "extensions/browser/guest_view/guest_view_base.h" | 9 #include "extensions/browser/guest_view/guest_view_base.h" |
| 10 #include "extensions/browser/guest_view/guest_view_manager.h" | 10 #include "extensions/browser/guest_view/guest_view_manager.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 GuestViewManager::WebContentsCreatedCallback callback = | 32 GuestViewManager::WebContentsCreatedCallback callback = |
| 33 base::Bind(&GuestViewInternalCreateGuestFunction::CreateGuestCallback, | 33 base::Bind(&GuestViewInternalCreateGuestFunction::CreateGuestCallback, |
| 34 this); | 34 this); |
| 35 | 35 |
| 36 content::WebContents* owner_web_contents = | 36 content::WebContents* owner_web_contents = |
| 37 content::WebContents::FromRenderViewHost(render_view_host()); | 37 content::WebContents::FromRenderViewHost(render_view_host()); |
| 38 if (!owner_web_contents) { | 38 if (!owner_web_contents) { |
| 39 error_ = "Guest views can only be embedded in web content"; | 39 error_ = "Guest views can only be embedded in web content"; |
| 40 return false; | 40 return false; |
| 41 } | 41 } |
| 42 // If the guest is an <extensionoptions> to be embedded in a WebUI, then | |
| 43 // there is no extension, and extension() will be null. Use an empty string | |
| 44 // instead. | |
| 45 std::string embedder_extension_id = | |
| 46 extension() ? extension_id() : std::string(); | |
| 47 | 42 |
| 48 guest_view_manager->CreateGuest(view_type, | 43 guest_view_manager->CreateGuest(view_type, |
| 49 embedder_extension_id, | |
| 50 owner_web_contents, | 44 owner_web_contents, |
| 51 *create_params, | 45 *create_params, |
| 52 callback); | 46 callback); |
| 53 return true; | 47 return true; |
| 54 } | 48 } |
| 55 | 49 |
| 56 void GuestViewInternalCreateGuestFunction::CreateGuestCallback( | 50 void GuestViewInternalCreateGuestFunction::CreateGuestCallback( |
| 57 content::WebContents* guest_web_contents) { | 51 content::WebContents* guest_web_contents) { |
| 58 int guest_instance_id = 0; | 52 int guest_instance_id = 0; |
| 59 if (guest_web_contents) { | 53 if (guest_web_contents) { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 guest->SetAutoSize(params->params.enable_auto_size, | 98 guest->SetAutoSize(params->params.enable_auto_size, |
| 105 gfx::Size(params->params.min.width, | 99 gfx::Size(params->params.min.width, |
| 106 params->params.min.height), | 100 params->params.min.height), |
| 107 gfx::Size(params->params.max.width, | 101 gfx::Size(params->params.max.width, |
| 108 params->params.max.height)); | 102 params->params.max.height)); |
| 109 SendResponse(true); | 103 SendResponse(true); |
| 110 return true; | 104 return true; |
| 111 } | 105 } |
| 112 | 106 |
| 113 } // namespace extensions | 107 } // namespace extensions |
| OLD | NEW |