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

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

Issue 2736293002: Add chrome flags entry for ChromeVox ARC support (Closed)
Patch Set: Boolean managed pref. Created 3 years, 9 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 | « chrome/browser/about_flags.cc ('k') | tools/metrics/histograms/histograms.xml » ('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 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/intent_helper/arc_settings_service.h" 5 #include "chrome/browser/chromeos/arc/intent_helper/arc_settings_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 145
146 void OnBluetoothAdapterInitialized( 146 void OnBluetoothAdapterInitialized(
147 scoped_refptr<device::BluetoothAdapter> adapter); 147 scoped_refptr<device::BluetoothAdapter> adapter);
148 148
149 // Registers to listen to a particular perf. 149 // Registers to listen to a particular perf.
150 void AddPrefToObserve(const std::string& pref_name); 150 void AddPrefToObserve(const std::string& pref_name);
151 151
152 // Returns the integer value of the pref. pref_name must exist. 152 // Returns the integer value of the pref. pref_name must exist.
153 int GetIntegerPref(const std::string& pref_name) const; 153 int GetIntegerPref(const std::string& pref_name) const;
154 154
155 // Gets whether this is a managed pref.
156 bool IsBooleanPrefManaged(const std::string& pref_name) const;
157
155 // Sends boolean pref broadcast to the delegate. 158 // Sends boolean pref broadcast to the delegate.
156 void SendBoolPrefSettingsBroadcast(const std::string& pref_name, 159 void SendBoolPrefSettingsBroadcast(const std::string& pref_name,
157 const std::string& action) const; 160 const std::string& action) const;
158 161
162 // Same as above, except sends a specific boolean value.
163 void SendBoolValueSettingsBroadcast(bool value,
164 bool managed,
165 const std::string& action) const;
166
159 // Sends a broadcast to the delegate. 167 // Sends a broadcast to the delegate.
160 void SendSettingsBroadcast(const std::string& action, 168 void SendSettingsBroadcast(const std::string& action,
161 const base::DictionaryValue& extras) const; 169 const base::DictionaryValue& extras) const;
162 170
163 // Manages pref observation registration. 171 // Manages pref observation registration.
164 PrefChangeRegistrar registrar_; 172 PrefChangeRegistrar registrar_;
165 173
166 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription> 174 std::unique_ptr<chromeos::CrosSettings::ObserverSubscription>
167 reporting_consent_subscription_; 175 reporting_consent_subscription_;
168 ArcBridgeService* const arc_bridge_service_; 176 ArcBridgeService* const arc_bridge_service_;
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 void ArcSettingsServiceImpl::SyncReportingConsent() const { 491 void ArcSettingsServiceImpl::SyncReportingConsent() const {
484 bool consent = false; 492 bool consent = false;
485 CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, &consent); 493 CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, &consent);
486 base::DictionaryValue extras; 494 base::DictionaryValue extras;
487 extras.SetBoolean("reportingConsent", consent); 495 extras.SetBoolean("reportingConsent", consent);
488 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_REPORTING_CONSENT", 496 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_REPORTING_CONSENT",
489 extras); 497 extras);
490 } 498 }
491 499
492 void ArcSettingsServiceImpl::SyncSpokenFeedbackEnabled() const { 500 void ArcSettingsServiceImpl::SyncSpokenFeedbackEnabled() const {
493 std::string setting = 501 // Chrome spoken feedback triggers enabling of Android spoken feedback.
502 // There are two types of spoken feedback from Android:
503 // 1. Talkback (default)
504 // 2. accessibility helper (experimental, works through ChromeVox).
505 // These two features are mutually exclusive.
506
507 const PrefService::Preference* pref = registrar_.prefs()->FindPreference(
508 prefs::kAccessibilitySpokenFeedbackEnabled);
509 DCHECK(pref);
510 bool enabled = false;
511 bool value_exists = pref->GetValue()->GetAsBoolean(&enabled);
512 CHECK(value_exists);
513 bool managed =
514 IsBooleanPrefManaged(prefs::kAccessibilitySpokenFeedbackEnabled);
515
516 std::string talkback_setting =
494 "org.chromium.arc.intent_helper.SET_SPOKEN_FEEDBACK_ENABLED"; 517 "org.chromium.arc.intent_helper.SET_SPOKEN_FEEDBACK_ENABLED";
518 std::string accessibility_helper_setting =
519 "org.chromium.arc.intent_helper.SET_ACCESSIBILITY_HELPER_ENABLED";
520
495 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 521 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
496 chromeos::switches::kEnableChromeVoxArcSupport)) 522 chromeos::switches::kEnableChromeVoxArcSupport)) {
497 setting = "org.chromium.arc.intent_helper.SET_ACCESSIBILITY_HELPER_ENABLED"; 523 // Make sure if ChromeVox is on, TalkBack is off.
524 if (enabled)
525 SendBoolValueSettingsBroadcast(false, managed, talkback_setting);
498 526
499 SendBoolPrefSettingsBroadcast(prefs::kAccessibilitySpokenFeedbackEnabled, 527 SendBoolValueSettingsBroadcast(enabled, managed,
500 setting); 528 accessibility_helper_setting);
529
530 return;
531 }
532
533 SendBoolValueSettingsBroadcast(enabled, managed, talkback_setting);
501 } 534 }
502 535
503 void ArcSettingsServiceImpl::SyncTimeZone() const { 536 void ArcSettingsServiceImpl::SyncTimeZone() const {
504 TimezoneSettings* timezone_settings = TimezoneSettings::GetInstance(); 537 TimezoneSettings* timezone_settings = TimezoneSettings::GetInstance();
505 base::string16 timezoneID = timezone_settings->GetCurrentTimezoneID(); 538 base::string16 timezoneID = timezone_settings->GetCurrentTimezoneID();
506 base::DictionaryValue extras; 539 base::DictionaryValue extras;
507 extras.SetString("olsonTimeZone", timezoneID); 540 extras.SetString("olsonTimeZone", timezoneID);
508 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_TIME_ZONE", extras); 541 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_TIME_ZONE", extras);
509 } 542 }
510 543
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 int ArcSettingsServiceImpl::GetIntegerPref(const std::string& pref_name) const { 584 int ArcSettingsServiceImpl::GetIntegerPref(const std::string& pref_name) const {
552 const PrefService::Preference* pref = 585 const PrefService::Preference* pref =
553 registrar_.prefs()->FindPreference(pref_name); 586 registrar_.prefs()->FindPreference(pref_name);
554 DCHECK(pref); 587 DCHECK(pref);
555 int val = -1; 588 int val = -1;
556 bool value_exists = pref->GetValue()->GetAsInteger(&val); 589 bool value_exists = pref->GetValue()->GetAsInteger(&val);
557 DCHECK(value_exists); 590 DCHECK(value_exists);
558 return val; 591 return val;
559 } 592 }
560 593
594 bool ArcSettingsServiceImpl::IsBooleanPrefManaged(
595 const std::string& pref_name) const {
596 const PrefService::Preference* pref =
597 registrar_.prefs()->FindPreference(pref_name);
598 DCHECK(pref);
599 bool value_exists = pref->GetValue()->is_bool();
600 DCHECK(value_exists);
601 return !pref->IsUserModifiable();
602 }
603
561 void ArcSettingsServiceImpl::SendBoolPrefSettingsBroadcast( 604 void ArcSettingsServiceImpl::SendBoolPrefSettingsBroadcast(
562 const std::string& pref_name, 605 const std::string& pref_name,
563 const std::string& action) const { 606 const std::string& action) const {
564 const PrefService::Preference* pref = 607 const PrefService::Preference* pref =
565 registrar_.prefs()->FindPreference(pref_name); 608 registrar_.prefs()->FindPreference(pref_name);
566 DCHECK(pref); 609 DCHECK(pref);
567 bool enabled = false; 610 bool enabled = false;
568 bool value_exists = pref->GetValue()->GetAsBoolean(&enabled); 611 bool value_exists = pref->GetValue()->GetAsBoolean(&enabled);
569 DCHECK(value_exists); 612 DCHECK(value_exists);
613 SendBoolValueSettingsBroadcast(enabled, !pref->IsUserModifiable(), action);
614 }
615
616 void ArcSettingsServiceImpl::SendBoolValueSettingsBroadcast(
617 bool enabled,
618 bool managed,
619 const std::string& action) const {
570 base::DictionaryValue extras; 620 base::DictionaryValue extras;
571 extras.SetBoolean("enabled", enabled); 621 extras.SetBoolean("enabled", enabled);
572 extras.SetBoolean("managed", !pref->IsUserModifiable()); 622 extras.SetBoolean("managed", managed);
573 SendSettingsBroadcast(action, extras); 623 SendSettingsBroadcast(action, extras);
574 } 624 }
575 625
576 void ArcSettingsServiceImpl::SendSettingsBroadcast( 626 void ArcSettingsServiceImpl::SendSettingsBroadcast(
577 const std::string& action, 627 const std::string& action,
578 const base::DictionaryValue& extras) const { 628 const base::DictionaryValue& extras) const {
579 auto* instance = ARC_GET_INSTANCE_FOR_METHOD( 629 auto* instance = ARC_GET_INSTANCE_FOR_METHOD(
580 arc_bridge_service_->intent_helper(), SendBroadcast); 630 arc_bridge_service_->intent_helper(), SendBroadcast);
581 if (!instance) 631 if (!instance)
582 return; 632 return;
(...skipping 17 matching lines...) Expand all
600 650
601 void ArcSettingsService::OnInstanceReady() { 651 void ArcSettingsService::OnInstanceReady() {
602 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); 652 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service()));
603 } 653 }
604 654
605 void ArcSettingsService::OnInstanceClosed() { 655 void ArcSettingsService::OnInstanceClosed() {
606 impl_.reset(); 656 impl_.reset();
607 } 657 }
608 658
609 } // namespace arc 659 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/about_flags.cc ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698