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

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

Issue 11466010: Decompose BrowserStateMonitor into two parts, simplifying unit tests and APIs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix gypi ordering. 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
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 "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h"
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/prefs/public/pref_member.h"
13 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 13 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
14 #include "content/public/browser/notification_observer.h" 14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/notification_types.h"
17 16
18 namespace chromeos { 17 namespace chromeos {
19 namespace input_method { 18 namespace input_method {
20 19
21 class InputMethodDelegate; 20 // Translates notifications from the browser (not logged in, logged in, etc.),
22 21 // into InputMethodManager::State transitions.
23 // A class which monitors a notification from the browser to keep track of the 22 class BrowserStateMonitor : public content::NotificationObserver {
24 // browser state (not logged in, logged in, etc.) and notify the current state
25 // to the input method manager. The class also updates the appropriate Chrome
26 // prefs via the InputMethodDelegate, depending on the current browser state.
27 class BrowserStateMonitor : public content::NotificationObserver,
28 public InputMethodManager::Observer {
29 public: 23 public:
30 BrowserStateMonitor(InputMethodManager* manager, 24 // Constructs a monitor that will invoke the given observer callback whenever
31 InputMethodDelegate* delegate); 25 // the InputMethodManager::State changes. Assumes that the current state is
26 // STATE_LOGIN_SCREEN. |observer| may be null.
27 explicit BrowserStateMonitor(
28 const base::Callback<void(InputMethodManager::State)>& observer);
32 virtual ~BrowserStateMonitor(); 29 virtual ~BrowserStateMonitor();
33 30
34 InputMethodManager::State state() const { return state_; } 31 InputMethodManager::State state() const { return state_; }
35 32
36 protected:
37 // InputMethodManager::Observer overrides:
38 virtual void InputMethodChanged(InputMethodManager* manager,
39 bool show_message) OVERRIDE;
40 virtual void InputMethodPropertyChanged(InputMethodManager* manager) OVERRIDE;
41
42 // content::NotificationObserver overrides: 33 // content::NotificationObserver overrides:
43 virtual void Observe(int type, 34 virtual void Observe(int type,
44 const content::NotificationSource& source, 35 const content::NotificationSource& source,
45 const content::NotificationDetails& details) OVERRIDE; 36 const content::NotificationDetails& details) OVERRIDE;
46 37
47 private: 38 private:
48 void SetState(InputMethodManager::State new_state); 39 base::Callback<void(InputMethodManager::State)> observer_;
49
50 InputMethodManager* manager_;
51 InputMethodDelegate* delegate_;
52 InputMethodManager::State state_; 40 InputMethodManager::State state_;
53
54 // This is used to register this object to some browser notifications.
55 content::NotificationRegistrar notification_registrar_; 41 content::NotificationRegistrar notification_registrar_;
56 42
57 DISALLOW_COPY_AND_ASSIGN(BrowserStateMonitor); 43 DISALLOW_COPY_AND_ASSIGN(BrowserStateMonitor);
58 }; 44 };
59 45
60 } // namespace input_method 46 } // namespace input_method
61 } // namespace chromeos 47 } // namespace chromeos
62 48
63 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_BROWSER_STATE_MONITOR_H_ 49 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_BROWSER_STATE_MONITOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/input_method/DEPS ('k') | chrome/browser/chromeos/input_method/browser_state_monitor.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698