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

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

Powered by Google App Engine
This is Rietveld 408576698