| 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" |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 item->SetChecked(checked); | 596 item->SetChecked(checked); |
| 597 properties->SetBoolean("checked", item->checked()); | 597 properties->SetBoolean("checked", item->checked()); |
| 598 | 598 |
| 599 const extensions::Extension* extension = ExtensionSystem::Get(profile_)-> | 599 const extensions::Extension* extension = ExtensionSystem::Get(profile_)-> |
| 600 extension_service()->GetExtensionById(menuItemId.extension_id, false); | 600 extension_service()->GetExtensionById(menuItemId.extension_id, false); |
| 601 WriteToPrefs(extension); | 601 WriteToPrefs(extension); |
| 602 } | 602 } |
| 603 | 603 |
| 604 std::string json_args; | 604 std::string json_args; |
| 605 base::JSONWriter::Write(&args, &json_args); | 605 base::JSONWriter::Write(&args, &json_args); |
| 606 std::string event_name = "contextMenus"; | |
| 607 event_router->DispatchEventToExtension( | 606 event_router->DispatchEventToExtension( |
| 608 item->extension_id(), event_name, json_args, profile, GURL(), | 607 item->extension_id(), "contextMenus", json_args, profile, GURL(), |
| 609 ExtensionEventRouter::USER_GESTURE_ENABLED); | 608 ExtensionEventRouter::USER_GESTURE_ENABLED); |
| 610 // TODO(yoz): dispatch another event onClicked. | 609 event_router->DispatchEventToExtension( |
| 610 item->extension_id(), "contextMenus.onClicked", |
| 611 json_args, profile, GURL(), |
| 612 ExtensionEventRouter::USER_GESTURE_ENABLED); |
| 611 } | 613 } |
| 612 | 614 |
| 613 void ExtensionMenuManager::SanitizeRadioList( | 615 void ExtensionMenuManager::SanitizeRadioList( |
| 614 const ExtensionMenuItem::List& item_list) { | 616 const ExtensionMenuItem::List& item_list) { |
| 615 ExtensionMenuItem::List::const_iterator i = item_list.begin(); | 617 ExtensionMenuItem::List::const_iterator i = item_list.begin(); |
| 616 while (i != item_list.end()) { | 618 while (i != item_list.end()) { |
| 617 if ((*i)->type() != ExtensionMenuItem::RADIO) { | 619 if ((*i)->type() != ExtensionMenuItem::RADIO) { |
| 618 ++i; | 620 ++i; |
| 619 break; | 621 break; |
| 620 } | 622 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 return true; | 761 return true; |
| 760 if (extension_id == other.extension_id) { | 762 if (extension_id == other.extension_id) { |
| 761 if (uid < other.uid) | 763 if (uid < other.uid) |
| 762 return true; | 764 return true; |
| 763 if (uid == other.uid) | 765 if (uid == other.uid) |
| 764 return string_uid < other.string_uid; | 766 return string_uid < other.string_uid; |
| 765 } | 767 } |
| 766 } | 768 } |
| 767 return false; | 769 return false; |
| 768 } | 770 } |
| OLD | NEW |