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

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: Address feedback. 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
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 IsPrefManaged(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 int enabled = GetIntegerPref(prefs::kAccessibilitySpokenFeedbackEnabled);
508 bool managed = IsPrefManaged(prefs::kAccessibilitySpokenFeedbackEnabled);
509
510 std::string talkback_setting =
494 "org.chromium.arc.intent_helper.SET_SPOKEN_FEEDBACK_ENABLED"; 511 "org.chromium.arc.intent_helper.SET_SPOKEN_FEEDBACK_ENABLED";
512 std::string accessibility_helper_setting =
513 "org.chromium.arc.intent_helper.SET_ACCESSIBILITY_HELPER_ENABLED";
514
495 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 515 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
496 chromeos::switches::kEnableChromeVoxArcSupport)) 516 chromeos::switches::kEnableChromeVoxArcSupport)) {
497 setting = "org.chromium.arc.intent_helper.SET_ACCESSIBILITY_HELPER_ENABLED"; 517 // Make sure if ChromeVox is on, TalkBack is off.
518 if (enabled)
519 SendBoolValueSettingsBroadcast(false, managed, talkback_setting);
498 520
499 SendBoolPrefSettingsBroadcast(prefs::kAccessibilitySpokenFeedbackEnabled, 521 SendBoolValueSettingsBroadcast(enabled, managed,
500 setting); 522 accessibility_helper_setting);
523
524 return;
525 }
526
527 SendBoolValueSettingsBroadcast(enabled, managed, talkback_setting);
501 } 528 }
502 529
503 void ArcSettingsServiceImpl::SyncTimeZone() const { 530 void ArcSettingsServiceImpl::SyncTimeZone() const {
504 TimezoneSettings* timezone_settings = TimezoneSettings::GetInstance(); 531 TimezoneSettings* timezone_settings = TimezoneSettings::GetInstance();
505 base::string16 timezoneID = timezone_settings->GetCurrentTimezoneID(); 532 base::string16 timezoneID = timezone_settings->GetCurrentTimezoneID();
506 base::DictionaryValue extras; 533 base::DictionaryValue extras;
507 extras.SetString("olsonTimeZone", timezoneID); 534 extras.SetString("olsonTimeZone", timezoneID);
508 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_TIME_ZONE", extras); 535 SendSettingsBroadcast("org.chromium.arc.intent_helper.SET_TIME_ZONE", extras);
509 } 536 }
510 537
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 int ArcSettingsServiceImpl::GetIntegerPref(const std::string& pref_name) const { 578 int ArcSettingsServiceImpl::GetIntegerPref(const std::string& pref_name) const {
552 const PrefService::Preference* pref = 579 const PrefService::Preference* pref =
553 registrar_.prefs()->FindPreference(pref_name); 580 registrar_.prefs()->FindPreference(pref_name);
554 DCHECK(pref); 581 DCHECK(pref);
555 int val = -1; 582 int val = -1;
556 bool value_exists = pref->GetValue()->GetAsInteger(&val); 583 bool value_exists = pref->GetValue()->GetAsInteger(&val);
557 DCHECK(value_exists); 584 DCHECK(value_exists);
558 return val; 585 return val;
559 } 586 }
560 587
588 bool ArcSettingsServiceImpl::IsPrefManaged(const std::string& pref_name) const {
589 const PrefService::Preference* pref =
590 registrar_.prefs()->FindPreference(pref_name);
591 DCHECK(pref);
592 bool value_exists = pref->GetValue()->is_int();
593 DCHECK(value_exists);
594 return !pref->IsUserModifiable();
595 }
596
561 void ArcSettingsServiceImpl::SendBoolPrefSettingsBroadcast( 597 void ArcSettingsServiceImpl::SendBoolPrefSettingsBroadcast(
562 const std::string& pref_name, 598 const std::string& pref_name,
563 const std::string& action) const { 599 const std::string& action) const {
564 const PrefService::Preference* pref = 600 const PrefService::Preference* pref =
565 registrar_.prefs()->FindPreference(pref_name); 601 registrar_.prefs()->FindPreference(pref_name);
566 DCHECK(pref); 602 DCHECK(pref);
567 bool enabled = false; 603 bool enabled = false;
568 bool value_exists = pref->GetValue()->GetAsBoolean(&enabled); 604 bool value_exists = pref->GetValue()->GetAsBoolean(&enabled);
569 DCHECK(value_exists); 605 DCHECK(value_exists);
606 SendBoolValueSettingsBroadcast(enabled, !pref->IsUserModifiable(), action);
607 }
608
609 void ArcSettingsServiceImpl::SendBoolValueSettingsBroadcast(
610 bool enabled,
611 bool managed,
612 const std::string& action) const {
570 base::DictionaryValue extras; 613 base::DictionaryValue extras;
571 extras.SetBoolean("enabled", enabled); 614 extras.SetBoolean("enabled", enabled);
572 extras.SetBoolean("managed", !pref->IsUserModifiable()); 615 extras.SetBoolean("managed", managed);
573 SendSettingsBroadcast(action, extras); 616 SendSettingsBroadcast(action, extras);
574 } 617 }
575 618
576 void ArcSettingsServiceImpl::SendSettingsBroadcast( 619 void ArcSettingsServiceImpl::SendSettingsBroadcast(
577 const std::string& action, 620 const std::string& action,
578 const base::DictionaryValue& extras) const { 621 const base::DictionaryValue& extras) const {
579 auto* instance = ARC_GET_INSTANCE_FOR_METHOD( 622 auto* instance = ARC_GET_INSTANCE_FOR_METHOD(
580 arc_bridge_service_->intent_helper(), SendBroadcast); 623 arc_bridge_service_->intent_helper(), SendBroadcast);
581 if (!instance) 624 if (!instance)
582 return; 625 return;
(...skipping 17 matching lines...) Expand all
600 643
601 void ArcSettingsService::OnInstanceReady() { 644 void ArcSettingsService::OnInstanceReady() {
602 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service())); 645 impl_.reset(new ArcSettingsServiceImpl(arc_bridge_service()));
603 } 646 }
604 647
605 void ArcSettingsService::OnInstanceClosed() { 648 void ArcSettingsService::OnInstanceClosed() {
606 impl_.reset(); 649 impl_.reset();
607 } 650 }
608 651
609 } // namespace arc 652 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698