| OLD | NEW | 
|---|
|  | (Empty) | 
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |  | 
| 2 // Use of this source code is governed by a BSD-style license that can be |  | 
| 3 // found in the LICENSE file. |  | 
| 4 #ifndef CHROME_BROWSER_CHROMEOS_ARC_SETTINGS_BRIDGE_H_ |  | 
| 5 #define CHROME_BROWSER_CHROMEOS_ARC_SETTINGS_BRIDGE_H_ |  | 
| 6 |  | 
| 7 #include <string> |  | 
| 8 |  | 
| 9 #include "base/gtest_prod_util.h" |  | 
| 10 #include "base/macros.h" |  | 
| 11 #include "base/values.h" |  | 
| 12 #include "chrome/browser/chromeos/settings/cros_settings.h" |  | 
| 13 #include "chromeos/settings/timezone_settings.h" |  | 
| 14 #include "components/arc/arc_bridge_service.h" |  | 
| 15 #include "components/prefs/pref_change_registrar.h" |  | 
| 16 |  | 
| 17 namespace arc { |  | 
| 18 |  | 
| 19 namespace fontsizes { |  | 
| 20 |  | 
| 21 // The following values were obtained from chrome://settings and Android's |  | 
| 22 // Display settings on Nov 2015. They are expected to remain stable. |  | 
| 23 const float kAndroidFontScaleSmall = 0.85; |  | 
| 24 const float kAndroidFontScaleNormal = 1; |  | 
| 25 const float kAndroidFontScaleLarge = 1.15; |  | 
| 26 const float kAndroidFontScaleHuge = 1.3; |  | 
| 27 const int kChromeFontSizeNormal = 16; |  | 
| 28 const int kChromeFontSizeLarge = 20; |  | 
| 29 const int kChromeFontSizeVeryLarge = 24; |  | 
| 30 |  | 
| 31 // Android has only a single float value for system-wide font size |  | 
| 32 // (font_scale).  Chrome has three main int pixel values that affect |  | 
| 33 // system-wide font size.  We will take the largest font value of the three |  | 
| 34 // main font values on Chrome and convert to an Android size. |  | 
| 35 double ConvertFontSizeChromeToAndroid(int default_size, |  | 
| 36                                       int default_fixed_size, |  | 
| 37                                       int minimum_size); |  | 
| 38 |  | 
| 39 }  // namespace fontsizes |  | 
| 40 |  | 
| 41 // Listens to changes for select Chrome settings (prefs) that Android cares |  | 
| 42 // about and sends the new values to Android to keep the state in sync. |  | 
| 43 class SettingsBridge : public chromeos::system::TimezoneSettings::Observer { |  | 
| 44  public: |  | 
| 45   class Delegate { |  | 
| 46    public: |  | 
| 47     virtual void OnBroadcastNeeded(const std::string& action, |  | 
| 48                                    const base::DictionaryValue& extras) = 0; |  | 
| 49   }; |  | 
| 50 |  | 
| 51   explicit SettingsBridge(Delegate* delegate); |  | 
| 52   ~SettingsBridge() override; |  | 
| 53 |  | 
| 54   // Called when a Chrome pref we have registered an observer for has changed. |  | 
| 55   // Obtains the new pref value and sends it to Android. |  | 
| 56   void OnPrefChanged(const std::string& pref_name) const; |  | 
| 57 |  | 
| 58   // TimezoneSettings::Observer |  | 
| 59   void TimezoneChanged(const icu::TimeZone& timezone) override; |  | 
| 60 |  | 
| 61  private: |  | 
| 62   // Registers to observe changes for Chrome settings we care about. |  | 
| 63   void StartObservingSettingsChanges(); |  | 
| 64 |  | 
| 65   // Stops listening for Chrome settings changes. |  | 
| 66   void StopObservingSettingsChanges(); |  | 
| 67 |  | 
| 68   // Retrives Chrome's state for the settings and send it to Android. |  | 
| 69   void SyncAllPrefs() const; |  | 
| 70   void SyncFontSize() const; |  | 
| 71   void SyncLocale() const; |  | 
| 72   void SyncReportingConsent() const; |  | 
| 73   void SyncSpokenFeedbackEnabled() const; |  | 
| 74   void SyncTimeZone() const; |  | 
| 75   void SyncUse24HourClock() const; |  | 
| 76 |  | 
| 77   // Registers to listen to a particular perf. |  | 
| 78   void AddPrefToObserve(const std::string& pref_name); |  | 
| 79 |  | 
| 80   // Returns the integer value of the pref.  pref_name must exist. |  | 
| 81   int GetIntegerPref(const std::string& pref_name) const; |  | 
| 82 |  | 
| 83   // Sends a broadcast to the delegate. |  | 
| 84   void SendSettingsBroadcast(const std::string& action, |  | 
| 85                              const base::DictionaryValue& extras) const; |  | 
| 86 |  | 
| 87   // Manages pref observation registration. |  | 
| 88   PrefChangeRegistrar registrar_; |  | 
| 89 |  | 
| 90   scoped_ptr<chromeos::CrosSettings::ObserverSubscription> |  | 
| 91       reporting_consent_subscription_; |  | 
| 92 |  | 
| 93   Delegate* const delegate_; |  | 
| 94 |  | 
| 95   DISALLOW_COPY_AND_ASSIGN(SettingsBridge); |  | 
| 96 }; |  | 
| 97 |  | 
| 98 }  // namespace arc |  | 
| 99 |  | 
| 100 #endif  // CHROME_BROWSER_CHROMEOS_ARC_SETTINGS_BRIDGE_H_ |  | 
| OLD | NEW | 
|---|