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/memory/ptr_util.h" |
9 #include "base/values.h" | 10 #include "base/values.h" |
10 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/chromeos/settings/cros_settings.h" | 12 #include "chrome/browser/chromeos/settings/cros_settings.h" |
12 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" | 13 #include "chrome/browser/extensions/api/settings_private/prefs_util.h" |
13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" | 15 #include "chrome/browser/ui/zoom/chrome_zoom_level_prefs.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
17 #include "content/public/common/page_zoom.h" | 18 #include "content/public/common/page_zoom.h" |
18 #include "extensions/browser/extension_registry.h" | 19 #include "extensions/browser/extension_registry.h" |
(...skipping 10 matching lines...) Expand all Loading... |
29 } | 30 } |
30 | 31 |
31 SettingsPrivateDelegate::~SettingsPrivateDelegate() { | 32 SettingsPrivateDelegate::~SettingsPrivateDelegate() { |
32 } | 33 } |
33 | 34 |
34 std::unique_ptr<base::Value> SettingsPrivateDelegate::GetPref( | 35 std::unique_ptr<base::Value> SettingsPrivateDelegate::GetPref( |
35 const std::string& name) { | 36 const std::string& name) { |
36 std::unique_ptr<api::settings_private::PrefObject> pref = | 37 std::unique_ptr<api::settings_private::PrefObject> pref = |
37 prefs_util_->GetPref(name); | 38 prefs_util_->GetPref(name); |
38 if (!pref) | 39 if (!pref) |
39 return base::Value::CreateNullValue(); | 40 return base::MakeUnique<base::Value>(); |
40 return pref->ToValue(); | 41 return pref->ToValue(); |
41 } | 42 } |
42 | 43 |
43 std::unique_ptr<base::Value> SettingsPrivateDelegate::GetAllPrefs() { | 44 std::unique_ptr<base::Value> SettingsPrivateDelegate::GetAllPrefs() { |
44 std::unique_ptr<base::ListValue> prefs(new base::ListValue()); | 45 std::unique_ptr<base::ListValue> prefs(new base::ListValue()); |
45 | 46 |
46 const TypedPrefMap& keys = prefs_util_->GetWhitelistedKeys(); | 47 const TypedPrefMap& keys = prefs_util_->GetWhitelistedKeys(); |
47 for (const auto& it : keys) { | 48 for (const auto& it : keys) { |
48 std::unique_ptr<base::Value> pref = GetPref(it.first); | 49 std::unique_ptr<base::Value> pref = GetPref(it.first); |
49 if (!pref->IsType(base::Value::Type::NONE)) | 50 if (!pref->IsType(base::Value::Type::NONE)) |
(...skipping 16 matching lines...) Expand all Loading... |
66 } | 67 } |
67 | 68 |
68 PrefsUtil::SetPrefResult SettingsPrivateDelegate::SetDefaultZoom( | 69 PrefsUtil::SetPrefResult SettingsPrivateDelegate::SetDefaultZoom( |
69 double zoom) { | 70 double zoom) { |
70 double zoom_factor = content::ZoomFactorToZoomLevel(zoom); | 71 double zoom_factor = content::ZoomFactorToZoomLevel(zoom); |
71 profile_->GetZoomLevelPrefs()->SetDefaultZoomLevelPref(zoom_factor); | 72 profile_->GetZoomLevelPrefs()->SetDefaultZoomLevelPref(zoom_factor); |
72 return PrefsUtil::SetPrefResult::SUCCESS; | 73 return PrefsUtil::SetPrefResult::SUCCESS; |
73 } | 74 } |
74 | 75 |
75 } // namespace extensions | 76 } // namespace extensions |
OLD | NEW |