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

Side by Side Diff: chrome/browser/chromeos/options/network_property_ui_data.cc

Issue 433143002: Split onc::IsRecommendedValue into onc_utils.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update comments Created 6 years, 4 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
« no previous file with comments | « no previous file | chromeos/network/onc/onc_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/chromeos/options/network_property_ui_data.h" 5 #include "chrome/browser/chromeos/options/network_property_ui_data.h"
6 6
7 #include "base/logging.h"
7 #include "base/values.h" 8 #include "base/values.h"
9 #include "chromeos/network/onc/onc_utils.h"
8 10
9 namespace chromeos { 11 namespace chromeos {
10 12
11 NetworkPropertyUIData::NetworkPropertyUIData() 13 NetworkPropertyUIData::NetworkPropertyUIData()
12 : onc_source_(onc::ONC_SOURCE_NONE) { 14 : onc_source_(::onc::ONC_SOURCE_NONE) {
13 } 15 }
14 16
15 NetworkPropertyUIData::NetworkPropertyUIData(onc::ONCSource onc_source) 17 NetworkPropertyUIData::NetworkPropertyUIData(::onc::ONCSource onc_source)
16 : onc_source_(onc_source) { 18 : onc_source_(onc_source) {
17 } 19 }
18 20
19 NetworkPropertyUIData::~NetworkPropertyUIData() { 21 NetworkPropertyUIData::~NetworkPropertyUIData() {
20 } 22 }
21 23
22 void NetworkPropertyUIData::ParseOncProperty(onc::ONCSource onc_source, 24 void NetworkPropertyUIData::ParseOncProperty(::onc::ONCSource onc_source,
23 const base::DictionaryValue* onc, 25 const base::DictionaryValue* onc,
24 const std::string& property_key) { 26 const std::string& property_key) {
25 default_value_.reset(); 27 default_value_.reset();
26 onc_source_ = onc_source; 28 onc_source_ = onc_source;
27 29
28 if (!onc || !IsManaged()) 30 if (!onc || !IsManaged())
29 return; 31 return;
30 32
31 size_t pos = property_key.find_last_of('.'); 33 if (!onc::IsRecommendedValue(onc, property_key))
32 std::string recommended_property_key; 34 return;
33 std::string property_basename(property_key); 35
34 if (pos != std::string::npos) { 36 // Set onc_source_ to NONE to indicate that the value is not enforced.
35 recommended_property_key = property_key.substr(0, pos + 1); 37 onc_source_ = ::onc::ONC_SOURCE_NONE;
36 property_basename = property_key.substr(pos + 1); 38
39 const base::Value* default_value = NULL;
40 if (!onc->Get(property_key, &default_value)) {
41 // No default entry indicates that the property can be modified by the user,
42 // but has no default value, e.g. Username or Passphrase. (The default
43 // behavior for a property with no entry is non user modifiable).
44 return;
37 } 45 }
38 recommended_property_key += "Recommended";
39 46
40 const base::ListValue* recommended_keys = NULL; 47 // Set the recommended (default) value.
41 if (onc->GetList(recommended_property_key, &recommended_keys)) { 48 default_value_.reset(default_value->DeepCopy());
42 base::StringValue basename_value(property_basename);
43 if (recommended_keys->Find(basename_value) != recommended_keys->end()) {
44 onc_source_ = onc::ONC_SOURCE_NONE;
45 const base::Value* default_value = NULL;
46 if (onc->Get(property_key, &default_value))
47 default_value_.reset(default_value->DeepCopy());
48 }
49 }
50 } 49 }
51 50
52 } // namespace chromeos 51 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chromeos/network/onc/onc_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698