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 <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 WebContentsImpl* web_contents, | 83 WebContentsImpl* web_contents, |
84 WebContentsViewDelegate* delegate, | 84 WebContentsViewDelegate* delegate, |
85 RenderViewHostDelegateView** render_view_host_delegate_view) { | 85 RenderViewHostDelegateView** render_view_host_delegate_view) { |
86 WebContentsViewAura* rv = new WebContentsViewAura(web_contents, delegate); | 86 WebContentsViewAura* rv = new WebContentsViewAura(web_contents, delegate); |
87 *render_view_host_delegate_view = rv; | 87 *render_view_host_delegate_view = rv; |
88 return rv; | 88 return rv; |
89 } | 89 } |
90 | 90 |
91 namespace { | 91 namespace { |
92 | 92 |
| 93 WebContentsViewAura::RenderWidgetHostViewCreateFunction |
| 94 g_create_render_widget_host_view = nullptr; |
| 95 |
93 bool IsScrollEndEffectEnabled() { | 96 bool IsScrollEndEffectEnabled() { |
94 return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 97 return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
95 switches::kScrollEndEffect) == "1"; | 98 switches::kScrollEndEffect) == "1"; |
96 } | 99 } |
97 | 100 |
98 RenderWidgetHostViewAura* ToRenderWidgetHostViewAura( | 101 RenderWidgetHostViewAura* ToRenderWidgetHostViewAura( |
99 RenderWidgetHostView* view) { | 102 RenderWidgetHostView* view) { |
100 if (!view || (RenderViewHostFactory::has_factory() && | 103 if (!view || (RenderViewHostFactory::has_factory() && |
101 !RenderViewHostFactory::is_real_render_view_host())) { | 104 !RenderViewHostFactory::is_real_render_view_host())) { |
102 return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests. | 105 return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests. |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 | 507 |
505 WebContentsViewAura* view_; | 508 WebContentsViewAura* view_; |
506 | 509 |
507 // The parent window that hosts the constrained windows. We cache the old host | 510 // The parent window that hosts the constrained windows. We cache the old host |
508 // view so that we can unregister when it's not the parent anymore. | 511 // view so that we can unregister when it's not the parent anymore. |
509 aura::Window* host_window_; | 512 aura::Window* host_window_; |
510 | 513 |
511 DISALLOW_COPY_AND_ASSIGN(WindowObserver); | 514 DISALLOW_COPY_AND_ASSIGN(WindowObserver); |
512 }; | 515 }; |
513 | 516 |
| 517 // static |
| 518 void WebContentsViewAura::InstallCreateHookForTests( |
| 519 RenderWidgetHostViewCreateFunction create_render_widget_host_view) { |
| 520 CHECK_EQ(nullptr, g_create_render_widget_host_view); |
| 521 g_create_render_widget_host_view = create_render_widget_host_view; |
| 522 } |
| 523 |
514 //////////////////////////////////////////////////////////////////////////////// | 524 //////////////////////////////////////////////////////////////////////////////// |
515 // WebContentsViewAura, public: | 525 // WebContentsViewAura, public: |
516 | 526 |
517 WebContentsViewAura::WebContentsViewAura(WebContentsImpl* web_contents, | 527 WebContentsViewAura::WebContentsViewAura(WebContentsImpl* web_contents, |
518 WebContentsViewDelegate* delegate) | 528 WebContentsViewDelegate* delegate) |
519 : web_contents_(web_contents), | 529 : web_contents_(web_contents), |
520 delegate_(delegate), | 530 delegate_(delegate), |
521 current_drag_op_(blink::WebDragOperationNone), | 531 current_drag_op_(blink::WebDragOperationNone), |
522 drag_dest_delegate_(nullptr), | 532 drag_dest_delegate_(nullptr), |
523 current_rvh_for_drag_(ChildProcessHost::kInvalidUniqueID, | 533 current_rvh_for_drag_(ChildProcessHost::kInvalidUniqueID, |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 // test view, so we don't want to clobber it with a real one. To verify that | 850 // test view, so we don't want to clobber it with a real one. To verify that |
841 // this actually is happening (and somebody isn't accidentally creating the | 851 // this actually is happening (and somebody isn't accidentally creating the |
842 // view twice), we check for the RVH Factory, which will be set when we're | 852 // view twice), we check for the RVH Factory, which will be set when we're |
843 // making special ones (which go along with the special views). | 853 // making special ones (which go along with the special views). |
844 DCHECK(RenderViewHostFactory::has_factory()); | 854 DCHECK(RenderViewHostFactory::has_factory()); |
845 return static_cast<RenderWidgetHostViewBase*>( | 855 return static_cast<RenderWidgetHostViewBase*>( |
846 render_widget_host->GetView()); | 856 render_widget_host->GetView()); |
847 } | 857 } |
848 | 858 |
849 RenderWidgetHostViewAura* view = | 859 RenderWidgetHostViewAura* view = |
850 new RenderWidgetHostViewAura(render_widget_host, is_guest_view_hack); | 860 g_create_render_widget_host_view |
| 861 ? g_create_render_widget_host_view(render_widget_host, |
| 862 is_guest_view_hack) |
| 863 : new RenderWidgetHostViewAura(render_widget_host, |
| 864 is_guest_view_hack); |
851 view->InitAsChild(GetRenderWidgetHostViewParent()); | 865 view->InitAsChild(GetRenderWidgetHostViewParent()); |
852 | 866 |
853 RenderWidgetHostImpl* host_impl = | 867 RenderWidgetHostImpl* host_impl = |
854 RenderWidgetHostImpl::From(render_widget_host); | 868 RenderWidgetHostImpl::From(render_widget_host); |
855 | 869 |
856 if (!host_impl->is_hidden()) | 870 if (!host_impl->is_hidden()) |
857 view->Show(); | 871 view->Show(); |
858 | 872 |
859 // We listen to drag drop events in the newly created view's window. | 873 // We listen to drag drop events in the newly created view's window. |
860 aura::client::SetDragDropDelegate(view->GetNativeView(), this); | 874 aura::client::SetDragDropDelegate(view->GetNativeView(), this); |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 bool allow_multiple_selection) { | 1338 bool allow_multiple_selection) { |
1325 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; | 1339 NOTIMPLEMENTED() << " show " << items.size() << " menu items"; |
1326 } | 1340 } |
1327 | 1341 |
1328 void WebContentsViewAura::HidePopupMenu() { | 1342 void WebContentsViewAura::HidePopupMenu() { |
1329 NOTIMPLEMENTED(); | 1343 NOTIMPLEMENTED(); |
1330 } | 1344 } |
1331 #endif | 1345 #endif |
1332 | 1346 |
1333 } // namespace content | 1347 } // namespace content |
OLD | NEW |