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" |
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/download/drag_download_util.h" | 13 #include "content/browser/download/drag_download_util.h" |
13 #include "content/browser/frame_host/interstitial_page_impl.h" | 14 #include "content/browser/frame_host/interstitial_page_impl.h" |
14 #include "content/browser/frame_host/navigation_entry_impl.h" | 15 #include "content/browser/frame_host/navigation_entry_impl.h" |
15 #include "content/browser/renderer_host/dip_util.h" | 16 #include "content/browser/renderer_host/dip_util.h" |
16 #include "content/browser/renderer_host/overscroll_controller.h" | 17 #include "content/browser/renderer_host/overscroll_controller.h" |
17 #include "content/browser/renderer_host/render_view_host_factory.h" | 18 #include "content/browser/renderer_host/render_view_host_factory.h" |
18 #include "content/browser/renderer_host/render_view_host_impl.h" | 19 #include "content/browser/renderer_host/render_view_host_impl.h" |
19 #include "content/browser/renderer_host/render_widget_host_impl.h" | 20 #include "content/browser/renderer_host/render_widget_host_impl.h" |
20 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 21 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
21 #include "content/browser/web_contents/aura/gesture_nav_simple.h" | 22 #include "content/browser/web_contents/aura/gesture_nav_simple.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 bool ShouldNavigateBack(const NavigationController& controller, | 96 bool ShouldNavigateBack(const NavigationController& controller, |
96 OverscrollMode mode) { | 97 OverscrollMode mode) { |
97 return mode == (base::i18n::IsRTL() ? OVERSCROLL_WEST : OVERSCROLL_EAST) && | 98 return mode == (base::i18n::IsRTL() ? OVERSCROLL_WEST : OVERSCROLL_EAST) && |
98 controller.CanGoBack(); | 99 controller.CanGoBack(); |
99 } | 100 } |
100 | 101 |
101 RenderWidgetHostViewAura* ToRenderWidgetHostViewAura( | 102 RenderWidgetHostViewAura* ToRenderWidgetHostViewAura( |
102 RenderWidgetHostView* view) { | 103 RenderWidgetHostView* view) { |
103 if (!view || RenderViewHostFactory::has_factory()) | 104 if (!view || RenderViewHostFactory::has_factory()) |
104 return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests. | 105 return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests. |
105 RenderProcessHostImpl* process = static_cast<RenderProcessHostImpl*>( | 106 |
106 view->GetRenderWidgetHost()->GetProcess()); | 107 RenderViewHost* rvh = RenderViewHost::From(view->GetRenderWidgetHost()); |
107 if (process->IsGuest()) | 108 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
| 109 rvh ? WebContents::FromRenderViewHost(rvh) : NULL); |
| 110 if (BrowserPluginGuest::IsGuest(web_contents)) |
108 return NULL; | 111 return NULL; |
109 return static_cast<RenderWidgetHostViewAura*>(view); | 112 return static_cast<RenderWidgetHostViewAura*>(view); |
110 } | 113 } |
111 | 114 |
112 // The window delegate for the overscroll window. This redirects trackpad events | 115 // The window delegate for the overscroll window. This redirects trackpad events |
113 // to the web-contents window. The delegate destroys itself when the window is | 116 // to the web-contents window. The delegate destroys itself when the window is |
114 // destroyed. | 117 // destroyed. |
115 class OverscrollWindowDelegate : public ImageWindowDelegate { | 118 class OverscrollWindowDelegate : public ImageWindowDelegate { |
116 public: | 119 public: |
117 OverscrollWindowDelegate(WebContentsImpl* web_contents, | 120 OverscrollWindowDelegate(WebContentsImpl* web_contents, |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 } | 1063 } |
1061 } | 1064 } |
1062 window_->layer()->SetMasksToBounds(true); | 1065 window_->layer()->SetMasksToBounds(true); |
1063 window_->SetName("WebContentsViewAura"); | 1066 window_->SetName("WebContentsViewAura"); |
1064 | 1067 |
1065 // WindowObserver is not interesting and is problematic for Browser Plugin | 1068 // WindowObserver is not interesting and is problematic for Browser Plugin |
1066 // guests. | 1069 // guests. |
1067 // The use cases for WindowObserver do not apply to Browser Plugins: | 1070 // The use cases for WindowObserver do not apply to Browser Plugins: |
1068 // 1) guests do not support NPAPI plugins. | 1071 // 1) guests do not support NPAPI plugins. |
1069 // 2) guests' window bounds are supposed to come from its embedder. | 1072 // 2) guests' window bounds are supposed to come from its embedder. |
1070 if (!web_contents_->GetRenderProcessHost()->IsGuest()) | 1073 if (!BrowserPluginGuest::IsGuest(web_contents_)) |
1071 window_observer_.reset(new WindowObserver(this)); | 1074 window_observer_.reset(new WindowObserver(this)); |
1072 | 1075 |
1073 // delegate_->GetDragDestDelegate() creates a new delegate on every call. | 1076 // delegate_->GetDragDestDelegate() creates a new delegate on every call. |
1074 // Hence, we save a reference to it locally. Similar model is used on other | 1077 // Hence, we save a reference to it locally. Similar model is used on other |
1075 // platforms as well. | 1078 // platforms as well. |
1076 if (delegate_) | 1079 if (delegate_) |
1077 drag_dest_delegate_ = delegate_->GetDragDestDelegate(); | 1080 drag_dest_delegate_ = delegate_->GetDragDestDelegate(); |
1078 } | 1081 } |
1079 | 1082 |
1080 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget( | 1083 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget( |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 event.location(), | 1549 event.location(), |
1547 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1550 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
1548 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1551 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1549 if (drag_dest_delegate_) | 1552 if (drag_dest_delegate_) |
1550 drag_dest_delegate_->OnDrop(); | 1553 drag_dest_delegate_->OnDrop(); |
1551 current_drop_data_.reset(); | 1554 current_drop_data_.reset(); |
1552 return ConvertFromWeb(current_drag_op_); | 1555 return ConvertFromWeb(current_drag_op_); |
1553 } | 1556 } |
1554 | 1557 |
1555 } // namespace content | 1558 } // namespace content |
OLD | NEW |