Chromium Code Reviews| 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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 return mode == (base::i18n::IsRTL() ? OVERSCROLL_WEST : OVERSCROLL_EAST) && | 91 return mode == (base::i18n::IsRTL() ? OVERSCROLL_WEST : OVERSCROLL_EAST) && |
| 92 controller.CanGoBack(); | 92 controller.CanGoBack(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 RenderWidgetHostViewAura* ToRenderWidgetHostViewAura( | 95 RenderWidgetHostViewAura* ToRenderWidgetHostViewAura( |
| 96 RenderWidgetHostView* view) { | 96 RenderWidgetHostView* view) { |
| 97 if (!view || RenderViewHostFactory::has_factory()) | 97 if (!view || RenderViewHostFactory::has_factory()) |
| 98 return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests. | 98 return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests. |
| 99 RenderProcessHostImpl* process = static_cast<RenderProcessHostImpl*>( | 99 RenderProcessHostImpl* process = static_cast<RenderProcessHostImpl*>( |
| 100 view->GetRenderWidgetHost()->GetProcess()); | 100 view->GetRenderWidgetHost()->GetProcess()); |
| 101 if (process->IsGuest()) | 101 DCHECK(!process->IsGuest()); |
|
jam
2013/11/14 17:42:15
is this dcheck conclusive? i.e. can we still end u
lazyboy
2013/11/14 19:04:50
IsGuest() = true here would mean either a. we inco
lazyboy
2013/11/14 21:34:55
TouchEditable also uses this method, which means t
| |
| 102 return NULL; | |
| 103 return static_cast<RenderWidgetHostViewAura*>(view); | 102 return static_cast<RenderWidgetHostViewAura*>(view); |
| 104 } | 103 } |
| 105 | 104 |
| 106 // The window delegate for the overscroll window. This redirects trackpad events | 105 // The window delegate for the overscroll window. This redirects trackpad events |
| 107 // to the web-contents window. The delegate destroys itself when the window is | 106 // to the web-contents window. The delegate destroys itself when the window is |
| 108 // destroyed. | 107 // destroyed. |
| 109 class OverscrollWindowDelegate : public ImageWindowDelegate { | 108 class OverscrollWindowDelegate : public ImageWindowDelegate { |
| 110 public: | 109 public: |
| 111 OverscrollWindowDelegate(WebContentsImpl* web_contents, | 110 OverscrollWindowDelegate(WebContentsImpl* web_contents, |
| 112 OverscrollMode overscroll_mode) | 111 OverscrollMode overscroll_mode) |
| (...skipping 1009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1122 } | 1121 } |
| 1123 | 1122 |
| 1124 DropData* WebContentsViewAura::GetDropData() const { | 1123 DropData* WebContentsViewAura::GetDropData() const { |
| 1125 return current_drop_data_.get(); | 1124 return current_drop_data_.get(); |
| 1126 } | 1125 } |
| 1127 | 1126 |
| 1128 gfx::Rect WebContentsViewAura::GetViewBounds() const { | 1127 gfx::Rect WebContentsViewAura::GetViewBounds() const { |
| 1129 return window_->GetBoundsInScreen(); | 1128 return window_->GetBoundsInScreen(); |
| 1130 } | 1129 } |
| 1131 | 1130 |
| 1131 | |
|
jam
2013/11/14 17:42:15
nit: undo
lazyboy
2013/11/14 19:04:50
Done.
| |
| 1132 //////////////////////////////////////////////////////////////////////////////// | 1132 //////////////////////////////////////////////////////////////////////////////// |
| 1133 // WebContentsViewAura, WebContentsViewPort implementation: | 1133 // WebContentsViewAura, WebContentsViewPort implementation: |
| 1134 | 1134 |
| 1135 void WebContentsViewAura::CreateView( | 1135 void WebContentsViewAura::CreateView( |
| 1136 const gfx::Size& initial_size, gfx::NativeView context) { | 1136 const gfx::Size& initial_size, gfx::NativeView context) { |
| 1137 // NOTE: we ignore |initial_size| since in some cases it's wrong (such as | 1137 // NOTE: we ignore |initial_size| since in some cases it's wrong (such as |
| 1138 // if the bookmark bar is not shown and you create a new tab). The right | 1138 // if the bookmark bar is not shown and you create a new tab). The right |
| 1139 // value is set shortly after this, so its safe to ignore. | 1139 // value is set shortly after this, so its safe to ignore. |
| 1140 | 1140 |
| 1141 aura::Env::CreateInstance(); | 1141 aura::Env::CreateInstance(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1155 // explicitly add this WebContentsViewAura to their tree after they create | 1155 // explicitly add this WebContentsViewAura to their tree after they create |
| 1156 // us. | 1156 // us. |
| 1157 if (root_window) { | 1157 if (root_window) { |
| 1158 aura::client::ParentWindowWithContext( | 1158 aura::client::ParentWindowWithContext( |
| 1159 window_.get(), root_window, root_window->GetBoundsInScreen()); | 1159 window_.get(), root_window, root_window->GetBoundsInScreen()); |
| 1160 } | 1160 } |
| 1161 } | 1161 } |
| 1162 window_->layer()->SetMasksToBounds(true); | 1162 window_->layer()->SetMasksToBounds(true); |
| 1163 window_->SetName("WebContentsViewAura"); | 1163 window_->SetName("WebContentsViewAura"); |
| 1164 | 1164 |
| 1165 window_observer_.reset(new WindowObserver(this)); | 1165 // WindowObserver is not interesting and is problematic for Browser Plugin |
| 1166 // guests. | |
| 1167 // The use cases for WindowObserver do not apply to Browser Plugins: | |
| 1168 // 1) guests do not support NPAPI plugins. | |
| 1169 // 2) guests' window bounds are supposed to come from its embedder. | |
| 1170 if (!web_contents_->GetRenderProcessHost()->IsGuest()) | |
| 1171 window_observer_.reset(new WindowObserver(this)); | |
| 1166 | 1172 |
| 1167 // delegate_->GetDragDestDelegate() creates a new delegate on every call. | 1173 // delegate_->GetDragDestDelegate() creates a new delegate on every call. |
| 1168 // Hence, we save a reference to it locally. Similar model is used on other | 1174 // Hence, we save a reference to it locally. Similar model is used on other |
| 1169 // platforms as well. | 1175 // platforms as well. |
| 1170 if (delegate_) | 1176 if (delegate_) |
| 1171 drag_dest_delegate_ = delegate_->GetDragDestDelegate(); | 1177 drag_dest_delegate_ = delegate_->GetDragDestDelegate(); |
| 1172 } | 1178 } |
| 1173 | 1179 |
| 1174 RenderWidgetHostView* WebContentsViewAura::CreateViewForWidget( | 1180 RenderWidgetHostView* WebContentsViewAura::CreateViewForWidget( |
| 1175 RenderWidgetHost* render_widget_host) { | 1181 RenderWidgetHost* render_widget_host) { |
| (...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1641 event.location(), | 1647 event.location(), |
| 1642 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1648 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
| 1643 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1649 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
| 1644 if (drag_dest_delegate_) | 1650 if (drag_dest_delegate_) |
| 1645 drag_dest_delegate_->OnDrop(); | 1651 drag_dest_delegate_->OnDrop(); |
| 1646 current_drop_data_.reset(); | 1652 current_drop_data_.reset(); |
| 1647 return current_drag_op_; | 1653 return current_drag_op_; |
| 1648 } | 1654 } |
| 1649 | 1655 |
| 1650 } // namespace content | 1656 } // namespace content |
| OLD | NEW |