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

Side by Side Diff: chrome/browser/chromeos/extensions/ime_menu_event_router.cc

Issue 1552743003: Add chrome.inputMethodPrivate.onImeMenuActivationChanged API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
Devlin 2016/01/05 18:50:02 year
Azure Wei 2016/01/06 11:50:43 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/extensions/ime_menu_event_router.h"
6
7 #include "base/values.h"
8 #include "chrome/browser/chromeos/extensions/input_method_api.h"
9 #include "content/public/browser/browser_context.h"
10 #include "extensions/browser/event_router.h"
11
12 namespace chromeos {
13
14 ExtensionImeMenuEventRouter::ExtensionImeMenuEventRouter(
15 content::BrowserContext* context)
16 : context_(context) {
17 input_method::InputMethodManager::Get()->AddImeMenuObserver(this);
18 }
19
20 ExtensionImeMenuEventRouter::~ExtensionImeMenuEventRouter() {
21 input_method::InputMethodManager::Get()->RemoveImeMenuObserver(this);
22 }
23
24 void ExtensionImeMenuEventRouter::ImeMenuActivationChanged(bool activation) {
25 extensions::EventRouter* router = extensions::EventRouter::Get(context_);
26
27 if (!router->HasEventListener(
28 extensions::InputMethodAPI::kOnImeMenuActivationChanged)) {
29 return;
30 }
31
32 scoped_ptr<base::ListValue> args(new base::ListValue());
33 args->AppendBoolean(activation);
34
35 // The router will only send the event to extensions that are listening.
36 scoped_ptr<extensions::Event> event(new extensions::Event(
37 extensions::events::INPUT_METHOD_PRIVATE_ON_IME_MENU_ACTIVATION_CHANGED,
38 extensions::InputMethodAPI::kOnImeMenuActivationChanged,
39 std::move(args)));
40 event->restrict_to_browser_context = context_;
41 router->BroadcastEvent(std::move(event));
42 }
43
44 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698