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