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

Side by Side Diff: chrome/browser/chromeos/extensions/info_private_api.cc

Issue 11369258: Revert 167808 - Get rid of use of CreateStringValue in chromeos/ directory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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/chromeos/extensions/info_private_api.h" 5 #include "chrome/browser/chromeos/extensions/info_private_api.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/chromeos/cros/cros_library.h" 8 #include "chrome/browser/chromeos/cros/cros_library.h"
9 #include "chrome/browser/chromeos/cros/network_library.h" 9 #include "chrome/browser/chromeos/cros/network_library.h"
10 #include "chrome/browser/chromeos/login/user_manager.h" 10 #include "chrome/browser/chromeos/login/user_manager.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 GetChromeosInfoFunction::~GetChromeosInfoFunction() { 47 GetChromeosInfoFunction::~GetChromeosInfoFunction() {
48 } 48 }
49 49
50 bool GetChromeosInfoFunction::RunImpl() { 50 bool GetChromeosInfoFunction::RunImpl() {
51 ListValue* list = NULL; 51 ListValue* list = NULL;
52 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &list)); 52 EXTENSION_FUNCTION_VALIDATE(args_->GetList(0, &list));
53 scoped_ptr<DictionaryValue> result(new DictionaryValue()); 53 scoped_ptr<DictionaryValue> result(new DictionaryValue());
54 for (size_t i = 0; i < list->GetSize(); ++i) { 54 for (size_t i = 0; i < list->GetSize(); ++i) {
55 std::string property_name; 55 std::string property_name;
56 EXTENSION_FUNCTION_VALIDATE(list->GetString(i, &property_name)); 56 EXTENSION_FUNCTION_VALIDATE(list->GetString(i, &property_name));
57 Value* value = GetValue(property_name); 57 Value* value = NULL;
58 if (value) 58 if (GetValue(property_name, &value))
59 result->Set(property_name, value); 59 result->Set(property_name, value);
60 } 60 }
61 SetResult(result.release()); 61 SetResult(result.release());
62 SendResponse(true); 62 SendResponse(true);
63 return true; 63 return true;
64 } 64 }
65 65
66 base::Value* GetChromeosInfoFunction::GetValue( 66 bool GetChromeosInfoFunction::GetValue(const std::string& property_name,
67 const std::string& property_name) { 67 Value** value) {
68 if (property_name == kPropertyHWID) { 68 if (property_name == kPropertyHWID) {
69 std::string hwid; 69 std::string hwid;
70 chromeos::system::StatisticsProvider* provider = 70 chromeos::system::StatisticsProvider* provider =
71 chromeos::system::StatisticsProvider::GetInstance(); 71 chromeos::system::StatisticsProvider::GetInstance();
72 provider->GetMachineStatistic(kHardwareClass, &hwid); 72 provider->GetMachineStatistic(kHardwareClass, &hwid);
73 return new base::StringValue(hwid); 73 *value = Value::CreateStringValue(hwid);
74 } else if (property_name == kPropertyHomeProvider) { 74 } else if (property_name == kPropertyHomeProvider) {
75 NetworkLibrary* netlib = CrosLibrary::Get()->GetNetworkLibrary(); 75 NetworkLibrary* netlib = CrosLibrary::Get()->GetNetworkLibrary();
76 return new base::StringValue(netlib->GetCellularHomeCarrierId()); 76 *value = Value::CreateStringValue(netlib->GetCellularHomeCarrierId());
77 } else if (property_name == kPropertyInitialLocale) { 77 } else if (property_name == kPropertyInitialLocale) {
78 return new base::StringValue( 78 *value = Value::CreateStringValue(
79 chromeos::WizardController::GetInitialLocale()); 79 chromeos::WizardController::GetInitialLocale());
80 } else if (property_name == kPropertyBoard) { 80 } else if (property_name == kPropertyBoard) {
81 std::string board; 81 std::string board;
82 chromeos::system::StatisticsProvider* provider = 82 chromeos::system::StatisticsProvider* provider =
83 chromeos::system::StatisticsProvider::GetInstance(); 83 chromeos::system::StatisticsProvider::GetInstance();
84 provider->GetMachineStatistic(kPropertyReleaseBoard, &board); 84 provider->GetMachineStatistic(kPropertyReleaseBoard, &board);
85 return new base::StringValue(board); 85 *value = Value::CreateStringValue(board);
86 } else if (property_name == kPropertyOwner) { 86 } else if (property_name == kPropertyOwner) {
87 return Value::CreateBooleanValue( 87 *value = Value::CreateBooleanValue(
88 chromeos::UserManager::Get()->IsCurrentUserOwner()); 88 chromeos::UserManager::Get()->IsCurrentUserOwner());
89 } else {
90 LOG(ERROR) << "Unknown property request: " << property_name;
91 return false;
89 } 92 }
90 93 return true;
91 DLOG(ERROR) << "Unknown property request: " << property_name;
92 return NULL;
93 } 94 }
94 95
95 } // namespace extensions 96 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/info_private_api.h ('k') | chrome/browser/chromeos/login/user_image_manager_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698