Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/browser/extensions/menu_manager.cc

Issue 1772513002: Add frameId to contextMenus.onClicked / onclick. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <tuple> 8 #include <tuple>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/common/extensions/api/chrome_web_view_internal.h" 22 #include "chrome/common/extensions/api/chrome_web_view_internal.h"
23 #include "chrome/common/extensions/api/context_menus.h" 23 #include "chrome/common/extensions/api/context_menus.h"
24 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
25 #include "content/public/browser/notification_service.h" 25 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/notification_source.h" 26 #include "content/public/browser/notification_source.h"
27 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
28 #include "content/public/common/child_process_host.h" 28 #include "content/public/common/child_process_host.h"
29 #include "content/public/common/context_menu_params.h" 29 #include "content/public/common/context_menu_params.h"
30 #include "extensions/browser/event_router.h" 30 #include "extensions/browser/event_router.h"
31 #include "extensions/browser/extension_api_frame_id_map.h"
31 #include "extensions/browser/extension_registry.h" 32 #include "extensions/browser/extension_registry.h"
32 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 33 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
33 #include "extensions/browser/state_store.h" 34 #include "extensions/browser/state_store.h"
34 #include "extensions/common/extension.h" 35 #include "extensions/common/extension.h"
35 #include "extensions/common/manifest_handlers/background_info.h" 36 #include "extensions/common/manifest_handlers/background_info.h"
36 #include "ui/gfx/favicon_size.h" 37 #include "ui/gfx/favicon_size.h"
37 #include "ui/gfx/text_elider.h" 38 #include "ui/gfx/text_elider.h"
38 39
39 using content::ChildProcessHost; 40 using content::ChildProcessHost;
40 using content::WebContents; 41 using content::WebContents;
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 } 611 }
611 612
612 static void AddURLProperty(base::DictionaryValue* dictionary, 613 static void AddURLProperty(base::DictionaryValue* dictionary,
613 const std::string& key, const GURL& url) { 614 const std::string& key, const GURL& url) {
614 if (!url.is_empty()) 615 if (!url.is_empty())
615 dictionary->SetString(key, url.possibly_invalid_spec()); 616 dictionary->SetString(key, url.possibly_invalid_spec());
616 } 617 }
617 618
618 void MenuManager::ExecuteCommand(content::BrowserContext* context, 619 void MenuManager::ExecuteCommand(content::BrowserContext* context,
619 WebContents* web_contents, 620 WebContents* web_contents,
621 content::RenderFrameHost* render_frame_host,
620 const content::ContextMenuParams& params, 622 const content::ContextMenuParams& params,
621 const MenuItem::Id& menu_item_id) { 623 const MenuItem::Id& menu_item_id) {
622 EventRouter* event_router = EventRouter::Get(context); 624 EventRouter* event_router = EventRouter::Get(context);
623 if (!event_router) 625 if (!event_router)
624 return; 626 return;
625 627
626 MenuItem* item = GetItemById(menu_item_id); 628 MenuItem* item = GetItemById(menu_item_id);
627 if (!item) 629 if (!item)
628 return; 630 return;
629 631
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
672 webview_guest->view_instance_id()); 674 webview_guest->view_instance_id());
673 } 675 }
674 676
675 args->Append(properties); 677 args->Append(properties);
676 678
677 // Add the tab info to the argument list. 679 // Add the tab info to the argument list.
678 // No tab info in a platform app. 680 // No tab info in a platform app.
679 if (!extension || !extension->is_platform_app()) { 681 if (!extension || !extension->is_platform_app()) {
680 // Note: web_contents are NULL in unit tests :( 682 // Note: web_contents are NULL in unit tests :(
681 if (web_contents) { 683 if (web_contents) {
684 int frame_id = ExtensionApiFrameIdMap::GetFrameId(render_frame_host);
685 if (frame_id != ExtensionApiFrameIdMap::kInvalidFrameId)
686 properties->SetInteger("frameId", frame_id);
687
682 args->Append( 688 args->Append(
683 ExtensionTabUtil::CreateTabObject(web_contents)->ToValue().release()); 689 ExtensionTabUtil::CreateTabObject(web_contents)->ToValue().release());
684 } else { 690 } else {
685 args->Append(new base::DictionaryValue()); 691 args->Append(new base::DictionaryValue());
686 } 692 }
687 } 693 }
688 694
689 if (item->type() == MenuItem::CHECKBOX || 695 if (item->type() == MenuItem::CHECKBOX ||
690 item->type() == MenuItem::RADIO) { 696 item->type() == MenuItem::RADIO) {
691 bool was_checked = item->checked(); 697 bool was_checked = item->checked();
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 bool MenuItem::Id::operator!=(const Id& other) const { 986 bool MenuItem::Id::operator!=(const Id& other) const {
981 return !(*this == other); 987 return !(*this == other);
982 } 988 }
983 989
984 bool MenuItem::Id::operator<(const Id& other) const { 990 bool MenuItem::Id::operator<(const Id& other) const {
985 return std::tie(incognito, extension_key, uid, string_uid) < 991 return std::tie(incognito, extension_key, uid, string_uid) <
986 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); 992 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid);
987 } 993 }
988 994
989 } // namespace extensions 995 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698