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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 guest_host_(nullptr), | 152 guest_host_(nullptr), |
153 auto_size_enabled_(false), | 153 auto_size_enabled_(false), |
154 is_full_page_plugin_(false), | 154 is_full_page_plugin_(false), |
155 guest_proxy_routing_id_(MSG_ROUTING_NONE), | 155 guest_proxy_routing_id_(MSG_ROUTING_NONE), |
156 weak_ptr_factory_(this) { | 156 weak_ptr_factory_(this) { |
157 owner_host_ = GuestViewManager::FromBrowserContext(browser_context_)-> | 157 owner_host_ = GuestViewManager::FromBrowserContext(browser_context_)-> |
158 IsOwnedByExtension(this) ? | 158 IsOwnedByExtension(this) ? |
159 owner_web_contents->GetLastCommittedURL().host() : std::string(); | 159 owner_web_contents->GetLastCommittedURL().host() : std::string(); |
160 } | 160 } |
161 | 161 |
| 162 GuestViewBase::~GuestViewBase() {} |
| 163 |
162 void GuestViewBase::Init(const base::DictionaryValue& create_params, | 164 void GuestViewBase::Init(const base::DictionaryValue& create_params, |
163 const WebContentsCreatedCallback& callback) { | 165 const WebContentsCreatedCallback& callback) { |
164 if (initialized_) | 166 if (initialized_) |
165 return; | 167 return; |
166 initialized_ = true; | 168 initialized_ = true; |
167 | 169 |
168 if (!GuestViewManager::FromBrowserContext(browser_context_)-> | 170 if (!GuestViewManager::FromBrowserContext(browser_context_)-> |
169 IsGuestAvailableToContext(this)) { | 171 IsGuestAvailableToContext(this)) { |
170 // The derived class did not create a WebContents so this class serves no | 172 // The derived class did not create a WebContents so this class serves no |
171 // purpose. Let's self-destruct. | 173 // purpose. Let's self-destruct. |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 } | 402 } |
401 | 403 |
402 void GuestViewBase::DidDetach() { | 404 void GuestViewBase::DidDetach() { |
403 GuestViewManager::FromBrowserContext(browser_context_)->DetachGuest(this); | 405 GuestViewManager::FromBrowserContext(browser_context_)->DetachGuest(this); |
404 StopTrackingEmbedderZoomLevel(); | 406 StopTrackingEmbedderZoomLevel(); |
405 owner_web_contents()->Send(new GuestViewMsg_GuestDetached( | 407 owner_web_contents()->Send(new GuestViewMsg_GuestDetached( |
406 element_instance_id_)); | 408 element_instance_id_)); |
407 element_instance_id_ = kInstanceIDNone; | 409 element_instance_id_ = kInstanceIDNone; |
408 } | 410 } |
409 | 411 |
410 bool GuestViewBase::Find(int request_id, | 412 bool GuestViewBase::HandleFindForEmbedder( |
411 const base::string16& search_text, | 413 int request_id, |
412 const blink::WebFindOptions& options) { | 414 const base::string16& search_text, |
| 415 const blink::WebFindOptions& options) { |
413 if (ShouldHandleFindRequestsForEmbedder()) { | 416 if (ShouldHandleFindRequestsForEmbedder()) { |
414 web_contents()->Find(request_id, search_text, options); | 417 web_contents()->Find(request_id, search_text, options); |
415 return true; | 418 return true; |
416 } | 419 } |
417 return false; | 420 return false; |
418 } | 421 } |
419 | 422 |
420 bool GuestViewBase::StopFinding(content::StopFindAction action) { | 423 bool GuestViewBase::HandleStopFindingForEmbedder( |
| 424 content::StopFindAction action) { |
421 if (ShouldHandleFindRequestsForEmbedder()) { | 425 if (ShouldHandleFindRequestsForEmbedder()) { |
422 web_contents()->StopFinding(action); | 426 web_contents()->StopFinding(action); |
423 return true; | 427 return true; |
424 } | 428 } |
425 return false; | 429 return false; |
426 } | 430 } |
427 | 431 |
428 WebContents* GuestViewBase::GetOwnerWebContents() const { | 432 WebContents* GuestViewBase::GetOwnerWebContents() const { |
429 return owner_web_contents_; | 433 return owner_web_contents_; |
430 } | 434 } |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 attached() && embedder_web_contents()->GetDelegate()) { | 698 attached() && embedder_web_contents()->GetDelegate()) { |
695 embedder_web_contents()->GetDelegate()->FindReply(embedder_web_contents(), | 699 embedder_web_contents()->GetDelegate()->FindReply(embedder_web_contents(), |
696 request_id, | 700 request_id, |
697 number_of_matches, | 701 number_of_matches, |
698 selection_rect, | 702 selection_rect, |
699 active_match_ordinal, | 703 active_match_ordinal, |
700 final_update); | 704 final_update); |
701 } | 705 } |
702 } | 706 } |
703 | 707 |
704 GuestViewBase::~GuestViewBase() { | |
705 } | |
706 | |
707 void GuestViewBase::OnZoomChanged( | 708 void GuestViewBase::OnZoomChanged( |
708 const ui_zoom::ZoomController::ZoomChangedEventData& data) { | 709 const ui_zoom::ZoomController::ZoomChangedEventData& data) { |
709 if (data.web_contents == embedder_web_contents()) { | 710 if (data.web_contents == embedder_web_contents()) { |
710 // The embedder's zoom level has changed. | 711 // The embedder's zoom level has changed. |
711 auto guest_zoom_controller = | 712 auto guest_zoom_controller = |
712 ui_zoom::ZoomController::FromWebContents(web_contents()); | 713 ui_zoom::ZoomController::FromWebContents(web_contents()); |
713 if (content::ZoomValuesEqual(data.new_zoom_level, | 714 if (content::ZoomValuesEqual(data.new_zoom_level, |
714 guest_zoom_controller->GetZoomLevel())) { | 715 guest_zoom_controller->GetZoomLevel())) { |
715 return; | 716 return; |
716 } | 717 } |
717 // When the embedder's zoom level doesn't match the guest's, then update the | 718 // When the embedder's zoom level doesn't match the guest's, then update the |
718 // guest's zoom level to match. | 719 // guest's zoom level to match. |
719 guest_zoom_controller->SetZoomLevel(data.new_zoom_level); | 720 guest_zoom_controller->SetZoomLevel(data.new_zoom_level); |
720 | |
721 EmbedderZoomChanged(data.old_zoom_level, data.new_zoom_level); | |
722 return; | 721 return; |
723 } | 722 } |
724 | 723 |
725 if (data.web_contents == web_contents()) { | 724 if (data.web_contents == web_contents()) { |
726 // The guest's zoom level has changed. | 725 // The guest's zoom level has changed. |
727 GuestZoomChanged(data.old_zoom_level, data.new_zoom_level); | 726 GuestZoomChanged(data.old_zoom_level, data.new_zoom_level); |
728 } | 727 } |
729 } | 728 } |
730 | 729 |
731 void GuestViewBase::DispatchEventToGuestProxy(GuestViewEvent* event) { | 730 void GuestViewBase::DispatchEventToGuestProxy(GuestViewEvent* event) { |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 | 863 |
865 void GuestViewBase::UpdateGuestSize(const gfx::Size& new_size, | 864 void GuestViewBase::UpdateGuestSize(const gfx::Size& new_size, |
866 bool due_to_auto_resize) { | 865 bool due_to_auto_resize) { |
867 if (due_to_auto_resize) | 866 if (due_to_auto_resize) |
868 GuestSizeChangedDueToAutoSize(guest_size_, new_size); | 867 GuestSizeChangedDueToAutoSize(guest_size_, new_size); |
869 DispatchOnResizeEvent(guest_size_, new_size); | 868 DispatchOnResizeEvent(guest_size_, new_size); |
870 guest_size_ = new_size; | 869 guest_size_ = new_size; |
871 } | 870 } |
872 | 871 |
873 } // namespace guest_view | 872 } // namespace guest_view |
OLD | NEW |