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

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

Issue 449050: Implement "Language Switcher" for Chromium OS. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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/language_library.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_CHROMEOS_LANGUAGE_LIBRARY_H_
6 #define CHROME_BROWSER_CHROMEOS_LANGUAGE_LIBRARY_H_
7
8 #include <string>
9
10 #include "base/observer_list.h"
11 #include "base/singleton.h"
12 #include "base/time.h"
13 #include "third_party/cros/chromeos_language.h"
14
15 namespace chromeos {
16
17 // This class handles the interaction with the ChromeOS language library APIs.
18 // Classes can add themselves as observers. Users can get an instance of this
19 // library class like this: LanguageLibrary::Get()
20 class LanguageLibrary {
21 public:
22 class Observer {
23 public:
24 virtual ~Observer() = 0;
25 virtual void LanguageChanged(LanguageLibrary* obj) = 0;
26 };
27
28 // This gets the singleton LanguageLibrary
29 static LanguageLibrary* Get();
30
31 // Makes sure the library is loaded, loading it if necessary. Returns true if
32 // the library has been successfully loaded.
33 static bool EnsureLoaded();
34
35 void AddObserver(Observer* observer);
36 void RemoveObserver(Observer* observer);
37
38 // Returns the list of IMEs and keyboard layouts we can select. If the cros
39 // library is not found or IBus/DBus daemon is not alive, this function
40 // returns a fallback language list (and never returns NULL).
41 InputLanguageList* GetLanguages();
42
43 // Changes the current IME engine to |id| and enable IME (when |category|
44 // is LANGUAGE_CATEGORY_IME). Changes the current XKB layout to |id| and
45 // disable IME (when |category| is LANGUAGE_CATEGORY_XKB). |id| is a unique
46 // identifier of a IME engine or XKB layout. Please check chromeos_language.h
47 // in src third_party/cros/ for details.
48 void ChangeLanguage(LanguageCategory category, const std::string& id);
49
50 const InputLanguage& current_language() const {
51 return current_language_;
52 }
53
54 private:
55 friend struct DefaultSingletonTraits<LanguageLibrary>;
56
57 LanguageLibrary();
58 ~LanguageLibrary();
59
60 // This method is called when there's a change in language status.
61 // This method is called on a background thread.
62 static void LanguageChangedHandler(
63 void* object, const InputLanguage& current_language);
64
65 // This methods starts the monitoring of language changes.
66 void Init();
67
68 // Called by the handler to update the language status.
69 // This will notify all the Observers.
70 void UpdateCurrentLanguage(const InputLanguage& current_language);
71
72 // A reference to the language api, to allow callbacks when the language
73 // status changes.
74 LanguageStatusConnection* language_status_connection_;
75 ObserverList<Observer> observers_;
76
77 // The language (IME or XKB layout) which currently selected.
78 InputLanguage current_language_;
79
80 DISALLOW_COPY_AND_ASSIGN(LanguageLibrary);
81 };
82
83 } // namespace chromeos
84
85 #endif // CHROME_BROWSER_CHROMEOS_LANGUAGE_LIBRARY_H_
86
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/language_library.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698