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

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

Issue 9960077: Modify the base::JSONReader interface to take a set of options rather than a boolean flag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 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 | Annotate | Revision Log
OLDNEW
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/app_notify_channel_setup.h" 5 #include "chrome/browser/extensions/app_notify_channel_setup.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 395
396 // static 396 // static
397 std::string AppNotifyChannelSetup::MakeAuthorizationHeader( 397 std::string AppNotifyChannelSetup::MakeAuthorizationHeader(
398 const std::string& auth_token) { 398 const std::string& auth_token) {
399 return StringPrintf(kAuthorizationHeaderFormat, auth_token.c_str()); 399 return StringPrintf(kAuthorizationHeaderFormat, auth_token.c_str());
400 } 400 }
401 401
402 // static 402 // static
403 bool AppNotifyChannelSetup::ParseCWSChannelServiceResponse( 403 bool AppNotifyChannelSetup::ParseCWSChannelServiceResponse(
404 const std::string& data, std::string* result) { 404 const std::string& data, std::string* result) {
405 base::JSONReader reader; 405 scoped_ptr<base::Value> value(base::JSONReader::Read(data));
406 scoped_ptr<base::Value> value(reader.Read(data, false));
407 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY) 406 if (!value.get() || value->GetType() != base::Value::TYPE_DICTIONARY)
408 return false; 407 return false;
409 408
410 Value* channel_id_value; 409 Value* channel_id_value;
411 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get()); 410 DictionaryValue* dict = static_cast<DictionaryValue*>(value.get());
412 if (!dict->Get("id", &channel_id_value)) 411 if (!dict->Get("id", &channel_id_value))
413 return false; 412 return false;
414 if (channel_id_value->GetType() != base::Value::TYPE_STRING) 413 if (channel_id_value->GetType() != base::Value::TYPE_STRING)
415 return false; 414 return false;
416 415
417 StringValue* channel_id = static_cast<StringValue*>(channel_id_value); 416 StringValue* channel_id = static_cast<StringValue*>(channel_id_value);
418 channel_id->GetAsString(result); 417 channel_id->GetAsString(result);
419 return true; 418 return true;
420 } 419 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698