| 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/renderer_host/web_input_event_aura.h" |
| 23 #include "content/browser/web_contents/aura/gesture_nav_simple.h" | 23 #include "content/browser/web_contents/aura/gesture_nav_simple.h" |
| 24 #include "content/browser/web_contents/aura/image_window_delegate.h" | |
| 25 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" | 24 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" |
| 26 #include "content/browser/web_contents/aura/shadow_layer_delegate.h" | 25 #include "content/browser/web_contents/aura/shadow_layer_delegate.h" |
| 27 #include "content/browser/web_contents/aura/window_slider.h" | 26 #include "content/browser/web_contents/aura/window_slider.h" |
| 28 #include "content/browser/web_contents/touch_editable_impl_aura.h" | 27 #include "content/browser/web_contents/touch_selection_controller_aura_client_im
pl.h" |
| 29 #include "content/browser/web_contents/web_contents_impl.h" | 28 #include "content/browser/web_contents/web_contents_impl.h" |
| 30 #include "content/public/browser/content_browser_client.h" | 29 #include "content/public/browser/content_browser_client.h" |
| 31 #include "content/public/browser/notification_observer.h" | 30 #include "content/public/browser/notification_observer.h" |
| 32 #include "content/public/browser/notification_registrar.h" | 31 #include "content/public/browser/notification_registrar.h" |
| 33 #include "content/public/browser/notification_source.h" | 32 #include "content/public/browser/notification_source.h" |
| 34 #include "content/public/browser/notification_types.h" | 33 #include "content/public/browser/notification_types.h" |
| 35 #include "content/public/browser/overscroll_configuration.h" | 34 #include "content/public/browser/overscroll_configuration.h" |
| 36 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
| 37 #include "content/public/browser/render_widget_host.h" | 36 #include "content/public/browser/render_widget_host.h" |
| 38 #include "content/public/browser/render_widget_host_view.h" | 37 #include "content/public/browser/render_widget_host_view.h" |
| 39 #include "content/public/browser/web_contents_delegate.h" | 38 #include "content/public/browser/web_contents_delegate.h" |
| 40 #include "content/public/browser/web_contents_observer.h" | 39 #include "content/public/browser/web_contents_observer.h" |
| 41 #include "content/public/browser/web_contents_view_delegate.h" | 40 #include "content/public/browser/web_contents_view_delegate.h" |
| 42 #include "content/public/browser/web_drag_dest_delegate.h" | 41 #include "content/public/browser/web_drag_dest_delegate.h" |
| 43 #include "content/public/common/content_client.h" | 42 #include "content/public/common/content_client.h" |
| 44 #include "content/public/common/content_switches.h" | 43 #include "content/public/common/content_switches.h" |
| 45 #include "content/public/common/drop_data.h" | 44 #include "content/public/common/drop_data.h" |
| 46 #include "net/base/filename_util.h" | 45 #include "net/base/filename_util.h" |
| 47 #include "third_party/WebKit/public/web/WebInputEvent.h" | 46 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 48 #include "ui/aura/client/aura_constants.h" | 47 #include "ui/aura/client/aura_constants.h" |
| 49 #include "ui/aura/client/window_tree_client.h" | 48 #include "ui/aura/client/window_tree_client.h" |
| 50 #include "ui/aura/env.h" | 49 #include "ui/aura/env.h" |
| 50 #include "ui/aura/image_window_delegate.h" |
| 51 #include "ui/aura/window.h" | 51 #include "ui/aura/window.h" |
| 52 #include "ui/aura/window_observer.h" | 52 #include "ui/aura/window_observer.h" |
| 53 #include "ui/aura/window_tree_host.h" | 53 #include "ui/aura/window_tree_host.h" |
| 54 #include "ui/aura/window_tree_host_observer.h" | 54 #include "ui/aura/window_tree_host_observer.h" |
| 55 #include "ui/base/clipboard/clipboard.h" | 55 #include "ui/base/clipboard/clipboard.h" |
| 56 #include "ui/base/clipboard/custom_data_helper.h" | 56 #include "ui/base/clipboard/custom_data_helper.h" |
| 57 #include "ui/base/dragdrop/drag_drop_types.h" | 57 #include "ui/base/dragdrop/drag_drop_types.h" |
| 58 #include "ui/base/dragdrop/drag_utils.h" | 58 #include "ui/base/dragdrop/drag_utils.h" |
| 59 #include "ui/base/dragdrop/drop_target_event.h" | 59 #include "ui/base/dragdrop/drop_target_event.h" |
| 60 #include "ui/base/dragdrop/os_exchange_data.h" | 60 #include "ui/base/dragdrop/os_exchange_data.h" |
| 61 #include "ui/base/hit_test.h" | 61 #include "ui/base/hit_test.h" |
| 62 #include "ui/compositor/layer.h" | 62 #include "ui/compositor/layer.h" |
| 63 #include "ui/compositor/scoped_layer_animation_settings.h" | 63 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 64 #include "ui/events/event.h" | 64 #include "ui/events/event.h" |
| 65 #include "ui/events/event_utils.h" | 65 #include "ui/events/event_utils.h" |
| 66 #include "ui/gfx/canvas.h" | 66 #include "ui/gfx/canvas.h" |
| 67 #include "ui/gfx/image/image.h" | 67 #include "ui/gfx/image/image.h" |
| 68 #include "ui/gfx/image/image_png_rep.h" | 68 #include "ui/gfx/image/image_png_rep.h" |
| 69 #include "ui/gfx/image/image_skia.h" | 69 #include "ui/gfx/image/image_skia.h" |
| 70 #include "ui/gfx/screen.h" | 70 #include "ui/gfx/screen.h" |
| 71 #include "ui/touch_selection/touch_selection_controller_aura.h" |
| 71 #include "ui/wm/public/drag_drop_client.h" | 72 #include "ui/wm/public/drag_drop_client.h" |
| 72 #include "ui/wm/public/drag_drop_delegate.h" | 73 #include "ui/wm/public/drag_drop_delegate.h" |
| 73 | 74 |
| 74 namespace content { | 75 namespace content { |
| 75 WebContentsView* CreateWebContentsView( | 76 WebContentsView* CreateWebContentsView( |
| 76 WebContentsImpl* web_contents, | 77 WebContentsImpl* web_contents, |
| 77 WebContentsViewDelegate* delegate, | 78 WebContentsViewDelegate* delegate, |
| 78 RenderViewHostDelegateView** render_view_host_delegate_view) { | 79 RenderViewHostDelegateView** render_view_host_delegate_view) { |
| 79 WebContentsViewAura* rv = new WebContentsViewAura(web_contents, delegate); | 80 WebContentsViewAura* rv = new WebContentsViewAura(web_contents, delegate); |
| 80 *render_view_host_delegate_view = rv; | 81 *render_view_host_delegate_view = rv; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 109 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | 110 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
| 110 rvh ? WebContents::FromRenderViewHost(rvh) : NULL); | 111 rvh ? WebContents::FromRenderViewHost(rvh) : NULL); |
| 111 if (BrowserPluginGuest::IsGuest(web_contents)) | 112 if (BrowserPluginGuest::IsGuest(web_contents)) |
| 112 return NULL; | 113 return NULL; |
| 113 return static_cast<RenderWidgetHostViewAura*>(view); | 114 return static_cast<RenderWidgetHostViewAura*>(view); |
| 114 } | 115 } |
| 115 | 116 |
| 116 // The window delegate for the overscroll window. This redirects trackpad events | 117 // The window delegate for the overscroll window. This redirects trackpad events |
| 117 // to the web-contents window. The delegate destroys itself when the window is | 118 // to the web-contents window. The delegate destroys itself when the window is |
| 118 // destroyed. | 119 // destroyed. |
| 119 class OverscrollWindowDelegate : public ImageWindowDelegate { | 120 class OverscrollWindowDelegate : public aura::ImageWindowDelegate { |
| 120 public: | 121 public: |
| 121 OverscrollWindowDelegate(WebContentsImpl* web_contents, | 122 OverscrollWindowDelegate(WebContentsImpl* web_contents, |
| 122 OverscrollMode overscroll_mode) | 123 OverscrollMode overscroll_mode) |
| 123 : web_contents_(web_contents), | 124 : web_contents_(web_contents), |
| 124 forward_events_(true) { | 125 forward_events_(true) { |
| 125 const NavigationControllerImpl& controller = web_contents->GetController(); | 126 const NavigationControllerImpl& controller = web_contents->GetController(); |
| 126 const NavigationEntryImpl* entry = NULL; | 127 const NavigationEntryImpl* entry = NULL; |
| 127 if (ShouldNavigateForward(controller, overscroll_mode)) { | 128 if (ShouldNavigateForward(controller, overscroll_mode)) { |
| 128 entry = NavigationEntryImpl::FromNavigationEntry( | 129 entry = NavigationEntryImpl::FromNavigationEntry( |
| 129 controller.GetEntryAtOffset(1)); | 130 controller.GetEntryAtOffset(1)); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 } | 612 } |
| 612 #endif | 613 #endif |
| 613 } | 614 } |
| 614 } | 615 } |
| 615 | 616 |
| 616 void OnWindowBoundsChanged(aura::Window* window, | 617 void OnWindowBoundsChanged(aura::Window* window, |
| 617 const gfx::Rect& old_bounds, | 618 const gfx::Rect& old_bounds, |
| 618 const gfx::Rect& new_bounds) override { | 619 const gfx::Rect& new_bounds) override { |
| 619 if (window == host_window_ || window == view_->window_) { | 620 if (window == host_window_ || window == view_->window_) { |
| 620 SendScreenRects(); | 621 SendScreenRects(); |
| 621 if (view_->touch_editable_) | 622 if (old_bounds.origin() != new_bounds.origin()) { |
| 622 view_->touch_editable_->UpdateEditingController(); | 623 ui::TouchSelectionControllerAura* selection_controller = |
| 624 view_->GetSelectionController(); |
| 625 if (selection_controller) |
| 626 selection_controller->OnWindowMoved(); |
| 627 } |
| 623 #if defined(OS_WIN) | 628 #if defined(OS_WIN) |
| 624 } else { | 629 } else { |
| 625 UpdateConstrainedWindows(NULL); | 630 UpdateConstrainedWindows(NULL); |
| 626 #endif | 631 #endif |
| 627 } | 632 } |
| 628 } | 633 } |
| 629 | 634 |
| 630 void OnWindowDestroying(aura::Window* window) override { | 635 void OnWindowDestroying(aura::Window* window) override { |
| 631 if (window == host_window_) { | 636 if (window == host_window_) { |
| 632 host_window_->RemoveObserver(this); | 637 host_window_->RemoveObserver(this); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 WebContentsImpl* web_contents, | 736 WebContentsImpl* web_contents, |
| 732 WebContentsViewDelegate* delegate) | 737 WebContentsViewDelegate* delegate) |
| 733 : web_contents_(web_contents), | 738 : web_contents_(web_contents), |
| 734 delegate_(delegate), | 739 delegate_(delegate), |
| 735 current_drag_op_(blink::WebDragOperationNone), | 740 current_drag_op_(blink::WebDragOperationNone), |
| 736 drag_dest_delegate_(NULL), | 741 drag_dest_delegate_(NULL), |
| 737 current_rvh_for_drag_(NULL), | 742 current_rvh_for_drag_(NULL), |
| 738 overscroll_change_brightness_(false), | 743 overscroll_change_brightness_(false), |
| 739 current_overscroll_gesture_(OVERSCROLL_NONE), | 744 current_overscroll_gesture_(OVERSCROLL_NONE), |
| 740 completed_overscroll_gesture_(OVERSCROLL_NONE), | 745 completed_overscroll_gesture_(OVERSCROLL_NONE), |
| 741 touch_editable_(TouchEditableImplAura::Create()), | |
| 742 is_or_was_visible_(false) { | 746 is_or_was_visible_(false) { |
| 743 } | 747 } |
| 744 | 748 |
| 745 //////////////////////////////////////////////////////////////////////////////// | 749 //////////////////////////////////////////////////////////////////////////////// |
| 746 // WebContentsViewAura, private: | 750 // WebContentsViewAura, private: |
| 747 | 751 |
| 748 WebContentsViewAura::~WebContentsViewAura() { | 752 WebContentsViewAura::~WebContentsViewAura() { |
| 749 if (!window_) | 753 if (!window_) |
| 750 return; | 754 return; |
| 751 | 755 |
| 752 window_observer_.reset(); | 756 window_observer_.reset(); |
| 753 window_->RemoveObserver(this); | 757 window_->RemoveObserver(this); |
| 754 | 758 |
| 755 // Window needs a valid delegate during its destructor, so we explicitly | 759 // Window needs a valid delegate during its destructor, so we explicitly |
| 756 // delete it here. | 760 // delete it here. |
| 757 window_.reset(); | 761 window_.reset(); |
| 758 } | 762 } |
| 759 | 763 |
| 760 void WebContentsViewAura::SetTouchEditableForTest( | |
| 761 TouchEditableImplAura* touch_editable) { | |
| 762 touch_editable_.reset(touch_editable); | |
| 763 AttachTouchEditableToRenderView(); | |
| 764 } | |
| 765 | |
| 766 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { | 764 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { |
| 767 if (web_contents_->GetInterstitialPage()) | 765 if (web_contents_->GetInterstitialPage()) |
| 768 web_contents_->GetInterstitialPage()->SetSize(size); | 766 web_contents_->GetInterstitialPage()->SetSize(size); |
| 769 RenderWidgetHostView* rwhv = | 767 RenderWidgetHostView* rwhv = |
| 770 web_contents_->GetRenderWidgetHostView(); | 768 web_contents_->GetRenderWidgetHostView(); |
| 771 if (rwhv) | 769 if (rwhv) |
| 772 rwhv->SetSize(size); | 770 rwhv->SetSize(size); |
| 773 } | 771 } |
| 774 | 772 |
| 775 void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) { | 773 void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 ratio = 1.f - ratio; | 967 ratio = 1.f - ratio; |
| 970 float brightness = current_overscroll_gesture_ == OVERSCROLL_WEST ? | 968 float brightness = current_overscroll_gesture_ == OVERSCROLL_WEST ? |
| 971 kBrightnessMin + ratio * (kBrightnessMax - kBrightnessMin) : | 969 kBrightnessMin + ratio * (kBrightnessMax - kBrightnessMin) : |
| 972 kBrightnessMax - ratio * (kBrightnessMax - kBrightnessMin); | 970 kBrightnessMax - ratio * (kBrightnessMax - kBrightnessMin); |
| 973 brightness = std::max(kBrightnessMin, brightness); | 971 brightness = std::max(kBrightnessMin, brightness); |
| 974 brightness = std::min(kBrightnessMax, brightness); | 972 brightness = std::min(kBrightnessMax, brightness); |
| 975 aura::Window* window = GetWindowToAnimateForOverscroll(); | 973 aura::Window* window = GetWindowToAnimateForOverscroll(); |
| 976 window->layer()->SetLayerBrightness(brightness); | 974 window->layer()->SetLayerBrightness(brightness); |
| 977 } | 975 } |
| 978 | 976 |
| 979 void WebContentsViewAura::AttachTouchEditableToRenderView() { | |
| 980 if (!touch_editable_) | |
| 981 return; | |
| 982 RenderWidgetHostViewAura* rwhva = ToRenderWidgetHostViewAura( | |
| 983 web_contents_->GetRenderWidgetHostView()); | |
| 984 touch_editable_->AttachToView(rwhva); | |
| 985 } | |
| 986 | |
| 987 void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate( | 977 void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate( |
| 988 float delta_y) { | 978 float delta_y) { |
| 989 if (web_contents_->GetDelegate() && IsScrollEndEffectEnabled()) | 979 if (web_contents_->GetDelegate() && IsScrollEndEffectEnabled()) |
| 990 web_contents_->GetDelegate()->OverscrollUpdate(delta_y); | 980 web_contents_->GetDelegate()->OverscrollUpdate(delta_y); |
| 991 } | 981 } |
| 992 | 982 |
| 983 ui::TouchSelectionControllerAura* |
| 984 WebContentsViewAura::GetSelectionController() { |
| 985 RenderWidgetHostViewAura* view = |
| 986 ToRenderWidgetHostViewAura(web_contents_->GetRenderWidgetHostView()); |
| 987 if (!view) |
| 988 return nullptr; |
| 989 return view->selection_controller(); |
| 990 } |
| 991 |
| 993 //////////////////////////////////////////////////////////////////////////////// | 992 //////////////////////////////////////////////////////////////////////////////// |
| 994 // WebContentsViewAura, WebContentsView implementation: | 993 // WebContentsViewAura, WebContentsView implementation: |
| 995 | 994 |
| 996 gfx::NativeView WebContentsViewAura::GetNativeView() const { | 995 gfx::NativeView WebContentsViewAura::GetNativeView() const { |
| 997 return window_.get(); | 996 return window_.get(); |
| 998 } | 997 } |
| 999 | 998 |
| 1000 gfx::NativeView WebContentsViewAura::GetContentNativeView() const { | 999 gfx::NativeView WebContentsViewAura::GetContentNativeView() const { |
| 1001 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); | 1000 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); |
| 1002 return rwhv ? rwhv->GetNativeView() : NULL; | 1001 return rwhv ? rwhv->GetNativeView() : NULL; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 // this actually is happening (and somebody isn't accidentally creating the | 1121 // this actually is happening (and somebody isn't accidentally creating the |
| 1123 // view twice), we check for the RVH Factory, which will be set when we're | 1122 // view twice), we check for the RVH Factory, which will be set when we're |
| 1124 // making special ones (which go along with the special views). | 1123 // making special ones (which go along with the special views). |
| 1125 DCHECK(RenderViewHostFactory::has_factory()); | 1124 DCHECK(RenderViewHostFactory::has_factory()); |
| 1126 return static_cast<RenderWidgetHostViewBase*>( | 1125 return static_cast<RenderWidgetHostViewBase*>( |
| 1127 render_widget_host->GetView()); | 1126 render_widget_host->GetView()); |
| 1128 } | 1127 } |
| 1129 | 1128 |
| 1130 RenderWidgetHostViewAura* view = | 1129 RenderWidgetHostViewAura* view = |
| 1131 new RenderWidgetHostViewAura(render_widget_host, is_guest_view_hack); | 1130 new RenderWidgetHostViewAura(render_widget_host, is_guest_view_hack); |
| 1131 TouchSelectionControllerAuraClientImpl* selection_controller_client = |
| 1132 new TouchSelectionControllerAuraClientImpl(view); |
| 1133 view->InitSelectionController(selection_controller_client); |
| 1134 |
| 1132 view->InitAsChild(NULL); | 1135 view->InitAsChild(NULL); |
| 1133 GetNativeView()->AddChild(view->GetNativeView()); | 1136 GetNativeView()->AddChild(view->GetNativeView()); |
| 1134 | 1137 |
| 1135 if (navigation_overlay_.get() && navigation_overlay_->has_window()) { | 1138 if (navigation_overlay_.get() && navigation_overlay_->has_window()) { |
| 1136 navigation_overlay_->StartObserving(); | 1139 navigation_overlay_->StartObserving(); |
| 1137 } | 1140 } |
| 1138 | 1141 |
| 1139 RenderWidgetHostImpl* host_impl = | 1142 RenderWidgetHostImpl* host_impl = |
| 1140 RenderWidgetHostImpl::From(render_widget_host); | 1143 RenderWidgetHostImpl::From(render_widget_host); |
| 1141 | 1144 |
| 1142 if (!host_impl->is_hidden()) | 1145 if (!host_impl->is_hidden()) |
| 1143 view->Show(); | 1146 view->Show(); |
| 1144 | 1147 |
| 1145 // We listen to drag drop events in the newly created view's window. | 1148 // We listen to drag drop events in the newly created view's window. |
| 1146 aura::client::SetDragDropDelegate(view->GetNativeView(), this); | 1149 aura::client::SetDragDropDelegate(view->GetNativeView(), this); |
| 1147 | 1150 |
| 1148 if (view->overscroll_controller() && | 1151 if (view->overscroll_controller() && |
| 1149 (!web_contents_->GetDelegate() || | 1152 (!web_contents_->GetDelegate() || |
| 1150 web_contents_->GetDelegate()->CanOverscrollContent())) { | 1153 web_contents_->GetDelegate()->CanOverscrollContent())) { |
| 1151 InstallOverscrollControllerDelegate(view); | 1154 InstallOverscrollControllerDelegate(view); |
| 1152 } | 1155 } |
| 1153 | 1156 |
| 1154 AttachTouchEditableToRenderView(); | |
| 1155 return view; | 1157 return view; |
| 1156 } | 1158 } |
| 1157 | 1159 |
| 1158 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget( | 1160 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget( |
| 1159 RenderWidgetHost* render_widget_host) { | 1161 RenderWidgetHost* render_widget_host) { |
| 1160 return new RenderWidgetHostViewAura(render_widget_host, false); | 1162 return new RenderWidgetHostViewAura(render_widget_host, false); |
| 1161 } | 1163 } |
| 1162 | 1164 |
| 1163 void WebContentsViewAura::SetPageTitle(const base::string16& title) { | 1165 void WebContentsViewAura::SetPageTitle(const base::string16& title) { |
| 1164 window_->SetTitle(title); | 1166 window_->SetTitle(title); |
| 1165 } | 1167 } |
| 1166 | 1168 |
| 1167 void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) { | 1169 void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) { |
| 1168 } | 1170 } |
| 1169 | 1171 |
| 1170 void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) { | 1172 void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) { |
| 1171 if (navigation_overlay_.get() && navigation_overlay_->has_window()) | 1173 if (navigation_overlay_.get() && navigation_overlay_->has_window()) |
| 1172 navigation_overlay_->StartObserving(); | 1174 navigation_overlay_->StartObserving(); |
| 1173 AttachTouchEditableToRenderView(); | |
| 1174 } | 1175 } |
| 1175 | 1176 |
| 1176 void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) { | 1177 void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) { |
| 1177 RenderWidgetHostViewAura* view = | 1178 RenderWidgetHostViewAura* view = |
| 1178 ToRenderWidgetHostViewAura(web_contents_->GetRenderWidgetHostView()); | 1179 ToRenderWidgetHostViewAura(web_contents_->GetRenderWidgetHostView()); |
| 1179 if (view) { | 1180 if (view) { |
| 1180 view->SetOverscrollControllerEnabled(enabled); | 1181 view->SetOverscrollControllerEnabled(enabled); |
| 1181 if (enabled) | 1182 if (enabled) |
| 1182 InstallOverscrollControllerDelegate(view); | 1183 InstallOverscrollControllerDelegate(view); |
| 1183 } | 1184 } |
| 1184 | 1185 |
| 1185 if (!enabled) | 1186 if (!enabled) |
| 1186 navigation_overlay_.reset(); | 1187 navigation_overlay_.reset(); |
| 1187 else if (!navigation_overlay_) | 1188 else if (!navigation_overlay_) |
| 1188 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); | 1189 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); |
| 1189 } | 1190 } |
| 1190 | 1191 |
| 1191 //////////////////////////////////////////////////////////////////////////////// | 1192 //////////////////////////////////////////////////////////////////////////////// |
| 1192 // WebContentsViewAura, RenderViewHostDelegateView implementation: | 1193 // WebContentsViewAura, RenderViewHostDelegateView implementation: |
| 1193 | 1194 |
| 1194 void WebContentsViewAura::ShowContextMenu(RenderFrameHost* render_frame_host, | 1195 void WebContentsViewAura::ShowContextMenu(RenderFrameHost* render_frame_host, |
| 1195 const ContextMenuParams& params) { | 1196 const ContextMenuParams& params) { |
| 1196 if (touch_editable_) { | 1197 ui::TouchSelectionControllerAura* selection_controller = |
| 1197 touch_editable_->EndTouchEditing(false); | 1198 GetSelectionController(); |
| 1198 } | 1199 if (selection_controller) |
| 1200 selection_controller->HideAndDisallowShowingAutomatically(); |
| 1199 if (delegate_) { | 1201 if (delegate_) { |
| 1200 delegate_->ShowContextMenu(render_frame_host, params); | 1202 delegate_->ShowContextMenu(render_frame_host, params); |
| 1201 // WARNING: we may have been deleted during the call to ShowContextMenu(). | 1203 // WARNING: we may have been deleted during the call to ShowContextMenu(). |
| 1202 } | 1204 } |
| 1203 } | 1205 } |
| 1204 | 1206 |
| 1205 void WebContentsViewAura::StartDragging( | 1207 void WebContentsViewAura::StartDragging( |
| 1206 const DropData& drop_data, | 1208 const DropData& drop_data, |
| 1207 blink::WebDragOperationsMask operations, | 1209 blink::WebDragOperationsMask operations, |
| 1208 const gfx::ImageSkia& image, | 1210 const gfx::ImageSkia& image, |
| 1209 const gfx::Vector2d& image_offset, | 1211 const gfx::Vector2d& image_offset, |
| 1210 const DragEventSourceInfo& event_info) { | 1212 const DragEventSourceInfo& event_info) { |
| 1211 aura::Window* root_window = GetNativeView()->GetRootWindow(); | 1213 aura::Window* root_window = GetNativeView()->GetRootWindow(); |
| 1212 if (!aura::client::GetDragDropClient(root_window)) { | 1214 if (!aura::client::GetDragDropClient(root_window)) { |
| 1213 web_contents_->SystemDragEnded(); | 1215 web_contents_->SystemDragEnded(); |
| 1214 return; | 1216 return; |
| 1215 } | 1217 } |
| 1216 | 1218 |
| 1217 if (touch_editable_) | 1219 ui::TouchSelectionControllerAura* selection_controller = |
| 1218 touch_editable_->EndTouchEditing(false); | 1220 GetSelectionController(); |
| 1219 | 1221 if (selection_controller) |
| 1222 selection_controller->HideAndDisallowShowingAutomatically(); |
| 1220 ui::OSExchangeData::Provider* provider = ui::OSExchangeData::CreateProvider(); | 1223 ui::OSExchangeData::Provider* provider = ui::OSExchangeData::CreateProvider(); |
| 1221 PrepareDragData(drop_data, provider, web_contents_); | 1224 PrepareDragData(drop_data, provider, web_contents_); |
| 1222 | 1225 |
| 1223 ui::OSExchangeData data(provider); // takes ownership of |provider|. | 1226 ui::OSExchangeData data(provider); // takes ownership of |provider|. |
| 1224 | 1227 |
| 1225 if (!image.isNull()) | 1228 if (!image.isNull()) |
| 1226 drag_utils::SetDragImageOnDataObject(image, image_offset, &data); | 1229 drag_utils::SetDragImageOnDataObject(image, image_offset, &data); |
| 1227 | 1230 |
| 1228 scoped_ptr<WebDragSourceAura> drag_source( | 1231 scoped_ptr<WebDragSourceAura> drag_source( |
| 1229 new WebDragSourceAura(GetNativeView(), web_contents_)); | 1232 new WebDragSourceAura(GetNativeView(), web_contents_)); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1341 } | 1344 } |
| 1342 | 1345 |
| 1343 void WebContentsViewAura::OnOverscrollModeChange(OverscrollMode old_mode, | 1346 void WebContentsViewAura::OnOverscrollModeChange(OverscrollMode old_mode, |
| 1344 OverscrollMode new_mode) { | 1347 OverscrollMode new_mode) { |
| 1345 // Reset any in-progress overscroll animation first. | 1348 // Reset any in-progress overscroll animation first. |
| 1346 ResetOverscrollTransform(); | 1349 ResetOverscrollTransform(); |
| 1347 | 1350 |
| 1348 if (old_mode == OVERSCROLL_NORTH || old_mode == OVERSCROLL_SOUTH) | 1351 if (old_mode == OVERSCROLL_NORTH || old_mode == OVERSCROLL_SOUTH) |
| 1349 OverscrollUpdateForWebContentsDelegate(0); | 1352 OverscrollUpdateForWebContentsDelegate(0); |
| 1350 | 1353 |
| 1351 if (new_mode != OVERSCROLL_NONE && touch_editable_) | 1354 if (new_mode != OVERSCROLL_NONE) { |
| 1352 touch_editable_->OverscrollStarted(); | 1355 ui::TouchSelectionControllerAura* selection_controller = |
| 1353 | 1356 GetSelectionController(); |
| 1357 if (selection_controller) |
| 1358 selection_controller->OnOverscrollStarted(); |
| 1359 } |
| 1354 if (new_mode == OVERSCROLL_NONE || | 1360 if (new_mode == OVERSCROLL_NONE || |
| 1355 !GetContentNativeView() || | 1361 !GetContentNativeView() || |
| 1356 ((new_mode == OVERSCROLL_EAST || new_mode == OVERSCROLL_WEST) && | 1362 ((new_mode == OVERSCROLL_EAST || new_mode == OVERSCROLL_WEST) && |
| 1357 navigation_overlay_.get() && navigation_overlay_->has_window())) { | 1363 navigation_overlay_.get() && navigation_overlay_->has_window())) { |
| 1358 current_overscroll_gesture_ = OVERSCROLL_NONE; | 1364 current_overscroll_gesture_ = OVERSCROLL_NONE; |
| 1359 } else { | 1365 } else { |
| 1360 aura::Window* target = GetWindowToAnimateForOverscroll(); | 1366 aura::Window* target = GetWindowToAnimateForOverscroll(); |
| 1361 if (target) { | 1367 if (target) { |
| 1362 StopObservingImplicitAnimations(); | 1368 StopObservingImplicitAnimations(); |
| 1363 target->layer()->GetAnimator()->AbortAllAnimations(); | 1369 target->layer()->GetAnimator()->AbortAllAnimations(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1384 | 1390 |
| 1385 if (ShouldNavigateForward(web_contents_->GetController(), | 1391 if (ShouldNavigateForward(web_contents_->GetController(), |
| 1386 completed_overscroll_gesture_)) { | 1392 completed_overscroll_gesture_)) { |
| 1387 web_contents_->GetController().GoForward(); | 1393 web_contents_->GetController().GoForward(); |
| 1388 PrepareOverscrollNavigationOverlay(); | 1394 PrepareOverscrollNavigationOverlay(); |
| 1389 } else if (ShouldNavigateBack(web_contents_->GetController(), | 1395 } else if (ShouldNavigateBack(web_contents_->GetController(), |
| 1390 completed_overscroll_gesture_)) { | 1396 completed_overscroll_gesture_)) { |
| 1391 web_contents_->GetController().GoBack(); | 1397 web_contents_->GetController().GoBack(); |
| 1392 PrepareOverscrollNavigationOverlay(); | 1398 PrepareOverscrollNavigationOverlay(); |
| 1393 } else { | 1399 } else { |
| 1394 if (touch_editable_) | 1400 ui::TouchSelectionControllerAura* selection_controller = |
| 1395 touch_editable_->OverscrollCompleted(); | 1401 GetSelectionController(); |
| 1402 if (selection_controller) |
| 1403 selection_controller->OnOverscrollCompleted(); |
| 1396 } | 1404 } |
| 1397 | 1405 |
| 1398 aura::Window* content = GetContentNativeView(); | 1406 aura::Window* content = GetContentNativeView(); |
| 1399 if (content) { | 1407 if (content) { |
| 1400 content->SetTransform(gfx::Transform()); | 1408 content->SetTransform(gfx::Transform()); |
| 1401 content->layer()->SetLayerBrightness(0.f); | 1409 content->layer()->SetLayerBrightness(0.f); |
| 1402 } | 1410 } |
| 1403 current_overscroll_gesture_ = OVERSCROLL_NONE; | 1411 current_overscroll_gesture_ = OVERSCROLL_NONE; |
| 1404 completed_overscroll_gesture_ = OVERSCROLL_NONE; | 1412 completed_overscroll_gesture_ = OVERSCROLL_NONE; |
| 1405 overscroll_window_.reset(); | 1413 overscroll_window_.reset(); |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1633 if (visible) { | 1641 if (visible) { |
| 1634 if (!web_contents_->should_normally_be_visible()) | 1642 if (!web_contents_->should_normally_be_visible()) |
| 1635 web_contents_->WasShown(); | 1643 web_contents_->WasShown(); |
| 1636 } else { | 1644 } else { |
| 1637 if (web_contents_->should_normally_be_visible()) | 1645 if (web_contents_->should_normally_be_visible()) |
| 1638 web_contents_->WasHidden(); | 1646 web_contents_->WasHidden(); |
| 1639 } | 1647 } |
| 1640 } | 1648 } |
| 1641 | 1649 |
| 1642 } // namespace content | 1650 } // namespace content |
| OLD | NEW |