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

Side by Side Diff: ash/common/system/tray/system_tray_controller.h

Issue 2525813004: chromeos: Introduce SetClient() on ash::mojom::SystemTray interface (Closed)
Patch Set: Created 4 years, 1 month 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #ifndef ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ 5 #ifndef ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_
6 #define ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ 6 #define ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_
7 7
8 #include "ash/ash_export.h" 8 #include "ash/ash_export.h"
9 #include "ash/public/interfaces/system_tray.mojom.h" 9 #include "ash/public/interfaces/system_tray.mojom.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/i18n/time_formatting.h" 11 #include "base/i18n/time_formatting.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "mojo/public/cpp/bindings/binding_set.h" 13 #include "mojo/public/cpp/bindings/binding_set.h"
14 14
15 namespace service_manager {
16 class Connector;
17 }
18
19 namespace ash { 15 namespace ash {
20 16
21 // Both implements mojom::SystemTray and wraps the mojom::SystemTrayClient 17 // Both implements mojom::SystemTray and wraps the mojom::SystemTrayClient
22 // interface. The wrapper makes the initial connection and handles reconnecting 18 // interface. Implements both because it caches state pushed down from the
23 // on error. Implements both because it caches state pushed down from the
24 // browser process via SystemTray so it can be synchronously queried inside ash. 19 // browser process via SystemTray so it can be synchronously queried inside ash.
25 // 20 //
26 // Conceptually similar to historical ash-to-chrome interfaces like 21 // Conceptually similar to historical ash-to-chrome interfaces like
27 // SystemTrayDelegate. Lives on the main thread. 22 // SystemTrayDelegate. Lives on the main thread.
28 // 23 //
29 // Only connects to the actual mojom::SystemTrayClient interface when running on
30 // Chrome OS. In tests and on Windows all operations are no-ops.
31 //
32 // TODO: Consider renaming this to SystemTrayClient or renaming the current 24 // TODO: Consider renaming this to SystemTrayClient or renaming the current
33 // SystemTray to SystemTrayView and making this class SystemTray. 25 // SystemTray to SystemTrayView and making this class SystemTray.
34 class ASH_EXPORT SystemTrayController 26 class ASH_EXPORT SystemTrayController
35 : NON_EXPORTED_BASE(public mojom::SystemTray) { 27 : NON_EXPORTED_BASE(public mojom::SystemTray) {
36 public: 28 public:
37 explicit SystemTrayController(service_manager::Connector* connector); 29 SystemTrayController();
38 ~SystemTrayController() override; 30 ~SystemTrayController() override;
39 31
40 base::HourClockType hour_clock_type() const { return hour_clock_type_; } 32 base::HourClockType hour_clock_type() const { return hour_clock_type_; }
41 33
42 // Wrappers around the mojom::SystemTrayClient interface. 34 // Wrappers around the mojom::SystemTrayClient interface.
43 void ShowSettings(); 35 void ShowSettings();
44 void ShowDateSettings(); 36 void ShowDateSettings();
45 void ShowSetTimeDialog(); 37 void ShowSetTimeDialog();
46 void ShowDisplaySettings(); 38 void ShowDisplaySettings();
47 void ShowPowerSettings(); 39 void ShowPowerSettings();
48 void ShowChromeSlow(); 40 void ShowChromeSlow();
49 void ShowIMESettings(); 41 void ShowIMESettings();
50 void ShowHelp(); 42 void ShowHelp();
51 void ShowAccessibilityHelp(); 43 void ShowAccessibilityHelp();
52 void ShowAccessibilitySettings(); 44 void ShowAccessibilitySettings();
53 void ShowPaletteHelp(); 45 void ShowPaletteHelp();
54 void ShowPaletteSettings(); 46 void ShowPaletteSettings();
55 void ShowPublicAccountInfo(); 47 void ShowPublicAccountInfo();
56 void ShowNetworkConfigure(const std::string& network_id); 48 void ShowNetworkConfigure(const std::string& network_id);
57 void ShowNetworkCreate(const std::string& type); 49 void ShowNetworkCreate(const std::string& type);
58 void ShowNetworkSettings(const std::string& network_id); 50 void ShowNetworkSettings(const std::string& network_id);
59 void ShowProxySettings(); 51 void ShowProxySettings();
60 void SignOut(); 52 void SignOut();
61 void RequestRestartForUpdate(); 53 void RequestRestartForUpdate();
62 54
63 // Binds the mojom::SystemTray interface to this object. 55 // Binds the mojom::SystemTray interface to this object.
64 void BindRequest(mojom::SystemTrayRequest request); 56 void BindRequest(mojom::SystemTrayRequest request);
65 57
66 private: 58 private:
67 // Connects or reconnects to the mojom::SystemTrayClient interface when 59 // Returns true if |system_tray_client_| is bound. Otherwise logs an error and
68 // running on Chrome OS. Otherwise does nothing. Returns true if connected. 60 // returns false.
69 bool ConnectToSystemTrayClient(); 61 bool HasSystemTrayClient();
70
71 // Handles errors on the |system_tray_client_| interface connection.
72 void OnClientConnectionError();
73 62
74 // mojom::SystemTray: 63 // mojom::SystemTray:
64 void SetClient(mojom::SystemTrayClientPtr client) override;
75 void SetUse24HourClock(bool use_24_hour) override; 65 void SetUse24HourClock(bool use_24_hour) override;
76 66
77 // May be null in unit tests.
78 service_manager::Connector* connector_;
79
80 // Client interface in chrome browser. Only bound on Chrome OS. 67 // Client interface in chrome browser. Only bound on Chrome OS.
81 mojom::SystemTrayClientPtr system_tray_client_; 68 mojom::SystemTrayClientPtr system_tray_client_;
82 69
83 // Bindings for the SystemTray interface. 70 // Bindings for the SystemTray interface.
84 mojo::BindingSet<mojom::SystemTray> bindings_; 71 mojo::BindingSet<mojom::SystemTray> bindings_;
85 72
86 // The type of clock hour display: 12 or 24 hour. 73 // The type of clock hour display: 12 or 24 hour.
87 base::HourClockType hour_clock_type_; 74 base::HourClockType hour_clock_type_;
88 75
89 DISALLOW_COPY_AND_ASSIGN(SystemTrayController); 76 DISALLOW_COPY_AND_ASSIGN(SystemTrayController);
90 }; 77 };
91 78
92 } // namspace ash 79 } // namspace ash
93 80
94 #endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_ 81 #endif // ASH_COMMON_SYSTEM_TRAY_SYSTEM_TRAY_CONTROLLER_H_
OLDNEW
« no previous file with comments | « no previous file | ash/common/system/tray/system_tray_controller.cc » ('j') | ash/common/system/tray/system_tray_controller.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698