| 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 "chrome/browser/extensions/menu_manager.h" | 5 #include "chrome/browser/extensions/menu_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <tuple> | 9 #include <tuple> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 // Note: web_contents are null in unit tests :( | 707 // Note: web_contents are null in unit tests :( |
| 708 if (web_contents && TabHelper::FromWebContents(web_contents)) { | 708 if (web_contents && TabHelper::FromWebContents(web_contents)) { |
| 709 TabHelper::FromWebContents(web_contents) | 709 TabHelper::FromWebContents(web_contents) |
| 710 ->active_tab_permission_granter() | 710 ->active_tab_permission_granter() |
| 711 ->GrantIfRequested(extension); | 711 ->GrantIfRequested(extension); |
| 712 } | 712 } |
| 713 | 713 |
| 714 { | 714 { |
| 715 // Dispatch to menu item's .onclick handler (this is the legacy API, from | 715 // Dispatch to menu item's .onclick handler (this is the legacy API, from |
| 716 // before chrome.contextMenus.onClicked existed). | 716 // before chrome.contextMenus.onClicked existed). |
| 717 std::unique_ptr<Event> event( | 717 auto event = base::MakeUnique<Event>( |
| 718 new Event(webview_guest ? events::WEB_VIEW_INTERNAL_CONTEXT_MENUS | 718 webview_guest ? events::WEB_VIEW_INTERNAL_CONTEXT_MENUS |
| 719 : events::CONTEXT_MENUS, | 719 : events::CONTEXT_MENUS, |
| 720 webview_guest ? kOnWebviewContextMenus : kOnContextMenus, | 720 webview_guest ? kOnWebviewContextMenus : kOnContextMenus, |
| 721 std::unique_ptr<base::ListValue>(args->DeepCopy()))); | 721 std::unique_ptr<base::ListValue>(args->DeepCopy()), context); |
| 722 event->restrict_to_browser_context = context; | |
| 723 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; | 722 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; |
| 724 event_router->DispatchEventToExtension(item->extension_id(), | 723 event_router->DispatchEventToExtension(item->extension_id(), |
| 725 std::move(event)); | 724 std::move(event)); |
| 726 } | 725 } |
| 727 { | 726 { |
| 728 // Dispatch to .contextMenus.onClicked handler. | 727 // Dispatch to .contextMenus.onClicked handler. |
| 729 std::unique_ptr<Event> event(new Event( | 728 auto event = base::MakeUnique<Event>( |
| 730 webview_guest ? events::CHROME_WEB_VIEW_INTERNAL_ON_CLICKED | 729 webview_guest ? events::CHROME_WEB_VIEW_INTERNAL_ON_CLICKED |
| 731 : events::CONTEXT_MENUS_ON_CLICKED, | 730 : events::CONTEXT_MENUS_ON_CLICKED, |
| 732 webview_guest ? api::chrome_web_view_internal::OnClicked::kEventName | 731 webview_guest ? api::chrome_web_view_internal::OnClicked::kEventName |
| 733 : api::context_menus::OnClicked::kEventName, | 732 : api::context_menus::OnClicked::kEventName, |
| 734 std::move(args))); | 733 std::move(args), context); |
| 735 event->restrict_to_browser_context = context; | |
| 736 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; | 734 event->user_gesture = EventRouter::USER_GESTURE_ENABLED; |
| 737 if (webview_guest) | 735 if (webview_guest) |
| 738 event->filter_info.SetInstanceID(webview_guest->view_instance_id()); | 736 event->filter_info.SetInstanceID(webview_guest->view_instance_id()); |
| 739 event_router->DispatchEventToExtension(item->extension_id(), | 737 event_router->DispatchEventToExtension(item->extension_id(), |
| 740 std::move(event)); | 738 std::move(event)); |
| 741 } | 739 } |
| 742 } | 740 } |
| 743 | 741 |
| 744 void MenuManager::SanitizeRadioList(const MenuItem::OwnedList& item_list) { | 742 void MenuManager::SanitizeRadioList(const MenuItem::OwnedList& item_list) { |
| 745 auto i = item_list.begin(); | 743 auto i = item_list.begin(); |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 bool MenuItem::Id::operator!=(const Id& other) const { | 966 bool MenuItem::Id::operator!=(const Id& other) const { |
| 969 return !(*this == other); | 967 return !(*this == other); |
| 970 } | 968 } |
| 971 | 969 |
| 972 bool MenuItem::Id::operator<(const Id& other) const { | 970 bool MenuItem::Id::operator<(const Id& other) const { |
| 973 return std::tie(incognito, extension_key, uid, string_uid) < | 971 return std::tie(incognito, extension_key, uid, string_uid) < |
| 974 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); | 972 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); |
| 975 } | 973 } |
| 976 | 974 |
| 977 } // namespace extensions | 975 } // namespace extensions |
| OLD | NEW |