| OLD | NEW |
| 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 "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 result.reset(); | 148 result.reset(); |
| 149 return result.Pass(); | 149 return result.Pass(); |
| 150 } | 150 } |
| 151 | 151 |
| 152 const base::ListValue* ids = NULL; | 152 const base::ListValue* ids = NULL; |
| 153 if (!value.GetList(kIdsKey, &ids)) { | 153 if (!value.GetList(kIdsKey, &ids)) { |
| 154 result.reset(); | 154 result.reset(); |
| 155 return result.Pass(); | 155 return result.Pass(); |
| 156 } | 156 } |
| 157 | 157 |
| 158 for (ListValue::const_iterator i = ids->begin(); i != ids->end(); ++i) { | 158 for (base::ListValue::const_iterator i = ids->begin(); i != ids->end(); ++i) { |
| 159 std::string id; | 159 std::string id; |
| 160 if (!(*i)->GetAsString(&id)) { | 160 if (!(*i)->GetAsString(&id)) { |
| 161 result.reset(); | 161 result.reset(); |
| 162 return result.Pass(); | 162 return result.Pass(); |
| 163 } | 163 } |
| 164 result->ids.insert(id); | 164 result->ids.insert(id); |
| 165 } | 165 } |
| 166 | 166 |
| 167 return result.Pass(); | 167 return result.Pass(); |
| 168 } | 168 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 | 282 |
| 283 // The request protocol is JSON of the form: | 283 // The request protocol is JSON of the form: |
| 284 // { | 284 // { |
| 285 // "protocol_version": "1", | 285 // "protocol_version": "1", |
| 286 // "hash": "<base64-encoded hash value here>", | 286 // "hash": "<base64-encoded hash value here>", |
| 287 // "ids": [ "<id1>", "id2" ] | 287 // "ids": [ "<id1>", "id2" ] |
| 288 // } | 288 // } |
| 289 base::DictionaryValue dictionary; | 289 base::DictionaryValue dictionary; |
| 290 dictionary.SetInteger(kProtocolVersionKey, 1); | 290 dictionary.SetInteger(kProtocolVersionKey, 1); |
| 291 dictionary.SetString(kHashKey, hash_base64); | 291 dictionary.SetString(kHashKey, hash_base64); |
| 292 scoped_ptr<ListValue> id_list(new ListValue); | 292 scoped_ptr<base::ListValue> id_list(new base::ListValue); |
| 293 for (ExtensionIdSet::const_iterator i = ids_.begin(); i != ids_.end(); ++i) { | 293 for (ExtensionIdSet::const_iterator i = ids_.begin(); i != ids_.end(); ++i) { |
| 294 id_list->AppendString(*i); | 294 id_list->AppendString(*i); |
| 295 } | 295 } |
| 296 dictionary.Set(kIdsKey, id_list.release()); | 296 dictionary.Set(kIdsKey, id_list.release()); |
| 297 std::string json; | 297 std::string json; |
| 298 base::JSONWriter::Write(&dictionary, &json); | 298 base::JSONWriter::Write(&dictionary, &json); |
| 299 if (json.empty()) { | 299 if (json.empty()) { |
| 300 ReportErrorViaCallback(); | 300 ReportErrorViaCallback(); |
| 301 return; | 301 return; |
| 302 } | 302 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 result.reset(); | 386 result.reset(); |
| 387 } | 387 } |
| 388 } | 388 } |
| 389 | 389 |
| 390 if (!callback_.is_null()) | 390 if (!callback_.is_null()) |
| 391 callback_.Run(result.Pass()); | 391 callback_.Run(result.Pass()); |
| 392 } | 392 } |
| 393 | 393 |
| 394 | 394 |
| 395 } // namespace extensions | 395 } // namespace extensions |
| OLD | NEW |