OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/api/settings_private/settings_private_delega
te.h" | 5 #include "chrome/browser/extensions/api/settings_private/settings_private_delega
te.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 namespace settings_private = api::settings_private; | 24 namespace settings_private = api::settings_private; |
25 | 25 |
26 SettingsPrivateDelegate::SettingsPrivateDelegate(Profile* profile) | 26 SettingsPrivateDelegate::SettingsPrivateDelegate(Profile* profile) |
27 : profile_(profile) { | 27 : profile_(profile) { |
28 prefs_util_.reset(new PrefsUtil(profile)); | 28 prefs_util_.reset(new PrefsUtil(profile)); |
29 } | 29 } |
30 | 30 |
31 SettingsPrivateDelegate::~SettingsPrivateDelegate() { | 31 SettingsPrivateDelegate::~SettingsPrivateDelegate() { |
32 } | 32 } |
33 | 33 |
34 scoped_ptr<base::Value> SettingsPrivateDelegate::GetPref( | 34 std::unique_ptr<base::Value> SettingsPrivateDelegate::GetPref( |
35 const std::string& name) { | 35 const std::string& name) { |
36 scoped_ptr<api::settings_private::PrefObject> pref = | 36 std::unique_ptr<api::settings_private::PrefObject> pref = |
37 prefs_util_->GetPref(name); | 37 prefs_util_->GetPref(name); |
38 if (!pref) | 38 if (!pref) |
39 return base::Value::CreateNullValue(); | 39 return base::Value::CreateNullValue(); |
40 return pref->ToValue(); | 40 return pref->ToValue(); |
41 } | 41 } |
42 | 42 |
43 scoped_ptr<base::Value> SettingsPrivateDelegate::GetAllPrefs() { | 43 std::unique_ptr<base::Value> SettingsPrivateDelegate::GetAllPrefs() { |
44 scoped_ptr<base::ListValue> prefs(new base::ListValue()); | 44 std::unique_ptr<base::ListValue> prefs(new base::ListValue()); |
45 | 45 |
46 const TypedPrefMap& keys = prefs_util_->GetWhitelistedKeys(); | 46 const TypedPrefMap& keys = prefs_util_->GetWhitelistedKeys(); |
47 for (const auto& it : keys) { | 47 for (const auto& it : keys) { |
48 scoped_ptr<base::Value> pref = GetPref(it.first); | 48 std::unique_ptr<base::Value> pref = GetPref(it.first); |
49 if (!pref->IsType(base::Value::TYPE_NULL)) | 49 if (!pref->IsType(base::Value::TYPE_NULL)) |
50 prefs->Append(pref.release()); | 50 prefs->Append(pref.release()); |
51 } | 51 } |
52 | 52 |
53 return std::move(prefs); | 53 return std::move(prefs); |
54 } | 54 } |
55 | 55 |
56 PrefsUtil::SetPrefResult SettingsPrivateDelegate::SetPref( | 56 PrefsUtil::SetPrefResult SettingsPrivateDelegate::SetPref( |
57 const std::string& pref_name, const base::Value* value) { | 57 const std::string& pref_name, const base::Value* value) { |
58 return prefs_util_->SetPref(pref_name, value); | 58 return prefs_util_->SetPref(pref_name, value); |
59 } | 59 } |
60 | 60 |
61 scoped_ptr<base::Value> SettingsPrivateDelegate::GetDefaultZoomPercent() { | 61 std::unique_ptr<base::Value> SettingsPrivateDelegate::GetDefaultZoomPercent() { |
62 double zoom = content::ZoomLevelToZoomFactor( | 62 double zoom = content::ZoomLevelToZoomFactor( |
63 profile_->GetZoomLevelPrefs()->GetDefaultZoomLevelPref()) * 100; | 63 profile_->GetZoomLevelPrefs()->GetDefaultZoomLevelPref()) * 100; |
64 scoped_ptr<base::Value> value(new base::FundamentalValue(zoom)); | 64 std::unique_ptr<base::Value> value(new base::FundamentalValue(zoom)); |
65 return value; | 65 return value; |
66 } | 66 } |
67 | 67 |
68 PrefsUtil::SetPrefResult SettingsPrivateDelegate::SetDefaultZoomPercent( | 68 PrefsUtil::SetPrefResult SettingsPrivateDelegate::SetDefaultZoomPercent( |
69 int percent) { | 69 int percent) { |
70 double zoom_factor = content::ZoomFactorToZoomLevel(percent * 0.01); | 70 double zoom_factor = content::ZoomFactorToZoomLevel(percent * 0.01); |
71 profile_->GetZoomLevelPrefs()->SetDefaultZoomLevelPref(zoom_factor); | 71 profile_->GetZoomLevelPrefs()->SetDefaultZoomLevelPref(zoom_factor); |
72 return PrefsUtil::SetPrefResult::SUCCESS; | 72 return PrefsUtil::SetPrefResult::SUCCESS; |
73 } | 73 } |
74 | 74 |
75 } // namespace extensions | 75 } // namespace extensions |
OLD | NEW |