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

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

Issue 9999018: chrome/browser/chromeos/input_method/ refactoring [part 6 of 6] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 8 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 | 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 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
11 #include "chrome/browser/chromeos/input_method/input_method_manager.h" 11 #include "chrome/browser/chromeos/input_method/input_method_manager.h"
12 #include "chrome/browser/prefs/pref_member.h" 12 #include "chrome/browser/prefs/pref_member.h"
13 #include "content/public/browser/notification_observer.h" 13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h" 14 #include "content/public/browser/notification_registrar.h"
15 #include "content/public/browser/notification_types.h" 15 #include "content/public/browser/notification_types.h"
16 16
17 namespace chromeos { 17 namespace chromeos {
18 namespace input_method { 18 namespace input_method {
19 19
20 // A class which monitors a notification from the browser to keep track of the 20 // A class which monitors a notification from the browser to keep track of the
21 // browser state (not logged in, logged in, etc.) and notify the current state 21 // browser state (not logged in, logged in, etc.) and notify the current state
22 // to the input method manager. The class also updates the appropriate Chrome 22 // to the input method manager. The class also updates the appropriate Chrome
23 // prefs (~/Local\ State or ~/Preferences) depending on the current browser 23 // prefs (~/Local\ State or ~/Preferences) depending on the current browser
24 // state. 24 // state.
25 class BrowserStateMonitor 25 class BrowserStateMonitor : public content::NotificationObserver,
26 : public content::NotificationObserver, 26 public InputMethodManager::Observer {
27 public input_method::InputMethodManager::Observer {
28 public: 27 public:
29 explicit BrowserStateMonitor(InputMethodManager* manager); 28 explicit BrowserStateMonitor(InputMethodManager* manager);
30 virtual ~BrowserStateMonitor(); 29 virtual ~BrowserStateMonitor();
31 30
31 InputMethodManager::State state() const { return state_; }
32
33 void SetPrefServiceForTesting(PrefService* pref_service);
34
32 protected: 35 protected:
33 // Updates ~/Local\ State file. protected: for testing. 36 // Updates ~/Local\ State file. protected: for testing.
34 virtual void UpdateLocalState(const std::string& current_input_method); 37 virtual void UpdateLocalState(const std::string& current_input_method);
35 // Updates ~/Preferences file. protected: for testing. 38 // Updates ~/Preferences file. protected: for testing.
36 virtual void UpdateUserPreferences(const std::string& current_input_method); 39 virtual void UpdateUserPreferences(const std::string& current_input_method);
37 40
38 private: 41 // InputMethodManager::Observer overrides:
39 // InputMethodManager::Observer implementation. 42 virtual void InputMethodChanged(InputMethodManager* manager) OVERRIDE;
40 virtual void InputMethodChanged( 43 virtual void InputMethodPropertyChanged(InputMethodManager* manager) OVERRIDE;
41 InputMethodManager* manager,
42 const InputMethodDescriptor& current_input_method,
43 size_t num_active_input_methods) OVERRIDE;
44 virtual void ActiveInputMethodsChanged(
45 InputMethodManager* manager,
46 const InputMethodDescriptor& current_input_method,
47 size_t num_active_input_methods) OVERRIDE {}
48 virtual void PropertyListChanged(
49 InputMethodManager* manager,
50 const InputMethodPropertyList& current_ime_properties) OVERRIDE {}
51 44
52 // content::NotificationObserver overrides: 45 // content::NotificationObserver overrides:
53 virtual void Observe(int type, 46 virtual void Observe(int type,
54 const content::NotificationSource& source, 47 const content::NotificationSource& source,
55 const content::NotificationDetails& details) OVERRIDE; 48 const content::NotificationDetails& details) OVERRIDE;
56 49
50 private:
57 void SetState(InputMethodManager::State new_state); 51 void SetState(InputMethodManager::State new_state);
58 void InitializePrefMembers(); 52 void InitializePrefMembers();
59 53
60 InputMethodManager* manager_; 54 InputMethodManager* manager_;
61 InputMethodManager::State state_; 55 InputMethodManager::State state_;
62 56
63 // Objects for updating the Chrome prefs. 57 // Objects for updating the Chrome prefs.
64 StringPrefMember previous_input_method_pref_; 58 StringPrefMember previous_input_method_pref_;
65 StringPrefMember current_input_method_pref_; 59 StringPrefMember current_input_method_pref_;
66 bool initialized_; 60 bool initialized_;
67 61
68 // This is used to register this object to some browser notifications. 62 // This is used to register this object to some browser notifications.
69 content::NotificationRegistrar notification_registrar_; 63 content::NotificationRegistrar notification_registrar_;
70 64
65 // For testing.
66 PrefService* pref_service_;
67
71 DISALLOW_COPY_AND_ASSIGN(BrowserStateMonitor); 68 DISALLOW_COPY_AND_ASSIGN(BrowserStateMonitor);
72 }; 69 };
73 70
74 } // namespace input_method 71 } // namespace input_method
75 } // namespace chromeos 72 } // namespace chromeos
76 73
77 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_BROWSER_STATE_MONITOR_H_ 74 #endif // CHROME_BROWSER_CHROMEOS_INPUT_METHOD_BROWSER_STATE_MONITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698