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

Side by Side Diff: chrome/browser/chromeos/arc/arc_settings_bridge_impl.h

Issue 1596663002: arc-bridge: Introduce the ArcService class (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Rebased + protected ArcService direct instantiation Created 4 years, 11 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
(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_ARC_SETTINGS_BRIDGE_IMPL_H_
5 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_SETTINGS_BRIDGE_IMPL_H_
6
7 #include <string>
8
9 #include "base/gtest_prod_util.h"
10 #include "base/macros.h"
11 #include "base/prefs/pref_change_registrar.h"
12 #include "base/values.h"
13 #include "chromeos/settings/timezone_settings.h"
14 #include "components/arc/arc_bridge_service.h"
15 #include "components/arc/settings/arc_settings_bridge.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 ArcSettingsBridgeImpl
44 : public ArcSettingsBridge,
45 public ArcBridgeService::Observer,
46 public chromeos::system::TimezoneSettings::Observer {
47 public:
48 ArcSettingsBridgeImpl() = default;
49
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
56 // Called when a Chrome pref we have registered an observer for has changed.
57 // Obtains the new pref value and sends it to Android.
58 void OnPrefChanged(const std::string& pref_name) const;
59
60 // ArcBridgeService::Observer
61 void OnStateChanged(ArcBridgeService::State state) override;
62 void OnSettingsInstanceReady() override;
63
64 // TimezoneSettings::Observer
65 void TimezoneChanged(const icu::TimeZone& timezone) override;
66
67 private:
68 // Registers to observe changes for Chrome settings we care about.
69 void StartObservingSettingsChanges();
70
71 // Stops listening for Chrome settings changes.
72 void StopObservingSettingsChanges();
73
74 // Retrives Chrome's state for the settings and send it to Android.
75 void SyncAllPrefs() const;
76 void SyncFontSize() const;
77 void SyncLocale() const;
78 void SyncSpokenFeedbackEnabled() const;
79 void SyncTimeZone() const;
80
81 // Registers to listen to a particular perf.
82 void AddPrefToObserve(const std::string& pref_name);
83
84 // Returns the integer value of the pref. pref_name must exist.
85 int GetIntegerPref(const std::string& pref_name) const;
86
87 // Sends a broadcast to the ArcSettings app in Android.
88 void SendSettingsBroadcast(const std::string& action,
89 const base::DictionaryValue& extras) const;
90
91 // Manages pref observation registration.
92 PrefChangeRegistrar registrar_;
93
94 DISALLOW_COPY_AND_ASSIGN(ArcSettingsBridgeImpl);
95 };
96
97 } // namespace arc
98
99 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_SETTINGS_BRIDGE_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_settings_bridge.cc ('k') | chrome/browser/chromeos/arc/arc_settings_bridge_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698