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_helper.h" | 9 #include "chrome/browser/favicon/favicon_helper.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 ChromeWebViewGuestDelegate::~ChromeWebViewGuestDelegate() { | 43 ChromeWebViewGuestDelegate::~ChromeWebViewGuestDelegate() { |
44 } | 44 } |
45 | 45 |
46 bool ChromeWebViewGuestDelegate::HandleContextMenu( | 46 bool ChromeWebViewGuestDelegate::HandleContextMenu( |
47 const content::ContextMenuParams& params) { | 47 const content::ContextMenuParams& params) { |
48 ContextMenuDelegate* menu_delegate = | 48 ContextMenuDelegate* menu_delegate = |
49 ContextMenuDelegate::FromWebContents(guest_web_contents()); | 49 ContextMenuDelegate::FromWebContents(guest_web_contents()); |
50 DCHECK(menu_delegate); | 50 DCHECK(menu_delegate); |
51 | 51 |
52 pending_menu_ = menu_delegate->BuildMenu(guest_web_contents(), params); | 52 pending_menu_ = menu_delegate->BuildMenu(guest_web_contents(), params); |
| 53 // It's possible for the returned menu to be null, so early out to avoid |
| 54 // a crash. TODO(wjmaclean): find out why it's possible for this to happen |
| 55 // in the first place, and if it's an error. |
| 56 if (!pending_menu_) |
| 57 return false; |
53 | 58 |
54 // Pass it to embedder. | 59 // Pass it to embedder. |
55 int request_id = ++pending_context_menu_request_id_; | 60 int request_id = ++pending_context_menu_request_id_; |
56 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 61 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
57 scoped_ptr<base::ListValue> items = | 62 scoped_ptr<base::ListValue> items = |
58 MenuModelToValue(pending_menu_->menu_model()); | 63 MenuModelToValue(pending_menu_->menu_model()); |
59 args->Set(webview::kContextMenuItems, items.release()); | 64 args->Set(webview::kContextMenuItems, items.release()); |
60 args->SetInteger(webview::kRequestId, request_id); | 65 args->SetInteger(webview::kRequestId, request_id); |
61 web_view_guest()->DispatchEventToView( | 66 web_view_guest()->DispatchEventToView( |
62 new GuestViewEvent(webview::kEventContextMenuShow, args.Pass())); | 67 new GuestViewEvent(webview::kEventContextMenuShow, args.Pass())); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 chromeos::ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) { | 177 chromeos::ACCESSIBILITY_TOGGLE_SPOKEN_FEEDBACK) { |
173 if (details.enabled) | 178 if (details.enabled) |
174 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost()); | 179 InjectChromeVoxIfNeeded(guest_web_contents()->GetRenderViewHost()); |
175 else | 180 else |
176 chromevox_injected_ = false; | 181 chromevox_injected_ = false; |
177 } | 182 } |
178 } | 183 } |
179 #endif | 184 #endif |
180 | 185 |
181 } // namespace extensions | 186 } // namespace extensions |
OLD | NEW |