Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(880)

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 291003002: Move OverscrollController to RenderWidgetHostViewAura (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
752 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); 752 RenderViewHost* rvh = web_contents_->GetRenderViewHost();
753 aura::Window* window = rvh->GetView()->GetNativeView(); 753 aura::Window* window = rvh->GetView()->GetNativeView();
754 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); 754 aura::Window::ConvertPointToTarget(root_window, window, &client_loc);
755 if (!web_contents_) 755 if (!web_contents_)
756 return; 756 return;
757 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), 757 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(),
758 screen_loc.x(), screen_loc.y(), ops); 758 screen_loc.x(), screen_loc.y(), ops);
759 } 759 }
760 760
761 void WebContentsViewAura::InstallOverscrollControllerDelegate( 761 void WebContentsViewAura::InstallOverscrollControllerDelegate(
762 RenderWidgetHostImpl* host) { 762 RenderWidgetHostViewAura* view) {
763 const std::string value = CommandLine::ForCurrentProcess()-> 763 const std::string value = CommandLine::ForCurrentProcess()->
764 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); 764 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation);
765 if (value == "0") { 765 if (value == "0") {
766 navigation_overlay_.reset(); 766 navigation_overlay_.reset();
767 return; 767 return;
768 } 768 }
769 if (value == "2") { 769 if (value == "2") {
770 navigation_overlay_.reset(); 770 navigation_overlay_.reset();
771 if (!gesture_nav_simple_) 771 if (!gesture_nav_simple_)
772 gesture_nav_simple_.reset(new GestureNavSimple(web_contents_)); 772 gesture_nav_simple_.reset(new GestureNavSimple(web_contents_));
773 host->overscroll_controller()->set_delegate(gesture_nav_simple_.get()); 773 view->overscroll_controller()->set_delegate(gesture_nav_simple_.get());
774 return; 774 return;
775 } 775 }
776 host->overscroll_controller()->set_delegate(this); 776 view->overscroll_controller()->set_delegate(this);
777 if (!navigation_overlay_) 777 if (!navigation_overlay_)
778 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); 778 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_));
779 } 779 }
780 780
781 void WebContentsViewAura::PrepareOverscrollWindow() { 781 void WebContentsViewAura::PrepareOverscrollWindow() {
782 // If there is an existing |overscroll_window_| which is in the middle of an 782 // If there is an existing |overscroll_window_| which is in the middle of an
783 // animation, then destroying the window here causes the animation to be 783 // animation, then destroying the window here causes the animation to be
784 // completed immidiately, which triggers |OnImplicitAnimationsCompleted()| 784 // completed immidiately, which triggers |OnImplicitAnimationsCompleted()|
785 // callback, and that tries to reset |overscroll_window_| again, causing a 785 // callback, and that tries to reset |overscroll_window_| again, causing a
786 // double-free. So use a temporary variable here. 786 // double-free. So use a temporary variable here.
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 // During testing, the view will already be set up in most cases to the 1084 // During testing, the view will already be set up in most cases to the
1085 // test view, so we don't want to clobber it with a real one. To verify that 1085 // test view, so we don't want to clobber it with a real one. To verify that
1086 // this actually is happening (and somebody isn't accidentally creating the 1086 // this actually is happening (and somebody isn't accidentally creating the
1087 // view twice), we check for the RVH Factory, which will be set when we're 1087 // view twice), we check for the RVH Factory, which will be set when we're
1088 // making special ones (which go along with the special views). 1088 // making special ones (which go along with the special views).
1089 DCHECK(RenderViewHostFactory::has_factory()); 1089 DCHECK(RenderViewHostFactory::has_factory());
1090 return static_cast<RenderWidgetHostViewBase*>( 1090 return static_cast<RenderWidgetHostViewBase*>(
1091 render_widget_host->GetView()); 1091 render_widget_host->GetView());
1092 } 1092 }
1093 1093
1094 RenderWidgetHostViewBase* view = new RenderWidgetHostViewAura( 1094 RenderWidgetHostViewAura* view =
1095 render_widget_host); 1095 new RenderWidgetHostViewAura(render_widget_host);
1096 view->InitAsChild(NULL); 1096 view->InitAsChild(NULL);
1097 GetNativeView()->AddChild(view->GetNativeView()); 1097 GetNativeView()->AddChild(view->GetNativeView());
1098 1098
1099 if (navigation_overlay_.get() && navigation_overlay_->has_window()) { 1099 if (navigation_overlay_.get() && navigation_overlay_->has_window()) {
1100 navigation_overlay_->StartObserving(); 1100 navigation_overlay_->StartObserving();
1101 } 1101 }
1102 1102
1103 RenderWidgetHostImpl* host_impl = 1103 RenderWidgetHostImpl* host_impl =
1104 RenderWidgetHostImpl::From(render_widget_host); 1104 RenderWidgetHostImpl::From(render_widget_host);
1105 1105
1106 if (!host_impl->is_hidden()) 1106 if (!host_impl->is_hidden())
1107 view->Show(); 1107 view->Show();
1108 1108
1109 // We listen to drag drop events in the newly created view's window. 1109 // We listen to drag drop events in the newly created view's window.
1110 aura::client::SetDragDropDelegate(view->GetNativeView(), this); 1110 aura::client::SetDragDropDelegate(view->GetNativeView(), this);
1111 1111
1112 if (host_impl->overscroll_controller() && 1112 if (view->overscroll_controller() &&
1113 (!web_contents_->GetDelegate() || 1113 (!web_contents_->GetDelegate() ||
1114 web_contents_->GetDelegate()->CanOverscrollContent())) { 1114 web_contents_->GetDelegate()->CanOverscrollContent())) {
1115 InstallOverscrollControllerDelegate(host_impl); 1115 InstallOverscrollControllerDelegate(view);
1116 } 1116 }
1117 1117
1118 AttachTouchEditableToRenderView(); 1118 AttachTouchEditableToRenderView();
1119 return view; 1119 return view;
1120 } 1120 }
1121 1121
1122 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget( 1122 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget(
1123 RenderWidgetHost* render_widget_host) { 1123 RenderWidgetHost* render_widget_host) {
1124 return new RenderWidgetHostViewAura(render_widget_host); 1124 return new RenderWidgetHostViewAura(render_widget_host);
1125 } 1125 }
1126 1126
1127 void WebContentsViewAura::SetPageTitle(const base::string16& title) { 1127 void WebContentsViewAura::SetPageTitle(const base::string16& title) {
1128 window_->set_title(title); 1128 window_->set_title(title);
1129 } 1129 }
1130 1130
1131 void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) { 1131 void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) {
1132 } 1132 }
1133 1133
1134 void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) { 1134 void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) {
1135 if (navigation_overlay_.get() && navigation_overlay_->has_window()) 1135 if (navigation_overlay_.get() && navigation_overlay_->has_window())
1136 navigation_overlay_->StartObserving(); 1136 navigation_overlay_->StartObserving();
1137 AttachTouchEditableToRenderView(); 1137 AttachTouchEditableToRenderView();
1138 } 1138 }
1139 1139
1140 void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) { 1140 void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) {
1141 RenderViewHostImpl* host = static_cast<RenderViewHostImpl*>( 1141 RenderWidgetHostViewAura* view =
1142 web_contents_->GetRenderViewHost()); 1142 ToRenderWidgetHostViewAura(web_contents_->GetRenderWidgetHostView());
1143 if (host) { 1143 if (view) {
1144 host->SetOverscrollControllerEnabled(enabled); 1144 view->SetOverscrollControllerEnabled(enabled);
1145 if (enabled) 1145 if (enabled)
1146 InstallOverscrollControllerDelegate(host); 1146 InstallOverscrollControllerDelegate(view);
1147 } 1147 }
1148 1148
1149 if (!enabled) 1149 if (!enabled)
1150 navigation_overlay_.reset(); 1150 navigation_overlay_.reset();
1151 else if (!navigation_overlay_) 1151 else if (!navigation_overlay_)
1152 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); 1152 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_));
1153 } 1153 }
1154 1154
1155 //////////////////////////////////////////////////////////////////////////////// 1155 ////////////////////////////////////////////////////////////////////////////////
1156 // WebContentsViewAura, RenderViewHostDelegateView implementation: 1156 // WebContentsViewAura, RenderViewHostDelegateView implementation:
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 event.location(), 1547 event.location(),
1548 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), 1548 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(),
1549 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); 1549 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags()));
1550 if (drag_dest_delegate_) 1550 if (drag_dest_delegate_)
1551 drag_dest_delegate_->OnDrop(); 1551 drag_dest_delegate_->OnDrop();
1552 current_drop_data_.reset(); 1552 current_drop_data_.reset();
1553 return ConvertFromWeb(current_drag_op_); 1553 return ConvertFromWeb(current_drag_op_);
1554 } 1554 }
1555 1555
1556 } // namespace content 1556 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698