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 <memory> | 8 #include <memory> |
9 #include <tuple> | 9 #include <tuple> |
10 #include <utility> | 10 #include <utility> |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 // string IDs for items. | 202 // string IDs for items. |
203 DCHECK_EQ(0, id_.uid); | 203 DCHECK_EQ(0, id_.uid); |
204 value->SetString(kStringUIDKey, id_.string_uid); | 204 value->SetString(kStringUIDKey, id_.string_uid); |
205 value->SetBoolean(kIncognitoKey, id_.incognito); | 205 value->SetBoolean(kIncognitoKey, id_.incognito); |
206 value->SetInteger(kTypeKey, type_); | 206 value->SetInteger(kTypeKey, type_); |
207 if (type_ != SEPARATOR) | 207 if (type_ != SEPARATOR) |
208 value->SetString(kTitleKey, title_); | 208 value->SetString(kTitleKey, title_); |
209 if (type_ == CHECKBOX || type_ == RADIO) | 209 if (type_ == CHECKBOX || type_ == RADIO) |
210 value->SetBoolean(kCheckedKey, checked_); | 210 value->SetBoolean(kCheckedKey, checked_); |
211 value->SetBoolean(kEnabledKey, enabled_); | 211 value->SetBoolean(kEnabledKey, enabled_); |
212 value->Set(kContextsKey, contexts_.ToValue().release()); | 212 value->Set(kContextsKey, contexts_.ToValue()); |
213 if (parent_id_) { | 213 if (parent_id_) { |
214 DCHECK_EQ(0, parent_id_->uid); | 214 DCHECK_EQ(0, parent_id_->uid); |
215 value->SetString(kParentUIDKey, parent_id_->string_uid); | 215 value->SetString(kParentUIDKey, parent_id_->string_uid); |
216 } | 216 } |
217 value->Set(kDocumentURLPatternsKey, | 217 value->Set(kDocumentURLPatternsKey, document_url_patterns_.ToValue()); |
218 document_url_patterns_.ToValue().release()); | 218 value->Set(kTargetURLPatternsKey, target_url_patterns_.ToValue()); |
219 value->Set(kTargetURLPatternsKey, target_url_patterns_.ToValue().release()); | |
220 return value; | 219 return value; |
221 } | 220 } |
222 | 221 |
223 // static | 222 // static |
224 std::unique_ptr<MenuItem> MenuItem::Populate(const std::string& extension_id, | 223 std::unique_ptr<MenuItem> MenuItem::Populate(const std::string& extension_id, |
225 const base::DictionaryValue& value, | 224 const base::DictionaryValue& value, |
226 std::string* error) { | 225 std::string* error) { |
227 bool incognito = false; | 226 bool incognito = false; |
228 if (!value.GetBoolean(kIncognitoKey, &incognito)) | 227 if (!value.GetBoolean(kIncognitoKey, &incognito)) |
229 return nullptr; | 228 return nullptr; |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 bool MenuItem::Id::operator!=(const Id& other) const { | 963 bool MenuItem::Id::operator!=(const Id& other) const { |
965 return !(*this == other); | 964 return !(*this == other); |
966 } | 965 } |
967 | 966 |
968 bool MenuItem::Id::operator<(const Id& other) const { | 967 bool MenuItem::Id::operator<(const Id& other) const { |
969 return std::tie(incognito, extension_key, uid, string_uid) < | 968 return std::tie(incognito, extension_key, uid, string_uid) < |
970 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); | 969 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); |
971 } | 970 } |
972 | 971 |
973 } // namespace extensions | 972 } // namespace extensions |
OLD | NEW |