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/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); | 761 RenderViewHost* rvh = web_contents_->GetRenderViewHost(); |
762 aura::Window* window = rvh->GetView()->GetNativeView(); | 762 aura::Window* window = rvh->GetView()->GetNativeView(); |
763 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); | 763 aura::Window::ConvertPointToTarget(root_window, window, &client_loc); |
764 if (!web_contents_) | 764 if (!web_contents_) |
765 return; | 765 return; |
766 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), | 766 web_contents_->DragSourceEndedAt(client_loc.x(), client_loc.y(), |
767 screen_loc.x(), screen_loc.y(), ops); | 767 screen_loc.x(), screen_loc.y(), ops); |
768 } | 768 } |
769 | 769 |
770 void WebContentsViewAura::InstallOverscrollControllerDelegate( | 770 void WebContentsViewAura::InstallOverscrollControllerDelegate( |
771 RenderWidgetHostImpl* host) { | 771 RenderWidgetHostViewAura* view) { |
772 const std::string value = CommandLine::ForCurrentProcess()-> | 772 const std::string value = CommandLine::ForCurrentProcess()-> |
773 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); | 773 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation); |
774 if (value == "0") { | 774 if (value == "0") { |
775 navigation_overlay_.reset(); | 775 navigation_overlay_.reset(); |
776 return; | 776 return; |
777 } | 777 } |
778 if (value == "2") { | 778 if (value == "2") { |
779 navigation_overlay_.reset(); | 779 navigation_overlay_.reset(); |
780 if (!gesture_nav_simple_) | 780 if (!gesture_nav_simple_) |
781 gesture_nav_simple_.reset(new GestureNavSimple(web_contents_)); | 781 gesture_nav_simple_.reset(new GestureNavSimple(web_contents_)); |
782 host->overscroll_controller()->set_delegate(gesture_nav_simple_.get()); | 782 view->overscroll_controller()->set_delegate(gesture_nav_simple_.get()); |
783 return; | 783 return; |
784 } | 784 } |
785 host->overscroll_controller()->set_delegate(this); | 785 view->overscroll_controller()->set_delegate(this); |
786 if (!navigation_overlay_) | 786 if (!navigation_overlay_) |
787 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); | 787 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); |
788 } | 788 } |
789 | 789 |
790 void WebContentsViewAura::PrepareOverscrollWindow() { | 790 void WebContentsViewAura::PrepareOverscrollWindow() { |
791 // If there is an existing |overscroll_window_| which is in the middle of an | 791 // If there is an existing |overscroll_window_| which is in the middle of an |
792 // animation, then destroying the window here causes the animation to be | 792 // animation, then destroying the window here causes the animation to be |
793 // completed immidiately, which triggers |OnImplicitAnimationsCompleted()| | 793 // completed immidiately, which triggers |OnImplicitAnimationsCompleted()| |
794 // callback, and that tries to reset |overscroll_window_| again, causing a | 794 // callback, and that tries to reset |overscroll_window_| again, causing a |
795 // double-free. So use a temporary variable here. | 795 // double-free. So use a temporary variable here. |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 // During testing, the view will already be set up in most cases to the | 1094 // During testing, the view will already be set up in most cases to the |
1095 // test view, so we don't want to clobber it with a real one. To verify that | 1095 // test view, so we don't want to clobber it with a real one. To verify that |
1096 // this actually is happening (and somebody isn't accidentally creating the | 1096 // this actually is happening (and somebody isn't accidentally creating the |
1097 // view twice), we check for the RVH Factory, which will be set when we're | 1097 // view twice), we check for the RVH Factory, which will be set when we're |
1098 // making special ones (which go along with the special views). | 1098 // making special ones (which go along with the special views). |
1099 DCHECK(RenderViewHostFactory::has_factory()); | 1099 DCHECK(RenderViewHostFactory::has_factory()); |
1100 return static_cast<RenderWidgetHostViewBase*>( | 1100 return static_cast<RenderWidgetHostViewBase*>( |
1101 render_widget_host->GetView()); | 1101 render_widget_host->GetView()); |
1102 } | 1102 } |
1103 | 1103 |
1104 RenderWidgetHostViewBase* view = new RenderWidgetHostViewAura( | 1104 RenderWidgetHostViewAura* view = |
1105 render_widget_host); | 1105 new RenderWidgetHostViewAura(render_widget_host); |
1106 view->InitAsChild(NULL); | 1106 view->InitAsChild(NULL); |
1107 GetNativeView()->AddChild(view->GetNativeView()); | 1107 GetNativeView()->AddChild(view->GetNativeView()); |
1108 | 1108 |
1109 if (navigation_overlay_.get() && navigation_overlay_->has_window()) { | 1109 if (navigation_overlay_.get() && navigation_overlay_->has_window()) { |
1110 navigation_overlay_->StartObserving(); | 1110 navigation_overlay_->StartObserving(); |
1111 } | 1111 } |
1112 | 1112 |
1113 RenderWidgetHostImpl* host_impl = | 1113 RenderWidgetHostImpl* host_impl = |
1114 RenderWidgetHostImpl::From(render_widget_host); | 1114 RenderWidgetHostImpl::From(render_widget_host); |
1115 | 1115 |
1116 if (!host_impl->is_hidden()) | 1116 if (!host_impl->is_hidden()) |
1117 view->Show(); | 1117 view->Show(); |
1118 | 1118 |
1119 // We listen to drag drop events in the newly created view's window. | 1119 // We listen to drag drop events in the newly created view's window. |
1120 aura::client::SetDragDropDelegate(view->GetNativeView(), this); | 1120 aura::client::SetDragDropDelegate(view->GetNativeView(), this); |
1121 | 1121 |
1122 if (host_impl->overscroll_controller() && | 1122 if (view->overscroll_controller() && |
1123 (!web_contents_->GetDelegate() || | 1123 (!web_contents_->GetDelegate() || |
1124 web_contents_->GetDelegate()->CanOverscrollContent())) { | 1124 web_contents_->GetDelegate()->CanOverscrollContent())) { |
1125 InstallOverscrollControllerDelegate(host_impl); | 1125 InstallOverscrollControllerDelegate(view); |
1126 } | 1126 } |
1127 | 1127 |
1128 AttachTouchEditableToRenderView(); | 1128 AttachTouchEditableToRenderView(); |
1129 return view; | 1129 return view; |
1130 } | 1130 } |
1131 | 1131 |
1132 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget( | 1132 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget( |
1133 RenderWidgetHost* render_widget_host) { | 1133 RenderWidgetHost* render_widget_host) { |
1134 return new RenderWidgetHostViewAura(render_widget_host); | 1134 return new RenderWidgetHostViewAura(render_widget_host); |
1135 } | 1135 } |
1136 | 1136 |
1137 void WebContentsViewAura::SetPageTitle(const base::string16& title) { | 1137 void WebContentsViewAura::SetPageTitle(const base::string16& title) { |
1138 window_->set_title(title); | 1138 window_->set_title(title); |
1139 } | 1139 } |
1140 | 1140 |
1141 void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) { | 1141 void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) { |
1142 } | 1142 } |
1143 | 1143 |
1144 void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) { | 1144 void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) { |
1145 if (navigation_overlay_.get() && navigation_overlay_->has_window()) | 1145 if (navigation_overlay_.get() && navigation_overlay_->has_window()) |
1146 navigation_overlay_->StartObserving(); | 1146 navigation_overlay_->StartObserving(); |
1147 AttachTouchEditableToRenderView(); | 1147 AttachTouchEditableToRenderView(); |
1148 } | 1148 } |
1149 | 1149 |
1150 void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) { | 1150 void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) { |
1151 RenderViewHostImpl* host = static_cast<RenderViewHostImpl*>( | 1151 RenderWidgetHostViewAura* view = |
1152 web_contents_->GetRenderViewHost()); | 1152 ToRenderWidgetHostViewAura(web_contents_->GetRenderWidgetHostView()); |
1153 if (host) { | 1153 if (view) { |
1154 host->SetOverscrollControllerEnabled(enabled); | 1154 view->SetOverscrollControllerEnabled(enabled); |
1155 if (enabled) | 1155 if (enabled) |
1156 InstallOverscrollControllerDelegate(host); | 1156 InstallOverscrollControllerDelegate(view); |
1157 } | 1157 } |
1158 | 1158 |
1159 if (!enabled) | 1159 if (!enabled) |
1160 navigation_overlay_.reset(); | 1160 navigation_overlay_.reset(); |
1161 else if (!navigation_overlay_) | 1161 else if (!navigation_overlay_) |
1162 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); | 1162 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); |
1163 } | 1163 } |
1164 | 1164 |
1165 //////////////////////////////////////////////////////////////////////////////// | 1165 //////////////////////////////////////////////////////////////////////////////// |
1166 // WebContentsViewAura, RenderViewHostDelegateView implementation: | 1166 // WebContentsViewAura, RenderViewHostDelegateView implementation: |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1571 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, | 1571 void WebContentsViewAura::OnWindowVisibilityChanged(aura::Window* window, |
1572 bool visible) { | 1572 bool visible) { |
1573 // Ignore any visibility changes in the hierarchy below. | 1573 // Ignore any visibility changes in the hierarchy below. |
1574 if (window != window_.get() && window_->Contains(window)) | 1574 if (window != window_.get() && window_->Contains(window)) |
1575 return; | 1575 return; |
1576 | 1576 |
1577 UpdateWebContentsVisibility(web_contents_, visible); | 1577 UpdateWebContentsVisibility(web_contents_, visible); |
1578 } | 1578 } |
1579 | 1579 |
1580 } // namespace content | 1580 } // namespace content |
OLD | NEW |