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

Side by Side Diff: chrome/browser/chromeos/arc/arc_settings_service.cc

Issue 2126203002: Send setting for enabling Android backup to container. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass whether the setting is enforced by policy Created 4 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/chromeos/arc/arc_settings_service.h" 5 #include "chrome/browser/chromeos/arc/arc_settings_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 88
89 // Retrives Chrome's state for the settings and send it to Android. 89 // Retrives Chrome's state for the settings and send it to Android.
90 void SyncAllPrefs() const; 90 void SyncAllPrefs() const;
91 void SyncFontSize() const; 91 void SyncFontSize() const;
92 void SyncLocale() const; 92 void SyncLocale() const;
93 void SyncProxySettings() const; 93 void SyncProxySettings() const;
94 void SyncReportingConsent() const; 94 void SyncReportingConsent() const;
95 void SyncSpokenFeedbackEnabled() const; 95 void SyncSpokenFeedbackEnabled() const;
96 void SyncTimeZone() const; 96 void SyncTimeZone() const;
97 void SyncUse24HourClock() const; 97 void SyncUse24HourClock() const;
98 void SyncBackupEnabled() const;
98 99
99 void OnBluetoothAdapterInitialized( 100 void OnBluetoothAdapterInitialized(
100 scoped_refptr<device::BluetoothAdapter> adapter); 101 scoped_refptr<device::BluetoothAdapter> adapter);
101 102
102 // Registers to listen to a particular perf. 103 // Registers to listen to a particular perf.
103 void AddPrefToObserve(const std::string& pref_name); 104 void AddPrefToObserve(const std::string& pref_name);
104 105
105 // Returns the integer value of the pref. pref_name must exist. 106 // Returns the integer value of the pref. pref_name must exist.
106 int GetIntegerPref(const std::string& pref_name) const; 107 int GetIntegerPref(const std::string& pref_name) const;
107 108
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 void ArcSettingsServiceImpl::StartObservingSettingsChanges() { 143 void ArcSettingsServiceImpl::StartObservingSettingsChanges() {
143 Profile* profile = ProfileManager::GetActiveUserProfile(); 144 Profile* profile = ProfileManager::GetActiveUserProfile();
144 registrar_.Init(profile->GetPrefs()); 145 registrar_.Init(profile->GetPrefs());
145 146
146 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize); 147 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize);
147 AddPrefToObserve(prefs::kWebKitDefaultFontSize); 148 AddPrefToObserve(prefs::kWebKitDefaultFontSize);
148 AddPrefToObserve(prefs::kWebKitMinimumFontSize); 149 AddPrefToObserve(prefs::kWebKitMinimumFontSize);
149 AddPrefToObserve(prefs::kAccessibilitySpokenFeedbackEnabled); 150 AddPrefToObserve(prefs::kAccessibilitySpokenFeedbackEnabled);
150 AddPrefToObserve(prefs::kUse24HourClock); 151 AddPrefToObserve(prefs::kUse24HourClock);
151 AddPrefToObserve(proxy_config::prefs::kProxy); 152 AddPrefToObserve(proxy_config::prefs::kProxy);
153 AddPrefToObserve(prefs::kArcBackupRestoreEnabled);
152 154
153 reporting_consent_subscription_ = CrosSettings::Get()->AddSettingsObserver( 155 reporting_consent_subscription_ = CrosSettings::Get()->AddSettingsObserver(
154 chromeos::kStatsReportingPref, 156 chromeos::kStatsReportingPref,
155 base::Bind(&ArcSettingsServiceImpl::SyncReportingConsent, 157 base::Bind(&ArcSettingsServiceImpl::SyncReportingConsent,
156 base::Unretained(this))); 158 base::Unretained(this)));
157 159
158 TimezoneSettings::GetInstance()->AddObserver(this); 160 TimezoneSettings::GetInstance()->AddObserver(this);
159 161
160 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { 162 if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) {
161 device::BluetoothAdapterFactory::GetAdapter( 163 device::BluetoothAdapterFactory::GetAdapter(
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 if (pref_name == prefs::kAccessibilitySpokenFeedbackEnabled) { 210 if (pref_name == prefs::kAccessibilitySpokenFeedbackEnabled) {
209 SyncSpokenFeedbackEnabled(); 211 SyncSpokenFeedbackEnabled();
210 } else if (pref_name == prefs::kWebKitDefaultFixedFontSize || 212 } else if (pref_name == prefs::kWebKitDefaultFixedFontSize ||
211 pref_name == prefs::kWebKitDefaultFontSize || 213 pref_name == prefs::kWebKitDefaultFontSize ||
212 pref_name == prefs::kWebKitMinimumFontSize) { 214 pref_name == prefs::kWebKitMinimumFontSize) {
213 SyncFontSize(); 215 SyncFontSize();
214 } else if (pref_name == prefs::kUse24HourClock) { 216 } else if (pref_name == prefs::kUse24HourClock) {
215 SyncUse24HourClock(); 217 SyncUse24HourClock();
216 } else if (pref_name == proxy_config::prefs::kProxy) { 218 } else if (pref_name == proxy_config::prefs::kProxy) {
217 SyncProxySettings(); 219 SyncProxySettings();
220 } else if (pref_name == prefs::kArcBackupRestoreEnabled) {
221 SyncBackupEnabled();
218 } else { 222 } else {
219 LOG(ERROR) << "Unknown pref changed."; 223 LOG(ERROR) << "Unknown pref changed.";
220 } 224 }
221 } 225 }
222 226
223 void ArcSettingsServiceImpl::TimezoneChanged(const icu::TimeZone& timezone) { 227 void ArcSettingsServiceImpl::TimezoneChanged(const icu::TimeZone& timezone) {
224 SyncTimeZone(); 228 SyncTimeZone();
225 } 229 }
226 230
227 int ArcSettingsServiceImpl::GetIntegerPref(const std::string& pref_name) const { 231 int ArcSettingsServiceImpl::GetIntegerPref(const std::string& pref_name) const {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 break; 359 break;
356 } 360 }
357 default: 361 default:
358 LOG(ERROR) << "Incorrect proxy mode."; 362 LOG(ERROR) << "Incorrect proxy mode.";
359 return; 363 return;
360 } 364 }
361 365
362 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_PROXY", extras); 366 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_PROXY", extras);
363 } 367 }
364 368
369 void ArcSettingsServiceImpl::SyncBackupEnabled() const {
370 const PrefService::Preference* const pref =
371 registrar_.prefs()->FindPreference(prefs::kArcBackupRestoreEnabled);
372 DCHECK(pref);
373 bool enabled = false;
374 bool value_exists = pref->GetValue()->GetAsBoolean(&enabled);
375 DCHECK(value_exists);
376 base::DictionaryValue extras;
377 extras.SetBoolean("enabled", enabled);
378 extras.SetBoolean("managed", !pref->IsUserModifiable());
379 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_BACKUP_ENABLED",
380 extras);
381 }
382
365 void ArcSettingsServiceImpl::SendSettingsBroadcast( 383 void ArcSettingsServiceImpl::SendSettingsBroadcast(
366 const std::string& action, 384 const std::string& action,
367 const base::DictionaryValue& extras) const { 385 const base::DictionaryValue& extras) const {
368 if (!arc_bridge_service_->intent_helper()->instance()) { 386 if (!arc_bridge_service_->intent_helper()->instance()) {
369 LOG(ERROR) << "IntentHelper instance is not ready."; 387 LOG(ERROR) << "IntentHelper instance is not ready.";
370 return; 388 return;
371 } 389 }
372 390
373 std::string extras_json; 391 std::string extras_json;
374 bool write_success = base::JSONWriter::Write(extras, &extras_json); 392 bool write_success = base::JSONWriter::Write(extras, &extras_json);
(...skipping 17 matching lines...) Expand all
392 410
393 void ArcSettingsService::OnInstanceReady() { 411 void ArcSettingsService::OnInstanceReady() {
394 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); 412 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service()));
395 } 413 }
396 414
397 void ArcSettingsService::OnInstanceClosed() { 415 void ArcSettingsService::OnInstanceClosed() {
398 impl_.reset(); 416 impl_.reset();
399 } 417 }
400 418
401 } // namespace arc 419 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698