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

Side by Side Diff: chrome/browser/chromeos/wm_ipc.h

Issue 2078017: chromeos: Add _CHROME_LOGGED_IN property on root window. (Closed)
Patch Set: move logged-in property setting to UserManager::UserLoggedIn() Created 10 years, 7 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
« no previous file with comments | « chrome/browser/chromeos/login/wizard_controller.cc ('k') | chrome/browser/chromeos/wm_ipc.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 CHROME_BROWSER_CHROMEOS_WM_IPC_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_WM_IPC_H_
6 #define CHROME_BROWSER_CHROMEOS_WM_IPC_H_ 6 #define CHROME_BROWSER_CHROMEOS_WM_IPC_H_
7 7
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/singleton.h" 14 #include "base/singleton.h"
15 #include "third_party/cros/chromeos_wm_ipc_enums.h" 15 #include "third_party/cros/chromeos_wm_ipc_enums.h"
16 16
17 typedef unsigned long Atom; 17 typedef unsigned long Atom;
18 typedef unsigned long XID; 18 typedef unsigned long XID;
19 19
20 namespace chromeos { 20 namespace chromeos {
21 21
22 class WmIpc { 22 class WmIpc {
23 public: 23 public:
24 enum AtomType { 24 enum AtomType {
25 ATOM_CHROME_WINDOW_TYPE = 0, 25 ATOM_CHROME_LOGGED_IN = 0,
26 ATOM_CHROME_WINDOW_TYPE,
26 ATOM_CHROME_WM_MESSAGE, 27 ATOM_CHROME_WM_MESSAGE,
27 ATOM_MANAGER, 28 ATOM_MANAGER,
28 ATOM_NET_SUPPORTING_WM_CHECK,
29 ATOM_NET_WM_NAME,
30 ATOM_PRIMARY,
31 ATOM_STRING, 29 ATOM_STRING,
32 ATOM_UTF8_STRING, 30 ATOM_UTF8_STRING,
33 ATOM_WM_NORMAL_HINTS,
34 ATOM_WM_S0, 31 ATOM_WM_S0,
35 ATOM_WM_STATE,
36 ATOM_WM_TRANSIENT_FOR,
37 ATOM_WM_SYSTEM_METRICS, 32 ATOM_WM_SYSTEM_METRICS,
38 kNumAtoms, 33 kNumAtoms,
39 }; 34 };
40 35
41 struct Message { 36 struct Message {
42 public: 37 public:
43 Message() { 38 Message() {
44 Init(WM_IPC_MESSAGE_UNKNOWN); 39 Init(WM_IPC_MESSAGE_UNKNOWN);
45 } 40 }
46 // WmIpcMessageType is defined in chromeos_wm_ipc_enums.h. 41 // WmIpcMessageType is defined in chromeos_wm_ipc_enums.h.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 74
80 // Type-specific data. This is bounded by the number of 32-bit values 75 // Type-specific data. This is bounded by the number of 32-bit values
81 // that we can pack into a ClientMessageEvent -- it holds five, but we 76 // that we can pack into a ClientMessageEvent -- it holds five, but we
82 // use the first one to store the message type. 77 // use the first one to store the message type.
83 long params_[4]; 78 long params_[4];
84 }; 79 };
85 80
86 // Returns the single instance of WmIpc. 81 // Returns the single instance of WmIpc.
87 static WmIpc* instance(); 82 static WmIpc* instance();
88 83
89 // Get or set a property describing a window's type. 84 // Gets or sets a property describing a window's type.
90 // WmIpcMessageType is defined in chromeos_wm_ipc_enums.h. Type-specific 85 // WmIpcMessageType is defined in chromeos_wm_ipc_enums.h. Type-specific
91 // parameters may also be supplied. The caller is responsible for trapping 86 // parameters may also be supplied. The caller is responsible for trapping
92 // errors from the X server. 87 // errors from the X server.
93 bool SetWindowType(GtkWidget* widget, 88 bool SetWindowType(GtkWidget* widget,
94 WmIpcWindowType type, 89 WmIpcWindowType type,
95 const std::vector<int>* params); 90 const std::vector<int>* params);
96 91
97 // Gets the type of the window, and any associated parameters. The 92 // Gets the type of the window, and any associated parameters. The
98 // caller is responsible for trapping errors from the X server. If 93 // caller is responsible for trapping errors from the X server. If
99 // the parameters are not interesting to the caller, NULL may be 94 // the parameters are not interesting to the caller, NULL may be
100 // passed for |params|. 95 // passed for |params|.
101 WmIpcWindowType GetWindowType(GtkWidget* widget, std::vector<int>* params); 96 WmIpcWindowType GetWindowType(GtkWidget* widget, std::vector<int>* params);
102 97
103 // Sends a message to the WM. 98 // Sends a message to the WM.
104 void SendMessage(const Message& msg); 99 void SendMessage(const Message& msg);
105 100
106 // If |event| is a valid Message it is decoded into |msg| and true is 101 // If |event| is a valid Message it is decoded into |msg| and true is
107 // returned. If false is returned, |event| is not a valid Message. 102 // returned. If false is returned, |event| is not a valid Message.
108 bool DecodeMessage(const GdkEventClient& event, Message* msg); 103 bool DecodeMessage(const GdkEventClient& event, Message* msg);
109 104
110 // If |event| is a valid StringMessage it is decoded into |msg| and true is 105 // If |event| is a valid StringMessage it is decoded into |msg| and true is
111 // returned. If false is returned, |event| is not a valid StringMessage. 106 // returned. If false is returned, |event| is not a valid StringMessage.
112 bool DecodeStringMessage(const GdkEventProperty& event, std::string* msg); 107 bool DecodeStringMessage(const GdkEventProperty& event, std::string* msg);
113 108
114 // Handle ClientMessage events that weren't decodable using DecodeMessage(). 109 // Handles ClientMessage events that weren't decodable using DecodeMessage().
115 // Specifically, this catches messages about the WM_S0 selection that get sent 110 // Specifically, this catches messages about the WM_S0 selection that get sent
116 // when a window manager process starts (so that we can re-run InitWmInfo()). 111 // when a window manager process starts (so that we can re-run InitWmInfo()).
117 // See ICCCM 2.8 for more info about MANAGER selections. 112 // See ICCCM 2.8 for more info about MANAGER selections.
118 void HandleNonChromeClientMessageEvent(const GdkEventClient& event); 113 void HandleNonChromeClientMessageEvent(const GdkEventClient& event);
119 114
115 // Sets a _CHROME_LOGGED_IN property on the root window describing whether
116 // the user is currently logged in or not.
117 void SetLoggedInProperty(bool logged_in);
118
120 private: 119 private:
121 friend struct DefaultSingletonTraits<WmIpc>; 120 friend struct DefaultSingletonTraits<WmIpc>;
122 121
123 WmIpc(); 122 WmIpc();
124 123
125 // Initialize 'wm_' and send the window manager a message telling it the 124 // Initialize 'wm_' and send the window manager a message telling it the
126 // version of the IPC protocol that we support. This is called in our 125 // version of the IPC protocol that we support. This is called in our
127 // constructor, but needs to be re-run if the window manager gets restarted. 126 // constructor, but needs to be re-run if the window manager gets restarted.
128 void InitWmInfo(); 127 void InitWmInfo();
129 128
130 // Maps from our Atom enum to the X server's atom IDs and from the 129 // Maps from our Atom enum to the X server's atom IDs and from the
131 // server's IDs to atoms' string names. These maps aren't necessarily in 130 // server's IDs to atoms' string names. These maps aren't necessarily in
132 // sync; 'atom_to_xatom_' is constant after the constructor finishes but 131 // sync; 'atom_to_xatom_' is constant after the constructor finishes but
133 // GetName() caches additional string mappings in 'xatom_to_string_'. 132 // GetName() caches additional string mappings in 'xatom_to_string_'.
134 std::map<AtomType, Atom> type_to_atom_; 133 std::map<AtomType, Atom> type_to_atom_;
135 std::map<Atom, std::string> atom_to_string_; 134 std::map<Atom, std::string> atom_to_string_;
136 135
137 // Cached value of type_to_atom_[ATOM_CHROME_WM_MESSAGE]. 136 // Cached value of type_to_atom_[ATOM_CHROME_WM_MESSAGE].
138 Atom wm_message_atom_; 137 Atom wm_message_atom_;
139 138
140 // Handle to the wm. Used for sending messages. 139 // Handle to the wm. Used for sending messages.
141 XID wm_; 140 XID wm_;
142 141
143 DISALLOW_COPY_AND_ASSIGN(WmIpc); 142 DISALLOW_COPY_AND_ASSIGN(WmIpc);
144 }; 143 };
145 144
146 } // namespace chromeos 145 } // namespace chromeos
147 146
148 #endif // CHROME_BROWSER_CHROMEOS_WM_IPC_H_ 147 #endif // CHROME_BROWSER_CHROMEOS_WM_IPC_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/wizard_controller.cc ('k') | chrome/browser/chromeos/wm_ipc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698