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

Side by Side Diff: chrome/browser/chromeos/input_method/browser_state_monitor.h

Issue 11415266: Extract a delegate interface from c/b/input_method to permit decoupling from c/b. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Class comment. Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/chromeos/input_method/browser_state_monitor.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_INPUT_METHOD_BROWSER_STATE_MONITOR_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_INPUT_METHOD_BROWSER_STATE_MONITOR_H_
6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_BROWSER_STATE_MONITOR_H_ 6 #define CHROME_BROWSER_CHROMEOS_INPUT_METHOD_BROWSER_STATE_MONITOR_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "chrome/browser/api/prefs/pref_member.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
11 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 12 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
12 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
14 #include "content/public/browser/notification_types.h" 15 #include "content/public/browser/notification_types.h"
15 16
16 class PrefService;
17
18 namespace chromeos { 17 namespace chromeos {
19 namespace input_method { 18 namespace input_method {
20 19
20 class InputMethodDelegate;
21
21 // A class which monitors a notification from the browser to keep track of the 22 // A class which monitors a notification from the browser to keep track of the
22 // browser state (not logged in, logged in, etc.) and notify the current state 23 // browser state (not logged in, logged in, etc.) and notify the current state
23 // to the input method manager. The class also updates the appropriate Chrome 24 // to the input method manager. The class also updates the appropriate Chrome
24 // prefs (~/Local\ State or ~/Preferences) depending on the current browser 25 // prefs via the InputMethodDelegate, depending on the current browser state.
25 // state.
26 class BrowserStateMonitor : public content::NotificationObserver, 26 class BrowserStateMonitor : public content::NotificationObserver,
27 public InputMethodManager::Observer { 27 public InputMethodManager::Observer {
28 public: 28 public:
29 explicit BrowserStateMonitor(InputMethodManager* manager); 29 BrowserStateMonitor(InputMethodManager* manager,
30 InputMethodDelegate* delegate);
30 virtual ~BrowserStateMonitor(); 31 virtual ~BrowserStateMonitor();
31 32
32 InputMethodManager::State state() const { return state_; } 33 InputMethodManager::State state() const { return state_; }
33 34
34 void SetPrefServiceForTesting(PrefService* pref_service);
35
36 protected: 35 protected:
37 // Updates ~/Local\ State file. protected: for testing.
38 virtual void UpdateLocalState(const std::string& current_input_method);
39 // Updates ~/Preferences file. protected: for testing.
40 virtual void UpdateUserPreferences(const std::string& current_input_method);
41
42 // InputMethodManager::Observer overrides: 36 // InputMethodManager::Observer overrides:
43 virtual void InputMethodChanged(InputMethodManager* manager, 37 virtual void InputMethodChanged(InputMethodManager* manager,
44 bool show_message) OVERRIDE; 38 bool show_message) OVERRIDE;
45 virtual void InputMethodPropertyChanged(InputMethodManager* manager) OVERRIDE; 39 virtual void InputMethodPropertyChanged(InputMethodManager* manager) OVERRIDE;
46 40
47 // content::NotificationObserver overrides: 41 // content::NotificationObserver overrides:
48 virtual void Observe(int type, 42 virtual void Observe(int type,
49 const content::NotificationSource& source, 43 const content::NotificationSource& source,
50 const content::NotificationDetails& details) OVERRIDE; 44 const content::NotificationDetails& details) OVERRIDE;
51 45
52 private: 46 private:
53 void SetState(InputMethodManager::State new_state); 47 void SetState(InputMethodManager::State new_state);
54 void InitializePrefMembers();
55 48
56 InputMethodManager* manager_; 49 InputMethodManager* manager_;
50 InputMethodDelegate* delegate_;
57 InputMethodManager::State state_; 51 InputMethodManager::State state_;
58 52
59 // This is used to register this object to some browser notifications. 53 // This is used to register this object to some browser notifications.
60 content::NotificationRegistrar notification_registrar_; 54 content::NotificationRegistrar notification_registrar_;
61 55
62 // For testing.
63 PrefService* pref_service_;
64
65 DISALLOW_COPY_AND_ASSIGN(BrowserStateMonitor); 56 DISALLOW_COPY_AND_ASSIGN(BrowserStateMonitor);
66 }; 57 };
67 58
68 } // namespace input_method 59 } // namespace input_method
69 } // namespace chromeos 60 } // namespace chromeos
70 61
71 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_BROWSER_STATE_MONITOR_H_ 62 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_BROWSER_STATE_MONITOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/input_method/browser_state_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698