OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 12 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
13 #include "content/browser/download/drag_download_util.h" | 13 #include "content/browser/download/drag_download_util.h" |
14 #include "content/browser/frame_host/interstitial_page_impl.h" | 14 #include "content/browser/frame_host/interstitial_page_impl.h" |
15 #include "content/browser/frame_host/navigation_entry_impl.h" | 15 #include "content/browser/frame_host/navigation_entry_impl.h" |
16 #include "content/browser/renderer_host/dip_util.h" | 16 #include "content/browser/renderer_host/dip_util.h" |
17 #include "content/browser/renderer_host/overscroll_controller.h" | 17 #include "content/browser/renderer_host/overscroll_controller.h" |
18 #include "content/browser/renderer_host/render_view_host_factory.h" | 18 #include "content/browser/renderer_host/render_view_host_factory.h" |
19 #include "content/browser/renderer_host/render_view_host_impl.h" | 19 #include "content/browser/renderer_host/render_view_host_impl.h" |
20 #include "content/browser/renderer_host/render_widget_host_impl.h" | 20 #include "content/browser/renderer_host/render_widget_host_impl.h" |
21 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 21 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 22 #include "content/browser/renderer_host/web_input_event_aura.h" |
22 #include "content/browser/web_contents/aura/gesture_nav_simple.h" | 23 #include "content/browser/web_contents/aura/gesture_nav_simple.h" |
23 #include "content/browser/web_contents/aura/image_window_delegate.h" | 24 #include "content/browser/web_contents/aura/image_window_delegate.h" |
24 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" | 25 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" |
25 #include "content/browser/web_contents/aura/shadow_layer_delegate.h" | 26 #include "content/browser/web_contents/aura/shadow_layer_delegate.h" |
26 #include "content/browser/web_contents/aura/window_slider.h" | 27 #include "content/browser/web_contents/aura/window_slider.h" |
27 #include "content/browser/web_contents/touch_editable_impl_aura.h" | 28 #include "content/browser/web_contents/touch_editable_impl_aura.h" |
28 #include "content/browser/web_contents/web_contents_impl.h" | 29 #include "content/browser/web_contents/web_contents_impl.h" |
29 #include "content/public/browser/content_browser_client.h" | 30 #include "content/public/browser/content_browser_client.h" |
30 #include "content/public/browser/notification_observer.h" | 31 #include "content/public/browser/notification_observer.h" |
31 #include "content/public/browser/notification_registrar.h" | 32 #include "content/public/browser/notification_registrar.h" |
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 return; | 804 return; |
804 } | 805 } |
805 view->overscroll_controller()->set_delegate(this); | 806 view->overscroll_controller()->set_delegate(this); |
806 if (!navigation_overlay_) | 807 if (!navigation_overlay_) |
807 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); | 808 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); |
808 } | 809 } |
809 | 810 |
810 void WebContentsViewAura::PrepareOverscrollWindow() { | 811 void WebContentsViewAura::PrepareOverscrollWindow() { |
811 // If there is an existing |overscroll_window_| which is in the middle of an | 812 // If there is an existing |overscroll_window_| which is in the middle of an |
812 // animation, then destroying the window here causes the animation to be | 813 // animation, then destroying the window here causes the animation to be |
813 // completed immidiately, which triggers |OnImplicitAnimationsCompleted()| | 814 // completed immediately, which triggers |OnImplicitAnimationsCompleted()| |
814 // callback, and that tries to reset |overscroll_window_| again, causing a | 815 // callback, and that tries to reset |overscroll_window_| again, causing a |
815 // double-free. So use a temporary variable here. | 816 // double-free. So use a temporary variable here. |
816 if (overscroll_window_) { | 817 if (overscroll_window_) { |
817 base::AutoReset<OverscrollMode> reset_state(¤t_overscroll_gesture_, | 818 base::AutoReset<OverscrollMode> reset_state(¤t_overscroll_gesture_, |
818 current_overscroll_gesture_); | 819 current_overscroll_gesture_); |
819 scoped_ptr<aura::Window> reset_window(overscroll_window_.release()); | 820 scoped_ptr<aura::Window> reset_window(overscroll_window_.release()); |
820 } | 821 } |
821 | 822 |
822 OverscrollWindowDelegate* overscroll_delegate = new OverscrollWindowDelegate( | 823 OverscrollWindowDelegate* overscroll_delegate = new OverscrollWindowDelegate( |
823 web_contents_, | 824 web_contents_, |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 } | 1263 } |
1263 | 1264 |
1264 void WebContentsViewAura::TakeFocus(bool reverse) { | 1265 void WebContentsViewAura::TakeFocus(bool reverse) { |
1265 if (web_contents_->GetDelegate() && | 1266 if (web_contents_->GetDelegate() && |
1266 !web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && | 1267 !web_contents_->GetDelegate()->TakeFocus(web_contents_, reverse) && |
1267 delegate_.get()) { | 1268 delegate_.get()) { |
1268 delegate_->TakeFocus(reverse); | 1269 delegate_->TakeFocus(reverse); |
1269 } | 1270 } |
1270 } | 1271 } |
1271 | 1272 |
| 1273 void WebContentsViewAura::ShowDisambiguationPopup( |
| 1274 const gfx::Rect& target_rect, |
| 1275 const SkBitmap& zoomed_bitmap, |
| 1276 const base::Callback<void(ui::GestureEvent*)>& gesture_cb, |
| 1277 const base::Callback<void(ui::MouseEvent*)>& mouse_cb) { |
| 1278 if (delegate_) { |
| 1279 delegate_->ShowDisambiguationPopup(target_rect, zoomed_bitmap, |
| 1280 window_.get(), gesture_cb, mouse_cb); |
| 1281 } |
| 1282 } |
| 1283 |
| 1284 void WebContentsViewAura::HideDisambiguationPopup() { |
| 1285 if (delegate_) |
| 1286 delegate_->HideDisambiguationPopup(); |
| 1287 } |
| 1288 |
1272 //////////////////////////////////////////////////////////////////////////////// | 1289 //////////////////////////////////////////////////////////////////////////////// |
1273 // WebContentsViewAura, OverscrollControllerDelegate implementation: | 1290 // WebContentsViewAura, OverscrollControllerDelegate implementation: |
1274 | 1291 |
1275 gfx::Rect WebContentsViewAura::GetVisibleBounds() const { | 1292 gfx::Rect WebContentsViewAura::GetVisibleBounds() const { |
1276 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 1293 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
1277 if (!rwhv || !rwhv->IsShowing()) | 1294 if (!rwhv || !rwhv->IsShowing()) |
1278 return gfx::Rect(); | 1295 return gfx::Rect(); |
1279 | 1296 |
1280 return rwhv->GetViewBounds(); | 1297 return rwhv->GetViewBounds(); |
1281 } | 1298 } |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 if (visible) { | 1628 if (visible) { |
1612 if (!web_contents_->should_normally_be_visible()) | 1629 if (!web_contents_->should_normally_be_visible()) |
1613 web_contents_->WasShown(); | 1630 web_contents_->WasShown(); |
1614 } else { | 1631 } else { |
1615 if (web_contents_->should_normally_be_visible()) | 1632 if (web_contents_->should_normally_be_visible()) |
1616 web_contents_->WasHidden(); | 1633 web_contents_->WasHidden(); |
1617 } | 1634 } |
1618 } | 1635 } |
1619 | 1636 |
1620 } // namespace content | 1637 } // namespace content |
OLD | NEW |