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

Side by Side Diff: chrome/browser/download/download_dir_policy_handler.cc

Issue 78763002: Move PolicyMap and its dependencies to components/policy/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: export nested struct Created 7 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 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/download/download_dir_policy_handler.h" 5 #include "chrome/browser/download/download_dir_policy_handler.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/prefs/pref_value_map.h" 9 #include "base/prefs/pref_value_map.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/download/download_prefs.h" 11 #include "chrome/browser/download/download_prefs.h"
12 #include "chrome/browser/policy/policy_map.h"
13 #include "chrome/browser/policy/policy_path_parser.h" 12 #include "chrome/browser/policy/policy_path_parser.h"
14 #include "chrome/common/pref_names.h" 13 #include "chrome/common/pref_names.h"
14 #include "components/policy/core/common/policy_map.h"
15 #include "policy/policy_constants.h" 15 #include "policy/policy_constants.h"
16 16
17 DownloadDirPolicyHandler::DownloadDirPolicyHandler() 17 DownloadDirPolicyHandler::DownloadDirPolicyHandler()
18 : TypeCheckingPolicyHandler(policy::key::kDownloadDirectory, 18 : TypeCheckingPolicyHandler(policy::key::kDownloadDirectory,
19 base::Value::TYPE_STRING) {} 19 base::Value::TYPE_STRING) {}
20 20
21 DownloadDirPolicyHandler::~DownloadDirPolicyHandler() {} 21 DownloadDirPolicyHandler::~DownloadDirPolicyHandler() {}
22 22
23 void DownloadDirPolicyHandler::ApplyPolicySettings( 23 void DownloadDirPolicyHandler::ApplyPolicySettings(
24 const policy::PolicyMap& policies, 24 const policy::PolicyMap& policies,
25 PrefValueMap* prefs) { 25 PrefValueMap* prefs) {
26 const base::Value* value = policies.GetValue(policy_name()); 26 const base::Value* value = policies.GetValue(policy_name());
27 base::FilePath::StringType string_value; 27 base::FilePath::StringType string_value;
28 if (!value || !value->GetAsString(&string_value)) 28 if (!value || !value->GetAsString(&string_value))
29 return; 29 return;
30 30
31 base::FilePath::StringType expanded_value = 31 base::FilePath::StringType expanded_value =
32 policy::path_parser::ExpandPathVariables(string_value); 32 policy::path_parser::ExpandPathVariables(string_value);
33 // Make sure the path isn't empty, since that will point to an undefined 33 // Make sure the path isn't empty, since that will point to an undefined
34 // location; the default location is used instead in that case. 34 // location; the default location is used instead in that case.
35 // This is checked after path expansion because a non-empty policy value can 35 // This is checked after path expansion because a non-empty policy value can
36 // lead to an empty path value after expansion (e.g. "\"\""). 36 // lead to an empty path value after expansion (e.g. "\"\"").
37 if (expanded_value.empty()) 37 if (expanded_value.empty())
38 expanded_value = DownloadPrefs::GetDefaultDownloadDirectory().value(); 38 expanded_value = DownloadPrefs::GetDefaultDownloadDirectory().value();
39 prefs->SetValue(prefs::kDownloadDefaultDirectory, 39 prefs->SetValue(prefs::kDownloadDefaultDirectory,
40 Value::CreateStringValue(expanded_value)); 40 Value::CreateStringValue(expanded_value));
41 prefs->SetValue(prefs::kPromptForDownload, 41 prefs->SetValue(prefs::kPromptForDownload,
42 Value::CreateBooleanValue(false)); 42 Value::CreateBooleanValue(false));
43 } 43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698