OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 | 5 |
6 #include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h" | 6 #include "chrome/browser/guest_view/web_view/chrome_web_view_guest_delegate.h" |
7 | 7 |
8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" | 8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" |
9 #include "chrome/browser/favicon/favicon_utils.h" | 9 #include "chrome/browser/favicon/favicon_utils.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 ChromeWebViewGuestDelegate::~ChromeWebViewGuestDelegate() { | 33 ChromeWebViewGuestDelegate::~ChromeWebViewGuestDelegate() { |
34 } | 34 } |
35 | 35 |
36 bool ChromeWebViewGuestDelegate::HandleContextMenu( | 36 bool ChromeWebViewGuestDelegate::HandleContextMenu( |
37 const content::ContextMenuParams& params) { | 37 const content::ContextMenuParams& params) { |
38 ContextMenuDelegate* menu_delegate = | 38 ContextMenuDelegate* menu_delegate = |
39 ContextMenuDelegate::FromWebContents(guest_web_contents()); | 39 ContextMenuDelegate::FromWebContents(guest_web_contents()); |
40 DCHECK(menu_delegate); | 40 DCHECK(menu_delegate); |
41 | 41 |
42 pending_menu_ = menu_delegate->BuildMenu(guest_web_contents(), params); | 42 content::ContextMenuParams new_params = params; |
| 43 // The only case where |context_menu_position_| is not initialized is the case |
| 44 // where the input event is directly sent to the guest WebContents without |
| 45 // ever going throught the embedder and BrowserPlugin's |
| 46 // RenderWidgetHostViewGuest. This only happens in some tests, e.g., |
| 47 // WebViewInteractiveTest.ContextMenuParamCoordinates. |
| 48 if (context_menu_position_) { |
| 49 new_params.x = context_menu_position_->x(); |
| 50 new_params.y = context_menu_position_->y(); |
| 51 } |
| 52 |
| 53 pending_menu_ = menu_delegate->BuildMenu(guest_web_contents(), new_params); |
43 // It's possible for the returned menu to be null, so early out to avoid | 54 // It's possible for the returned menu to be null, so early out to avoid |
44 // a crash. TODO(wjmaclean): find out why it's possible for this to happen | 55 // a crash. TODO(wjmaclean): find out why it's possible for this to happen |
45 // in the first place, and if it's an error. | 56 // in the first place, and if it's an error. |
46 if (!pending_menu_) | 57 if (!pending_menu_) |
47 return false; | 58 return false; |
48 | 59 |
49 // Pass it to embedder. | 60 // Pass it to embedder. |
50 int request_id = ++pending_context_menu_request_id_; | 61 int request_id = ++pending_context_menu_request_id_; |
51 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 62 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
52 scoped_ptr<base::ListValue> items = | 63 scoped_ptr<base::ListValue> items = |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 } else if (details.notification_type == | 143 } else if (details.notification_type == |
133 chromeos::ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) { | 144 chromeos::ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) { |
134 if (details.enabled) | 145 if (details.enabled) |
135 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost()); | 146 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost()); |
136 else | 147 else |
137 chromevox_injected_ = false; | 148 chromevox_injected_ = false; |
138 } | 149 } |
139 } | 150 } |
140 #endif | 151 #endif |
141 | 152 |
| 153 void ChromeWebViewGuestDelegate::SetContextMenuPosition( |
| 154 const gfx::Point& position) { |
| 155 if (context_menu_position_ == nullptr) |
| 156 context_menu_position_.reset(new gfx::Point()); |
| 157 |
| 158 *context_menu_position_ = position; |
| 159 } |
| 160 |
142 } // namespace extensions | 161 } // namespace extensions |
OLD | NEW |