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 <memory> | 8 #include <memory> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 // a crash. TODO(wjmaclean): find out why it's possible for this to happen | 58 // a crash. TODO(wjmaclean): find out why it's possible for this to happen |
59 // in the first place, and if it's an error. | 59 // in the first place, and if it's an error. |
60 if (!pending_menu_) | 60 if (!pending_menu_) |
61 return false; | 61 return false; |
62 | 62 |
63 // Pass it to embedder. | 63 // Pass it to embedder. |
64 int request_id = ++pending_context_menu_request_id_; | 64 int request_id = ++pending_context_menu_request_id_; |
65 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); | 65 std::unique_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
66 std::unique_ptr<base::ListValue> items = | 66 std::unique_ptr<base::ListValue> items = |
67 MenuModelToValue(pending_menu_->menu_model()); | 67 MenuModelToValue(pending_menu_->menu_model()); |
68 args->Set(webview::kContextMenuItems, items.release()); | 68 args->Set(webview::kContextMenuItems, std::move(items)); |
69 args->SetInteger(webview::kRequestId, request_id); | 69 args->SetInteger(webview::kRequestId, request_id); |
70 web_view_guest()->DispatchEventToView(base::MakeUnique<GuestViewEvent>( | 70 web_view_guest()->DispatchEventToView(base::MakeUnique<GuestViewEvent>( |
71 webview::kEventContextMenuShow, std::move(args))); | 71 webview::kEventContextMenuShow, std::move(args))); |
72 return true; | 72 return true; |
73 } | 73 } |
74 | 74 |
75 // static | 75 // static |
76 std::unique_ptr<base::ListValue> ChromeWebViewGuestDelegate::MenuModelToValue( | 76 std::unique_ptr<base::ListValue> ChromeWebViewGuestDelegate::MenuModelToValue( |
77 const ui::SimpleMenuModel& menu_model) { | 77 const ui::SimpleMenuModel& menu_model) { |
78 std::unique_ptr<base::ListValue> items(new base::ListValue()); | 78 std::unique_ptr<base::ListValue> items(new base::ListValue()); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 | 113 |
114 void ChromeWebViewGuestDelegate::SetContextMenuPosition( | 114 void ChromeWebViewGuestDelegate::SetContextMenuPosition( |
115 const gfx::Point& position) { | 115 const gfx::Point& position) { |
116 if (context_menu_position_ == nullptr) | 116 if (context_menu_position_ == nullptr) |
117 context_menu_position_.reset(new gfx::Point()); | 117 context_menu_position_.reset(new gfx::Point()); |
118 | 118 |
119 *context_menu_position_ = position; | 119 *context_menu_position_ = position; |
120 } | 120 } |
121 | 121 |
122 } // namespace extensions | 122 } // namespace extensions |
OLD | NEW |