| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 namespace { | 85 namespace { |
| 86 | 86 |
| 87 bool IsScrollEndEffectEnabled() { | 87 bool IsScrollEndEffectEnabled() { |
| 88 return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 88 return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 89 switches::kScrollEndEffect) == "1"; | 89 switches::kScrollEndEffect) == "1"; |
| 90 } | 90 } |
| 91 | 91 |
| 92 RenderWidgetHostViewAura* ToRenderWidgetHostViewAura( | 92 RenderWidgetHostViewAura* ToRenderWidgetHostViewAura( |
| 93 RenderWidgetHostView* view) { | 93 RenderWidgetHostView* view) { |
| 94 if (!view || RenderViewHostFactory::has_factory()) | 94 if (!view || (RenderViewHostFactory::has_factory() && |
| 95 !RenderViewHostFactory::is_real_render_view_host())) { |
| 95 return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests. | 96 return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests. |
| 97 } |
| 96 | 98 |
| 97 RenderViewHost* rvh = RenderViewHost::From(view->GetRenderWidgetHost()); | 99 RenderViewHost* rvh = RenderViewHost::From(view->GetRenderWidgetHost()); |
| 98 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | 100 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
| 99 rvh ? WebContents::FromRenderViewHost(rvh) : NULL); | 101 rvh ? WebContents::FromRenderViewHost(rvh) : NULL); |
| 100 if (BrowserPluginGuest::IsGuest(web_contents)) | 102 if (BrowserPluginGuest::IsGuest(web_contents)) |
| 101 return NULL; | 103 return NULL; |
| 102 return static_cast<RenderWidgetHostViewAura*>(view); | 104 return static_cast<RenderWidgetHostViewAura*>(view); |
| 103 } | 105 } |
| 104 | 106 |
| 105 // Listens to all mouse drag events during a drag and drop and sends them to | 107 // Listens to all mouse drag events during a drag and drop and sends them to |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 delegate_(delegate), | 657 delegate_(delegate), |
| 656 current_drag_op_(blink::WebDragOperationNone), | 658 current_drag_op_(blink::WebDragOperationNone), |
| 657 drag_dest_delegate_(NULL), | 659 drag_dest_delegate_(NULL), |
| 658 current_rvh_for_drag_(NULL), | 660 current_rvh_for_drag_(NULL), |
| 659 current_overscroll_gesture_(OVERSCROLL_NONE), | 661 current_overscroll_gesture_(OVERSCROLL_NONE), |
| 660 completed_overscroll_gesture_(OVERSCROLL_NONE), | 662 completed_overscroll_gesture_(OVERSCROLL_NONE), |
| 661 navigation_overlay_(nullptr), | 663 navigation_overlay_(nullptr), |
| 662 is_or_was_visible_(false) { | 664 is_or_was_visible_(false) { |
| 663 } | 665 } |
| 664 | 666 |
| 667 void WebContentsViewAura::SetDelegateForTesting( |
| 668 WebContentsViewDelegate* delegate) { |
| 669 delegate_.reset(delegate); |
| 670 } |
| 671 |
| 665 //////////////////////////////////////////////////////////////////////////////// | 672 //////////////////////////////////////////////////////////////////////////////// |
| 666 // WebContentsViewAura, private: | 673 // WebContentsViewAura, private: |
| 667 | 674 |
| 668 WebContentsViewAura::~WebContentsViewAura() { | 675 WebContentsViewAura::~WebContentsViewAura() { |
| 669 if (!window_) | 676 if (!window_) |
| 670 return; | 677 return; |
| 671 | 678 |
| 672 window_observer_.reset(); | 679 window_observer_.reset(); |
| 673 window_->RemoveObserver(this); | 680 window_->RemoveObserver(this); |
| 674 | 681 |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 // WebContentsViewAura, RenderViewHostDelegateView implementation: | 951 // WebContentsViewAura, RenderViewHostDelegateView implementation: |
| 945 | 952 |
| 946 void WebContentsViewAura::ShowContextMenu(RenderFrameHost* render_frame_host, | 953 void WebContentsViewAura::ShowContextMenu(RenderFrameHost* render_frame_host, |
| 947 const ContextMenuParams& params) { | 954 const ContextMenuParams& params) { |
| 948 TouchSelectionControllerClientAura* selection_controller_client = | 955 TouchSelectionControllerClientAura* selection_controller_client = |
| 949 GetSelectionControllerClient(); | 956 GetSelectionControllerClient(); |
| 950 if (selection_controller_client && | 957 if (selection_controller_client && |
| 951 selection_controller_client->HandleContextMenu(params)) { | 958 selection_controller_client->HandleContextMenu(params)) { |
| 952 return; | 959 return; |
| 953 } | 960 } |
| 961 |
| 954 if (delegate_) { | 962 if (delegate_) { |
| 955 RenderWidgetHostViewAura* view = ToRenderWidgetHostViewAura( | 963 RenderWidgetHostViewAura* view = ToRenderWidgetHostViewAura( |
| 956 web_contents_->GetRenderWidgetHostView()); | 964 web_contents_->GetRenderWidgetHostView()); |
| 957 if (view) | 965 if (view && !view->OnShowContextMenu(params)) |
| 958 view->OnShowContextMenu(); | 966 return; |
| 959 | 967 |
| 960 delegate_->ShowContextMenu(render_frame_host, params); | 968 delegate_->ShowContextMenu(render_frame_host, params); |
| 961 // WARNING: we may have been deleted during the call to ShowContextMenu(). | 969 // WARNING: we may have been deleted during the call to ShowContextMenu(). |
| 962 } | 970 } |
| 963 } | 971 } |
| 964 | 972 |
| 965 void WebContentsViewAura::StartDragging( | 973 void WebContentsViewAura::StartDragging( |
| 966 const DropData& drop_data, | 974 const DropData& drop_data, |
| 967 blink::WebDragOperationsMask operations, | 975 blink::WebDragOperationsMask operations, |
| 968 const gfx::ImageSkia& image, | 976 const gfx::ImageSkia& image, |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 if (visible) { | 1323 if (visible) { |
| 1316 if (!web_contents_->should_normally_be_visible()) | 1324 if (!web_contents_->should_normally_be_visible()) |
| 1317 web_contents_->WasShown(); | 1325 web_contents_->WasShown(); |
| 1318 } else { | 1326 } else { |
| 1319 if (web_contents_->should_normally_be_visible()) | 1327 if (web_contents_->should_normally_be_visible()) |
| 1320 web_contents_->WasHidden(); | 1328 web_contents_->WasHidden(); |
| 1321 } | 1329 } |
| 1322 } | 1330 } |
| 1323 | 1331 |
| 1324 } // namespace content | 1332 } // namespace content |
| OLD | NEW |