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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 content::WebContents* guest_web_contents) { | 58 content::WebContents* guest_web_contents) { |
59 int guest_instance_id = 0; | 59 int guest_instance_id = 0; |
60 if (guest_web_contents) { | 60 if (guest_web_contents) { |
61 GuestViewBase* guest = GuestViewBase::FromWebContents(guest_web_contents); | 61 GuestViewBase* guest = GuestViewBase::FromWebContents(guest_web_contents); |
62 guest_instance_id = guest->guest_instance_id(); | 62 guest_instance_id = guest->guest_instance_id(); |
63 } | 63 } |
64 SetResult(new base::FundamentalValue(guest_instance_id)); | 64 SetResult(new base::FundamentalValue(guest_instance_id)); |
65 SendResponse(true); | 65 SendResponse(true); |
66 } | 66 } |
67 | 67 |
68 GuestViewInternalDestroyGuestFunction:: | |
69 GuestViewInternalDestroyGuestFunction() { | |
70 } | |
71 | |
72 GuestViewInternalDestroyGuestFunction:: | |
73 ~GuestViewInternalDestroyGuestFunction() { | |
74 } | |
75 | |
76 bool GuestViewInternalDestroyGuestFunction::RunAsync() { | |
77 scoped_ptr<guest_view_internal::DestroyGuest::Params> params( | |
78 guest_view_internal::DestroyGuest::Params::Create(*args_)); | |
79 EXTENSION_FUNCTION_VALIDATE(params.get()); | |
80 GuestViewBase* guest = GuestViewBase::From( | |
81 render_view_host()->GetProcess()->GetID(), params->instance_id); | |
82 if (!guest) | |
83 return false; | |
lfg
2014/09/30 18:59:27
Maybe should provide feedback to the javascript AP
Fady Samuel
2014/09/30 22:50:03
This code is likely racy at tear down. The embedde
lfg
2014/09/30 23:29:42
Acknowledged.
| |
84 guest->Destroy(); | |
85 SendResponse(true); | |
86 return true; | |
87 } | |
88 | |
68 GuestViewInternalSetAutoSizeFunction:: | 89 GuestViewInternalSetAutoSizeFunction:: |
69 GuestViewInternalSetAutoSizeFunction() { | 90 GuestViewInternalSetAutoSizeFunction() { |
70 } | 91 } |
71 | 92 |
72 GuestViewInternalSetAutoSizeFunction:: | 93 GuestViewInternalSetAutoSizeFunction:: |
73 ~GuestViewInternalSetAutoSizeFunction() { | 94 ~GuestViewInternalSetAutoSizeFunction() { |
74 } | 95 } |
75 | 96 |
76 bool GuestViewInternalSetAutoSizeFunction::RunAsync() { | 97 bool GuestViewInternalSetAutoSizeFunction::RunAsync() { |
77 scoped_ptr<guest_view_internal::SetAutoSize::Params> params( | 98 scoped_ptr<guest_view_internal::SetAutoSize::Params> params( |
78 guest_view_internal::SetAutoSize::Params::Create(*args_)); | 99 guest_view_internal::SetAutoSize::Params::Create(*args_)); |
79 EXTENSION_FUNCTION_VALIDATE(params.get()); | 100 EXTENSION_FUNCTION_VALIDATE(params.get()); |
80 GuestViewBase* guest = GuestViewBase::From( | 101 GuestViewBase* guest = GuestViewBase::From( |
81 render_view_host()->GetProcess()->GetID(), params->instance_id); | 102 render_view_host()->GetProcess()->GetID(), params->instance_id); |
82 if (!guest) | 103 if (!guest) |
83 return false; | 104 return false; |
84 guest->SetAutoSize(params->params.enable_auto_size, | 105 guest->SetAutoSize(params->params.enable_auto_size, |
85 gfx::Size(params->params.min.width, | 106 gfx::Size(params->params.min.width, |
86 params->params.min.height), | 107 params->params.min.height), |
87 gfx::Size(params->params.max.width, | 108 gfx::Size(params->params.max.width, |
88 params->params.max.height)); | 109 params->params.max.height)); |
89 SendResponse(true); | 110 SendResponse(true); |
90 return true; | 111 return true; |
91 } | 112 } |
92 | 113 |
93 } // namespace extensions | 114 } // namespace extensions |
OLD | NEW |