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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.cc

Issue 2792573002: Remove base::Value::CreateNullValue (Closed)
Patch Set: Rebase 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 (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/ui/webui/options/chromeos/core_chromeos_options_handler .h" 5 #include "chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler .h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 for (auto it : pref_subscription_map_) 170 for (auto it : pref_subscription_map_)
171 NotifySettingsChanged(it.first); 171 NotifySettingsChanged(it.first);
172 } 172 }
173 173
174 base::Value* CoreChromeOSOptionsHandler::FetchPref( 174 base::Value* CoreChromeOSOptionsHandler::FetchPref(
175 const std::string& pref_name) { 175 const std::string& pref_name) {
176 if (proxy_cros_settings_parser::IsProxyPref(pref_name)) { 176 if (proxy_cros_settings_parser::IsProxyPref(pref_name)) {
177 base::Value* value = nullptr; 177 base::Value* value = nullptr;
178 proxy_cros_settings_parser::GetProxyPrefValue( 178 proxy_cros_settings_parser::GetProxyPrefValue(
179 network_guid_, pref_name, GetUiProxyConfigService(), &value); 179 network_guid_, pref_name, GetUiProxyConfigService(), &value);
180 return value ? value : base::Value::CreateNullValue().release(); 180 return value ? value : new base::Value();
181 } 181 }
182 182
183 Profile* profile = Profile::FromWebUI(web_ui()); 183 Profile* profile = Profile::FromWebUI(web_ui());
184 if (!CrosSettings::IsCrosSettings(pref_name)) { 184 if (!CrosSettings::IsCrosSettings(pref_name)) {
185 std::string controlling_pref = 185 std::string controlling_pref =
186 pref_name == proxy_config::prefs::kUseSharedProxies 186 pref_name == proxy_config::prefs::kUseSharedProxies
187 ? proxy_config::prefs::kProxy 187 ? proxy_config::prefs::kProxy
188 : std::string(); 188 : std::string();
189 base::Value* value = CreateValueForPref(pref_name, controlling_pref); 189 base::Value* value = CreateValueForPref(pref_name, controlling_pref);
190 if (!IsSettingShared(pref_name) || !IsSecondaryUser(profile)) 190 if (!IsSettingShared(pref_name) || !IsSecondaryUser(profile))
191 return value; 191 return value;
192 base::DictionaryValue* dict; 192 base::DictionaryValue* dict;
193 if (!value->GetAsDictionary(&dict) || dict->HasKey("controlledBy")) 193 if (!value->GetAsDictionary(&dict) || dict->HasKey("controlledBy"))
194 return value; 194 return value;
195 Profile* primary_profile = ProfileHelper::Get()->GetProfileByUser( 195 Profile* primary_profile = ProfileHelper::Get()->GetProfileByUser(
196 user_manager::UserManager::Get()->GetPrimaryUser()); 196 user_manager::UserManager::Get()->GetPrimaryUser());
197 if (!primary_profile) 197 if (!primary_profile)
198 return value; 198 return value;
199 dict->SetString("controlledBy", "shared"); 199 dict->SetString("controlledBy", "shared");
200 dict->SetBoolean("disabled", true); 200 dict->SetBoolean("disabled", true);
201 dict->SetBoolean("value", primary_profile->GetPrefs()->GetBoolean( 201 dict->SetBoolean("value", primary_profile->GetPrefs()->GetBoolean(
202 pref_name)); 202 pref_name));
203 return dict; 203 return dict;
204 } 204 }
205 205
206 const base::Value* pref_value = CrosSettings::Get()->GetPref(pref_name); 206 const base::Value* pref_value = CrosSettings::Get()->GetPref(pref_name);
207 if (!pref_value) 207 if (!pref_value)
208 return base::Value::CreateNullValue().release(); 208 return new base::Value();
209 209
210 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does. 210 // Decorate pref value as CoreOptionsHandler::CreateValueForPref() does.
211 // TODO(estade): seems that this should replicate CreateValueForPref less. 211 // TODO(estade): seems that this should replicate CreateValueForPref less.
212 base::DictionaryValue* dict = new base::DictionaryValue; 212 base::DictionaryValue* dict = new base::DictionaryValue;
213 if (pref_name == kAccountsPrefUsers) 213 if (pref_name == kAccountsPrefUsers)
214 dict->Set("value", CreateUsersWhitelist(pref_value)); 214 dict->Set("value", CreateUsersWhitelist(pref_value));
215 else 215 else
216 dict->Set("value", pref_value->DeepCopy()); 216 dict->Set("value", pref_value->DeepCopy());
217 217
218 std::string controlled_by; 218 std::string controlled_by;
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 GetUiProxyConfigService(), &value); 417 GetUiProxyConfigService(), &value);
418 DCHECK(value); 418 DCHECK(value);
419 std::unique_ptr<base::Value> ptr(value); 419 std::unique_ptr<base::Value> ptr(value);
420 DispatchPrefChangeNotification( 420 DispatchPrefChangeNotification(
421 proxy_cros_settings_parser::kProxySettings[i], std::move(ptr)); 421 proxy_cros_settings_parser::kProxySettings[i], std::move(ptr));
422 } 422 }
423 } 423 }
424 424
425 } // namespace options 425 } // namespace options
426 } // namespace chromeos 426 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698