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()); | 212 value->Set(kContextsKey, contexts_.ToValue().release()); |
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, document_url_patterns_.ToValue()); | 217 value->Set(kDocumentURLPatternsKey, |
218 value->Set(kTargetURLPatternsKey, target_url_patterns_.ToValue()); | 218 document_url_patterns_.ToValue().release()); |
| 219 value->Set(kTargetURLPatternsKey, target_url_patterns_.ToValue().release()); |
219 return value; | 220 return value; |
220 } | 221 } |
221 | 222 |
222 // static | 223 // static |
223 std::unique_ptr<MenuItem> MenuItem::Populate(const std::string& extension_id, | 224 std::unique_ptr<MenuItem> MenuItem::Populate(const std::string& extension_id, |
224 const base::DictionaryValue& value, | 225 const base::DictionaryValue& value, |
225 std::string* error) { | 226 std::string* error) { |
226 bool incognito = false; | 227 bool incognito = false; |
227 if (!value.GetBoolean(kIncognitoKey, &incognito)) | 228 if (!value.GetBoolean(kIncognitoKey, &incognito)) |
228 return nullptr; | 229 return nullptr; |
(...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
963 bool MenuItem::Id::operator!=(const Id& other) const { | 964 bool MenuItem::Id::operator!=(const Id& other) const { |
964 return !(*this == other); | 965 return !(*this == other); |
965 } | 966 } |
966 | 967 |
967 bool MenuItem::Id::operator<(const Id& other) const { | 968 bool MenuItem::Id::operator<(const Id& other) const { |
968 return std::tie(incognito, extension_key, uid, string_uid) < | 969 return std::tie(incognito, extension_key, uid, string_uid) < |
969 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); | 970 std::tie(other.incognito, other.extension_key, other.uid, other.string_uid); |
970 } | 971 } |
971 | 972 |
972 } // namespace extensions | 973 } // namespace extensions |
OLD | NEW |