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 <tuple> | 8 #include <tuple> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 if (!item) | 85 if (!item) |
86 continue; | 86 continue; |
87 items.push_back(item); | 87 items.push_back(item); |
88 } | 88 } |
89 return items; | 89 return items; |
90 } | 90 } |
91 | 91 |
92 std::unique_ptr<base::Value> MenuItemsToValue(const MenuItem::List& items) { | 92 std::unique_ptr<base::Value> MenuItemsToValue(const MenuItem::List& items) { |
93 std::unique_ptr<base::ListValue> list(new base::ListValue()); | 93 std::unique_ptr<base::ListValue> list(new base::ListValue()); |
94 for (size_t i = 0; i < items.size(); ++i) | 94 for (size_t i = 0; i < items.size(); ++i) |
95 list->Append(items[i]->ToValue().release()); | 95 list->Append(items[i]->ToValue()); |
96 return std::unique_ptr<base::Value>(list.release()); | 96 return std::unique_ptr<base::Value>(list.release()); |
97 } | 97 } |
98 | 98 |
99 bool GetStringList(const base::DictionaryValue& dict, | 99 bool GetStringList(const base::DictionaryValue& dict, |
100 const std::string& key, | 100 const std::string& key, |
101 std::vector<std::string>* out) { | 101 std::vector<std::string>* out) { |
102 if (!dict.HasKey(key)) | 102 if (!dict.HasKey(key)) |
103 return true; | 103 return true; |
104 | 104 |
105 const base::ListValue* list = NULL; | 105 const base::ListValue* list = NULL; |
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 | 678 |
679 // Add the tab info to the argument list. | 679 // Add the tab info to the argument list. |
680 // No tab info in a platform app. | 680 // No tab info in a platform app. |
681 if (!extension || !extension->is_platform_app()) { | 681 if (!extension || !extension->is_platform_app()) { |
682 // Note: web_contents are NULL in unit tests :( | 682 // Note: web_contents are NULL in unit tests :( |
683 if (web_contents) { | 683 if (web_contents) { |
684 int frame_id = ExtensionApiFrameIdMap::GetFrameId(render_frame_host); | 684 int frame_id = ExtensionApiFrameIdMap::GetFrameId(render_frame_host); |
685 if (frame_id != ExtensionApiFrameIdMap::kInvalidFrameId) | 685 if (frame_id != ExtensionApiFrameIdMap::kInvalidFrameId) |
686 properties->SetInteger("frameId", frame_id); | 686 properties->SetInteger("frameId", frame_id); |
687 | 687 |
688 args->Append( | 688 args->Append(ExtensionTabUtil::CreateTabObject(web_contents)->ToValue()); |
689 ExtensionTabUtil::CreateTabObject(web_contents)->ToValue().release()); | |
690 } else { | 689 } else { |
691 args->Append(new base::DictionaryValue()); | 690 args->Append(new base::DictionaryValue()); |
692 } | 691 } |
693 } | 692 } |
694 | 693 |
695 if (item->type() == MenuItem::CHECKBOX || | 694 if (item->type() == MenuItem::CHECKBOX || |
696 item->type() == MenuItem::RADIO) { | 695 item->type() == MenuItem::RADIO) { |
697 bool was_checked = item->checked(); | 696 bool was_checked = item->checked(); |
698 properties->SetBoolean("wasChecked", was_checked); | 697 properties->SetBoolean("wasChecked", was_checked); |
699 | 698 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
986 bool MenuItem::Id::operator!=(const Id& other) const { | 985 bool MenuItem::Id::operator!=(const Id& other) const { |
987 return !(*this == other); | 986 return !(*this == other); |
988 } | 987 } |
989 | 988 |
990 bool MenuItem::Id::operator<(const Id& other) const { | 989 bool MenuItem::Id::operator<(const Id& other) const { |
991 return std::tie(incognito, extension_key, uid, string_uid) < | 990 return std::tie(incognito, extension_key, uid, string_uid) < |
992 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); | 991 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); |
993 } | 992 } |
994 | 993 |
995 } // namespace extensions | 994 } // namespace extensions |
OLD | NEW |