| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 guest_->Destroy(true); | 142 guest_->Destroy(true); |
| 143 } | 143 } |
| 144 | 144 |
| 145 DISALLOW_COPY_AND_ASSIGN(OwnerContentsObserver); | 145 DISALLOW_COPY_AND_ASSIGN(OwnerContentsObserver); |
| 146 }; | 146 }; |
| 147 | 147 |
| 148 // This observer ensures that the GuestViewBase destroys itself if its opener | 148 // This observer ensures that the GuestViewBase destroys itself if its opener |
| 149 // WebContents goes away before the GuestViewBase is attached. | 149 // WebContents goes away before the GuestViewBase is attached. |
| 150 class GuestViewBase::OpenerLifetimeObserver : public WebContentsObserver { | 150 class GuestViewBase::OpenerLifetimeObserver : public WebContentsObserver { |
| 151 public: | 151 public: |
| 152 OpenerLifetimeObserver(GuestViewBase* guest) | 152 explicit OpenerLifetimeObserver(GuestViewBase* guest) |
| 153 : WebContentsObserver(guest->GetOpener()->web_contents()), | 153 : WebContentsObserver(guest->GetOpener()->web_contents()), |
| 154 guest_(guest) {} | 154 guest_(guest) {} |
| 155 | 155 |
| 156 ~OpenerLifetimeObserver() override {} | 156 ~OpenerLifetimeObserver() override {} |
| 157 | 157 |
| 158 // WebContentsObserver implementation. | 158 // WebContentsObserver implementation. |
| 159 void WebContentsDestroyed() override { | 159 void WebContentsDestroyed() override { |
| 160 if (guest_->attached()) | 160 if (guest_->attached()) |
| 161 return; | 161 return; |
| 162 | 162 |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 params); | 667 params); |
| 668 } | 668 } |
| 669 | 669 |
| 670 bool GuestViewBase::ShouldFocusPageAfterCrash() { | 670 bool GuestViewBase::ShouldFocusPageAfterCrash() { |
| 671 // Focus is managed elsewhere. | 671 // Focus is managed elsewhere. |
| 672 return false; | 672 return false; |
| 673 } | 673 } |
| 674 | 674 |
| 675 bool GuestViewBase::PreHandleGestureEvent(WebContents* source, | 675 bool GuestViewBase::PreHandleGestureEvent(WebContents* source, |
| 676 const blink::WebGestureEvent& event) { | 676 const blink::WebGestureEvent& event) { |
| 677 return event.GetType() == blink::WebGestureEvent::kGesturePinchBegin || | 677 return blink::WebInputEvent::IsPinchGestureEventType(event.GetType()); |
| 678 event.GetType() == blink::WebGestureEvent::kGesturePinchUpdate || | |
| 679 event.GetType() == blink::WebGestureEvent::kGesturePinchEnd; | |
| 680 } | 678 } |
| 681 | 679 |
| 682 void GuestViewBase::UpdatePreferredSize(WebContents* target_web_contents, | 680 void GuestViewBase::UpdatePreferredSize(WebContents* target_web_contents, |
| 683 const gfx::Size& pref_size) { | 681 const gfx::Size& pref_size) { |
| 684 // In theory it's not necessary to check IsPreferredSizeModeEnabled() because | 682 // In theory it's not necessary to check IsPreferredSizeModeEnabled() because |
| 685 // there will only be events if it was enabled in the first place. However, | 683 // there will only be events if it was enabled in the first place. However, |
| 686 // something else may have turned on preferred size mode, so double check. | 684 // something else may have turned on preferred size mode, so double check. |
| 687 DCHECK_EQ(web_contents(), target_web_contents); | 685 DCHECK_EQ(web_contents(), target_web_contents); |
| 688 if (IsPreferredSizeModeEnabled()) { | 686 if (IsPreferredSizeModeEnabled()) { |
| 689 OnPreferredSizeChanged(pref_size); | 687 OnPreferredSizeChanged(pref_size); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 | 886 |
| 889 void GuestViewBase::UpdateGuestSize(const gfx::Size& new_size, | 887 void GuestViewBase::UpdateGuestSize(const gfx::Size& new_size, |
| 890 bool due_to_auto_resize) { | 888 bool due_to_auto_resize) { |
| 891 if (due_to_auto_resize) | 889 if (due_to_auto_resize) |
| 892 GuestSizeChangedDueToAutoSize(guest_size_, new_size); | 890 GuestSizeChangedDueToAutoSize(guest_size_, new_size); |
| 893 DispatchOnResizeEvent(guest_size_, new_size); | 891 DispatchOnResizeEvent(guest_size_, new_size); |
| 894 guest_size_ = new_size; | 892 guest_size_ = new_size; |
| 895 } | 893 } |
| 896 | 894 |
| 897 } // namespace guest_view | 895 } // namespace guest_view |
| OLD | NEW |