Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(78)

Side by Side Diff: chrome/browser/extensions/install_signer.cc

Issue 2806283002: Revert of Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/install_signer.h" 5 #include "chrome/browser/extensions/install_signer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/base64.h" 11 #include "base/base64.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/json/json_reader.h" 14 #include "base/json/json_reader.h"
15 #include "base/json/json_writer.h" 15 #include "base/json/json_writer.h"
16 #include "base/lazy_instance.h" 16 #include "base/lazy_instance.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/ptr_util.h"
19 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
20 #include "base/metrics/histogram_macros.h" 19 #include "base/metrics/histogram_macros.h"
21 #include "base/process/process_info.h" 20 #include "base/process/process_info.h"
22 #include "base/stl_util.h" 21 #include "base/stl_util.h"
23 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
24 #include "base/strings/string_split.h" 23 #include "base/strings/string_split.h"
25 #include "base/strings/string_util.h" 24 #include "base/strings/string_util.h"
26 #include "base/time/time.h" 25 #include "base/time/time.h"
27 #include "base/values.h" 26 #include "base/values.h"
28 #include "build/build_config.h" 27 #include "build/build_config.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 } 118 }
120 } 119 }
121 return true; 120 return true;
122 } 121 }
123 122
124 // Sets the value of |key| in |dictionary| to be a list with the contents of 123 // Sets the value of |key| in |dictionary| to be a list with the contents of
125 // |ids|. 124 // |ids|.
126 void SetExtensionIdSet(base::DictionaryValue* dictionary, 125 void SetExtensionIdSet(base::DictionaryValue* dictionary,
127 const char* key, 126 const char* key,
128 const ExtensionIdSet& ids) { 127 const ExtensionIdSet& ids) {
129 auto id_list = base::MakeUnique<base::ListValue>(); 128 base::ListValue* id_list = new base::ListValue();
130 for (ExtensionIdSet::const_iterator i = ids.begin(); i != ids.end(); ++i) 129 for (ExtensionIdSet::const_iterator i = ids.begin(); i != ids.end(); ++i)
131 id_list->AppendString(*i); 130 id_list->AppendString(*i);
132 dictionary->Set(key, std::move(id_list)); 131 dictionary->Set(key, id_list);
133 } 132 }
134 133
135 // Tries to fetch a list of strings from |dictionay| for |key|, and inserts 134 // Tries to fetch a list of strings from |dictionay| for |key|, and inserts
136 // them into |ids|. The return value indicates success/failure. Note: on 135 // them into |ids|. The return value indicates success/failure. Note: on
137 // failure, |ids| might contain partial results, for instance if some of the 136 // failure, |ids| might contain partial results, for instance if some of the
138 // members of the list were not strings. 137 // members of the list were not strings.
139 bool GetExtensionIdSet(const base::DictionaryValue& dictionary, 138 bool GetExtensionIdSet(const base::DictionaryValue& dictionary,
140 const char* key, 139 const char* key,
141 ExtensionIdSet* ids) { 140 ExtensionIdSet* ids) {
142 const base::ListValue* id_list = NULL; 141 const base::ListValue* id_list = NULL;
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 // "hash": "<base64-encoded hash value here>", 383 // "hash": "<base64-encoded hash value here>",
385 // "ids": [ "<id1>", "id2" ] 384 // "ids": [ "<id1>", "id2" ]
386 // } 385 // }
387 base::DictionaryValue dictionary; 386 base::DictionaryValue dictionary;
388 dictionary.SetInteger(kProtocolVersionKey, 1); 387 dictionary.SetInteger(kProtocolVersionKey, 1);
389 dictionary.SetString(kHashKey, hash_base64); 388 dictionary.SetString(kHashKey, hash_base64);
390 std::unique_ptr<base::ListValue> id_list(new base::ListValue); 389 std::unique_ptr<base::ListValue> id_list(new base::ListValue);
391 for (ExtensionIdSet::const_iterator i = ids_.begin(); i != ids_.end(); ++i) { 390 for (ExtensionIdSet::const_iterator i = ids_.begin(); i != ids_.end(); ++i) {
392 id_list->AppendString(*i); 391 id_list->AppendString(*i);
393 } 392 }
394 dictionary.Set(kIdsKey, std::move(id_list)); 393 dictionary.Set(kIdsKey, id_list.release());
395 std::string json; 394 std::string json;
396 base::JSONWriter::Write(dictionary, &json); 395 base::JSONWriter::Write(dictionary, &json);
397 if (json.empty()) { 396 if (json.empty()) {
398 ReportErrorViaCallback(); 397 ReportErrorViaCallback();
399 return; 398 return;
400 } 399 }
401 url_fetcher_->SetUploadData("application/json", json); 400 url_fetcher_->SetUploadData("application/json", json);
402 LogRequestStartHistograms(); 401 LogRequestStartHistograms();
403 request_start_time_ = base::Time::Now(); 402 request_start_time_ = base::Time::Now();
404 VLOG(1) << "Sending request: " << json; 403 VLOG(1) << "Sending request: " << json;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 if (!verified) 505 if (!verified)
507 result.reset(); 506 result.reset();
508 } 507 }
509 508
510 if (!callback_.is_null()) 509 if (!callback_.is_null())
511 callback_.Run(std::move(result)); 510 callback_.Run(std::move(result));
512 } 511 }
513 512
514 513
515 } // namespace extensions 514 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_pref_loader.cc ('k') | chrome/browser/extensions/menu_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698