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 "components/guest_view/browser/guest_view_base.h" | 5 #include "components/guest_view/browser/guest_view_base.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "components/guest_view/browser/guest_view_event.h" | 9 #include "components/guest_view/browser/guest_view_event.h" |
10 #include "components/guest_view/browser/guest_view_manager.h" | 10 #include "components/guest_view/browser/guest_view_manager.h" |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 private: | 103 private: |
104 bool is_fullscreen_; | 104 bool is_fullscreen_; |
105 bool destroyed_; | 105 bool destroyed_; |
106 GuestViewBase* guest_; | 106 GuestViewBase* guest_; |
107 | 107 |
108 void Destroy() { | 108 void Destroy() { |
109 if (destroyed_) | 109 if (destroyed_) |
110 return; | 110 return; |
111 | 111 |
112 destroyed_ = true; | 112 destroyed_ = true; |
113 guest_->EmbedderWillBeDestroyed(); | 113 GuestViewManager::FromBrowserContext(web_contents()->GetBrowserContext()) |
114 ->EmbedderWillBeDestroyed( | |
115 web_contents()->GetRenderProcessHost()->GetID()); | |
114 guest_->Destroy(); | 116 guest_->Destroy(); |
115 } | 117 } |
116 | 118 |
117 DISALLOW_COPY_AND_ASSIGN(OwnerContentsObserver); | 119 DISALLOW_COPY_AND_ASSIGN(OwnerContentsObserver); |
118 }; | 120 }; |
119 | 121 |
120 // This observer ensures that the GuestViewBase destroys itself when its | 122 // This observer ensures that the GuestViewBase destroys itself if its opening |
lazyboy
2015/06/09 14:19:32
s/opening/opener
paulmeyer
2015/06/09 14:49:42
Done.
| |
121 // embedder goes away. | 123 // WebContents goes away before the GuestViewBase is attached. |
122 class GuestViewBase::OpenerLifetimeObserver : public WebContentsObserver { | 124 class GuestViewBase::OpenerLifetimeObserver : public WebContentsObserver { |
123 public: | 125 public: |
124 OpenerLifetimeObserver(GuestViewBase* guest) | 126 OpenerLifetimeObserver(GuestViewBase* guest) |
125 : WebContentsObserver(guest->GetOpener()->web_contents()), | 127 : WebContentsObserver(guest->GetOpener()->web_contents()), |
126 guest_(guest) {} | 128 guest_(guest) {} |
127 | 129 |
128 ~OpenerLifetimeObserver() override {} | 130 ~OpenerLifetimeObserver() override {} |
129 | 131 |
130 // WebContentsObserver implementation. | 132 // WebContentsObserver implementation. |
131 void WebContentsDestroyed() override { | 133 void WebContentsDestroyed() override { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
311 } | 313 } |
312 | 314 |
313 DispatchOnResizeEvent(guest_size_, new_size); | 315 DispatchOnResizeEvent(guest_size_, new_size); |
314 guest_size_ = new_size; | 316 guest_size_ = new_size; |
315 } | 317 } |
316 | 318 |
317 auto_size_enabled_ = enable_auto_size; | 319 auto_size_enabled_ = enable_auto_size; |
318 } | 320 } |
319 | 321 |
320 // static | 322 // static |
323 void GuestViewBase::CleanUp(int embedder_process_id, int view_instance_id) { | |
324 // TODO(paulmeyer): Add in any general GuestView cleanup work here. | |
325 } | |
326 | |
327 // static | |
321 GuestViewBase* GuestViewBase::FromWebContents(const WebContents* web_contents) { | 328 GuestViewBase* GuestViewBase::FromWebContents(const WebContents* web_contents) { |
322 WebContentsGuestViewMap* guest_map = webcontents_guestview_map.Pointer(); | 329 WebContentsGuestViewMap* guest_map = webcontents_guestview_map.Pointer(); |
323 auto it = guest_map->find(web_contents); | 330 auto it = guest_map->find(web_contents); |
324 return it == guest_map->end() ? nullptr : it->second; | 331 return it == guest_map->end() ? nullptr : it->second; |
325 } | 332 } |
326 | 333 |
327 // static | 334 // static |
328 GuestViewBase* GuestViewBase::From(int owner_process_id, | 335 GuestViewBase* GuestViewBase::From(int owner_process_id, |
329 int guest_instance_id) { | 336 int guest_instance_id) { |
330 auto host = content::RenderProcessHost::FromID(owner_process_id); | 337 auto host = content::RenderProcessHost::FromID(owner_process_id); |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
823 | 830 |
824 auto embedder_zoom_controller = | 831 auto embedder_zoom_controller = |
825 ui_zoom::ZoomController::FromWebContents(owner_web_contents()); | 832 ui_zoom::ZoomController::FromWebContents(owner_web_contents()); |
826 // Chrome Apps do not have a ZoomController. | 833 // Chrome Apps do not have a ZoomController. |
827 if (!embedder_zoom_controller) | 834 if (!embedder_zoom_controller) |
828 return; | 835 return; |
829 embedder_zoom_controller->RemoveObserver(this); | 836 embedder_zoom_controller->RemoveObserver(this); |
830 } | 837 } |
831 | 838 |
832 } // namespace guest_view | 839 } // namespace guest_view |
OLD | NEW |