OLD | NEW |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_SETTINGS_BRIDGE_IMPL_H_ | 4 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_SETTINGS_BRIDGE_H_ |
5 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_SETTINGS_BRIDGE_IMPL_H_ | 5 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_SETTINGS_BRIDGE_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/macros.h" | 10 #include "base/macros.h" |
11 #include "base/prefs/pref_change_registrar.h" | 11 #include "base/prefs/pref_change_registrar.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chromeos/settings/timezone_settings.h" | 13 #include "chromeos/settings/timezone_settings.h" |
14 #include "components/arc/arc_bridge_service.h" | 14 #include "components/arc/arc_bridge_service.h" |
15 #include "components/arc/settings/arc_settings_bridge.h" | 15 #include "components/arc/arc_service.h" |
16 | 16 |
17 namespace arc { | 17 namespace arc { |
18 | 18 |
19 namespace fontsizes { | 19 namespace fontsizes { |
20 | 20 |
21 // The following values were obtained from chrome://settings and Android's | 21 // The following values were obtained from chrome://settings and Android's |
22 // Display settings on Nov 2015. They are expected to remain stable. | 22 // Display settings on Nov 2015. They are expected to remain stable. |
23 const float kAndroidFontScaleSmall = 0.85; | 23 const float kAndroidFontScaleSmall = 0.85; |
24 const float kAndroidFontScaleNormal = 1; | 24 const float kAndroidFontScaleNormal = 1; |
25 const float kAndroidFontScaleLarge = 1.15; | 25 const float kAndroidFontScaleLarge = 1.15; |
26 const float kAndroidFontScaleHuge = 1.3; | 26 const float kAndroidFontScaleHuge = 1.3; |
27 const int kChromeFontSizeNormal = 16; | 27 const int kChromeFontSizeNormal = 16; |
28 const int kChromeFontSizeLarge = 20; | 28 const int kChromeFontSizeLarge = 20; |
29 const int kChromeFontSizeVeryLarge = 24; | 29 const int kChromeFontSizeVeryLarge = 24; |
30 | 30 |
31 // Android has only a single float value for system-wide font size | 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 | 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 | 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. | 34 // main font values on Chrome and convert to an Android size. |
35 double ConvertFontSizeChromeToAndroid(int default_size, | 35 double ConvertFontSizeChromeToAndroid(int default_size, |
36 int default_fixed_size, | 36 int default_fixed_size, |
37 int minimum_size); | 37 int minimum_size); |
38 | 38 |
39 } // namespace fontsizes | 39 } // namespace fontsizes |
40 | 40 |
41 // Listens to changes for select Chrome settings (prefs) that Android cares | 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. | 42 // about and sends the new values to Android to keep the state in sync. |
43 class ArcSettingsBridgeImpl | 43 class ArcSettingsBridge : public ArcService, |
44 : public ArcSettingsBridge, | 44 public ArcBridgeService::Observer, |
45 public ArcBridgeService::Observer, | 45 public chromeos::system::TimezoneSettings::Observer { |
46 public chromeos::system::TimezoneSettings::Observer { | |
47 public: | 46 public: |
48 ArcSettingsBridgeImpl() = default; | 47 explicit ArcSettingsBridge(ArcBridgeService* bridge_service); |
49 | 48 ~ArcSettingsBridge() override; |
50 ~ArcSettingsBridgeImpl() override; | |
51 | |
52 // Starts listening to state changes of the ArcBridgeService. | |
53 // This must be called before the bridge service starts bootstrapping. | |
54 void StartObservingBridgeServiceChanges() override; | |
55 | 49 |
56 // Called when a Chrome pref we have registered an observer for has changed. | 50 // Called when a Chrome pref we have registered an observer for has changed. |
57 // Obtains the new pref value and sends it to Android. | 51 // Obtains the new pref value and sends it to Android. |
58 void OnPrefChanged(const std::string& pref_name) const; | 52 void OnPrefChanged(const std::string& pref_name) const; |
59 | 53 |
60 // ArcBridgeService::Observer | 54 // ArcBridgeService::Observer |
61 void OnStateChanged(ArcBridgeService::State state) override; | 55 void OnStateChanged(ArcBridgeService::State state) override; |
62 void OnSettingsInstanceReady() override; | 56 void OnSettingsInstanceReady() override; |
63 | 57 |
64 // TimezoneSettings::Observer | 58 // TimezoneSettings::Observer |
(...skipping 19 matching lines...) Expand all Loading... |
84 // Returns the integer value of the pref. pref_name must exist. | 78 // Returns the integer value of the pref. pref_name must exist. |
85 int GetIntegerPref(const std::string& pref_name) const; | 79 int GetIntegerPref(const std::string& pref_name) const; |
86 | 80 |
87 // Sends a broadcast to the ArcSettings app in Android. | 81 // Sends a broadcast to the ArcSettings app in Android. |
88 void SendSettingsBroadcast(const std::string& action, | 82 void SendSettingsBroadcast(const std::string& action, |
89 const base::DictionaryValue& extras) const; | 83 const base::DictionaryValue& extras) const; |
90 | 84 |
91 // Manages pref observation registration. | 85 // Manages pref observation registration. |
92 PrefChangeRegistrar registrar_; | 86 PrefChangeRegistrar registrar_; |
93 | 87 |
94 DISALLOW_COPY_AND_ASSIGN(ArcSettingsBridgeImpl); | 88 DISALLOW_COPY_AND_ASSIGN(ArcSettingsBridge); |
95 }; | 89 }; |
96 | 90 |
97 } // namespace arc | 91 } // namespace arc |
98 | 92 |
99 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SETTINGS_BRIDGE_IMPL_H_ | 93 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SETTINGS_BRIDGE_H_ |
OLD | NEW |