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 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/extensions/extension_event_names.h" | 15 #include "chrome/browser/extensions/event_names.h" |
16 #include "chrome/browser/extensions/extension_event_router.h" | 16 #include "chrome/browser/extensions/event_router.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
19 #include "chrome/browser/extensions/tab_helper.h" | 19 #include "chrome/browser/extensions/tab_helper.h" |
20 #include "chrome/browser/extensions/extension_tab_util.h" | 20 #include "chrome/browser/extensions/extension_tab_util.h" |
21 #include "chrome/browser/extensions/state_store.h" | 21 #include "chrome/browser/extensions/state_store.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 23 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
24 #include "chrome/common/chrome_notification_types.h" | 24 #include "chrome/common/chrome_notification_types.h" |
25 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
26 #include "content/public/browser/notification_details.h" | 26 #include "content/public/browser/notification_details.h" |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 static void AddURLProperty(DictionaryValue* dictionary, | 560 static void AddURLProperty(DictionaryValue* dictionary, |
561 const std::string& key, const GURL& url) { | 561 const std::string& key, const GURL& url) { |
562 if (!url.is_empty()) | 562 if (!url.is_empty()) |
563 dictionary->SetString(key, url.possibly_invalid_spec()); | 563 dictionary->SetString(key, url.possibly_invalid_spec()); |
564 } | 564 } |
565 | 565 |
566 void MenuManager::ExecuteCommand(Profile* profile, | 566 void MenuManager::ExecuteCommand(Profile* profile, |
567 WebContents* web_contents, | 567 WebContents* web_contents, |
568 const content::ContextMenuParams& params, | 568 const content::ContextMenuParams& params, |
569 const MenuItem::Id& menu_item_id) { | 569 const MenuItem::Id& menu_item_id) { |
570 ExtensionEventRouter* event_router = profile->GetExtensionEventRouter(); | 570 EventRouter* event_router = profile->GetExtensionEventRouter(); |
571 if (!event_router) | 571 if (!event_router) |
572 return; | 572 return; |
573 | 573 |
574 MenuItem* item = GetItemById(menu_item_id); | 574 MenuItem* item = GetItemById(menu_item_id); |
575 if (!item) | 575 if (!item) |
576 return; | 576 return; |
577 | 577 |
578 // ExtensionService/Extension can be NULL in unit tests :( | 578 // ExtensionService/Extension can be NULL in unit tests :( |
579 ExtensionService* service = | 579 ExtensionService* service = |
580 ExtensionSystem::Get(profile_)->extension_service(); | 580 ExtensionSystem::Get(profile_)->extension_service(); |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 TabContents* tab_contents = web_contents ? | 643 TabContents* tab_contents = web_contents ? |
644 TabContents::FromWebContents(web_contents) : NULL; | 644 TabContents::FromWebContents(web_contents) : NULL; |
645 if (tab_contents && extension) { | 645 if (tab_contents && extension) { |
646 tab_contents->extension_tab_helper()->active_tab_permission_manager()-> | 646 tab_contents->extension_tab_helper()->active_tab_permission_manager()-> |
647 GrantIfRequested(extension); | 647 GrantIfRequested(extension); |
648 } | 648 } |
649 | 649 |
650 std::string json_args; | 650 std::string json_args; |
651 base::JSONWriter::Write(&args, &json_args); | 651 base::JSONWriter::Write(&args, &json_args); |
652 event_router->DispatchEventToExtension( | 652 event_router->DispatchEventToExtension( |
653 item->extension_id(), extension_event_names::kOnContextMenus, | 653 item->extension_id(), event_names::kOnContextMenus, |
654 json_args, profile, GURL(), | 654 json_args, profile, GURL(), |
655 ExtensionEventRouter::USER_GESTURE_ENABLED); | 655 EventRouter::USER_GESTURE_ENABLED); |
656 event_router->DispatchEventToExtension( | 656 event_router->DispatchEventToExtension( |
657 item->extension_id(), extension_event_names::kOnContextMenuClicked, | 657 item->extension_id(), event_names::kOnContextMenuClicked, |
658 json_args, profile, GURL(), | 658 json_args, profile, GURL(), |
659 ExtensionEventRouter::USER_GESTURE_ENABLED); | 659 EventRouter::USER_GESTURE_ENABLED); |
660 } | 660 } |
661 | 661 |
662 void MenuManager::SanitizeRadioList(const MenuItem::List& item_list) { | 662 void MenuManager::SanitizeRadioList(const MenuItem::List& item_list) { |
663 MenuItem::List::const_iterator i = item_list.begin(); | 663 MenuItem::List::const_iterator i = item_list.begin(); |
664 while (i != item_list.end()) { | 664 while (i != item_list.end()) { |
665 if ((*i)->type() != MenuItem::RADIO) { | 665 if ((*i)->type() != MenuItem::RADIO) { |
666 ++i; | 666 ++i; |
667 break; | 667 break; |
668 } | 668 } |
669 | 669 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 if (uid < other.uid) | 817 if (uid < other.uid) |
818 return true; | 818 return true; |
819 if (uid == other.uid) | 819 if (uid == other.uid) |
820 return string_uid < other.string_uid; | 820 return string_uid < other.string_uid; |
821 } | 821 } |
822 } | 822 } |
823 return false; | 823 return false; |
824 } | 824 } |
825 | 825 |
826 } // namespace extensions | 826 } // namespace extensions |
OLD | NEW |