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/extension_menu_manager.h" | 5 #include "chrome/browser/extensions/extension_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/extension_event_router.h" | 16 #include "chrome/browser/extensions/extension_event_router.h" |
16 #include "chrome/browser/extensions/extension_prefs.h" | 17 #include "chrome/browser/extensions/extension_prefs.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/extensions/extension_system.h" | 19 #include "chrome/browser/extensions/extension_system.h" |
19 #include "chrome/browser/extensions/extension_tab_util.h" | 20 #include "chrome/browser/extensions/extension_tab_util.h" |
20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
21 #include "chrome/common/chrome_notification_types.h" | 22 #include "chrome/common/chrome_notification_types.h" |
22 #include "chrome/common/extensions/extension.h" | 23 #include "chrome/common/extensions/extension.h" |
23 #include "content/public/browser/notification_details.h" | 24 #include "content/public/browser/notification_details.h" |
24 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/notification_source.h" |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 item->SetChecked(checked); | 597 item->SetChecked(checked); |
597 properties->SetBoolean("checked", item->checked()); | 598 properties->SetBoolean("checked", item->checked()); |
598 | 599 |
599 const extensions::Extension* extension = ExtensionSystem::Get(profile_)-> | 600 const extensions::Extension* extension = ExtensionSystem::Get(profile_)-> |
600 extension_service()->GetExtensionById(menuItemId.extension_id, false); | 601 extension_service()->GetExtensionById(menuItemId.extension_id, false); |
601 WriteToPrefs(extension); | 602 WriteToPrefs(extension); |
602 } | 603 } |
603 | 604 |
604 std::string json_args; | 605 std::string json_args; |
605 base::JSONWriter::Write(&args, &json_args); | 606 base::JSONWriter::Write(&args, &json_args); |
606 std::string event_name = "contextMenus"; | |
607 event_router->DispatchEventToExtension( | 607 event_router->DispatchEventToExtension( |
608 item->extension_id(), event_name, json_args, profile, GURL(), | 608 item->extension_id(), extension_event_names::kOnContextMenus, |
| 609 json_args, profile, GURL(), |
609 ExtensionEventRouter::USER_GESTURE_ENABLED); | 610 ExtensionEventRouter::USER_GESTURE_ENABLED); |
610 // TODO(yoz): dispatch another event onClicked. | 611 event_router->DispatchEventToExtension( |
| 612 item->extension_id(), extension_event_names::kOnContextMenuClicked, |
| 613 json_args, profile, GURL(), |
| 614 ExtensionEventRouter::USER_GESTURE_ENABLED); |
611 } | 615 } |
612 | 616 |
613 void ExtensionMenuManager::SanitizeRadioList( | 617 void ExtensionMenuManager::SanitizeRadioList( |
614 const ExtensionMenuItem::List& item_list) { | 618 const ExtensionMenuItem::List& item_list) { |
615 ExtensionMenuItem::List::const_iterator i = item_list.begin(); | 619 ExtensionMenuItem::List::const_iterator i = item_list.begin(); |
616 while (i != item_list.end()) { | 620 while (i != item_list.end()) { |
617 if ((*i)->type() != ExtensionMenuItem::RADIO) { | 621 if ((*i)->type() != ExtensionMenuItem::RADIO) { |
618 ++i; | 622 ++i; |
619 break; | 623 break; |
620 } | 624 } |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
759 return true; | 763 return true; |
760 if (extension_id == other.extension_id) { | 764 if (extension_id == other.extension_id) { |
761 if (uid < other.uid) | 765 if (uid < other.uid) |
762 return true; | 766 return true; |
763 if (uid == other.uid) | 767 if (uid == other.uid) |
764 return string_uid < other.string_uid; | 768 return string_uid < other.string_uid; |
765 } | 769 } |
766 } | 770 } |
767 return false; | 771 return false; |
768 } | 772 } |
OLD | NEW |