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

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

Issue 2898383002: [Extensions] Make Event::restrict_to_browser_context const. (Closed)
Patch Set: sync @tott Created 3 years, 7 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
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "chrome/browser/chromeos/extensions/ime_menu_event_router.h" 5 #include "chrome/browser/chromeos/extensions/ime_menu_event_router.h"
6 6
7 #include "base/memory/ptr_util.h"
7 #include "base/values.h" 8 #include "base/values.h"
8 #include "chrome/browser/chromeos/extensions/input_method_api.h" 9 #include "chrome/browser/chromeos/extensions/input_method_api.h"
9 #include "chrome/common/extensions/api/input_method_private.h" 10 #include "chrome/common/extensions/api/input_method_private.h"
10 #include "content/public/browser/browser_context.h" 11 #include "content/public/browser/browser_context.h"
11 #include "extensions/browser/event_router.h" 12 #include "extensions/browser/event_router.h"
12 13
13 namespace input_method_private = extensions::api::input_method_private; 14 namespace input_method_private = extensions::api::input_method_private;
14 namespace OnImeMenuActivationChanged = 15 namespace OnImeMenuActivationChanged =
15 extensions::api::input_method_private::OnImeMenuActivationChanged; 16 extensions::api::input_method_private::OnImeMenuActivationChanged;
16 namespace OnImeMenuListChanged = 17 namespace OnImeMenuListChanged =
(...skipping 16 matching lines...) Expand all
33 void ExtensionImeMenuEventRouter::ImeMenuActivationChanged(bool activation) { 34 void ExtensionImeMenuEventRouter::ImeMenuActivationChanged(bool activation) {
34 extensions::EventRouter* router = extensions::EventRouter::Get(context_); 35 extensions::EventRouter* router = extensions::EventRouter::Get(context_);
35 36
36 if (!router->HasEventListener(OnImeMenuActivationChanged::kEventName)) 37 if (!router->HasEventListener(OnImeMenuActivationChanged::kEventName))
37 return; 38 return;
38 39
39 std::unique_ptr<base::ListValue> args(new base::ListValue()); 40 std::unique_ptr<base::ListValue> args(new base::ListValue());
40 args->AppendBoolean(activation); 41 args->AppendBoolean(activation);
41 42
42 // The router will only send the event to extensions that are listening. 43 // The router will only send the event to extensions that are listening.
43 std::unique_ptr<extensions::Event> event(new extensions::Event( 44 auto event = base::MakeUnique<extensions::Event>(
44 extensions::events::INPUT_METHOD_PRIVATE_ON_IME_MENU_ACTIVATION_CHANGED, 45 extensions::events::INPUT_METHOD_PRIVATE_ON_IME_MENU_ACTIVATION_CHANGED,
45 OnImeMenuActivationChanged::kEventName, std::move(args))); 46 OnImeMenuActivationChanged::kEventName, std::move(args), context_);
46 event->restrict_to_browser_context = context_;
47 router->BroadcastEvent(std::move(event)); 47 router->BroadcastEvent(std::move(event));
48 } 48 }
49 49
50 void ExtensionImeMenuEventRouter::ImeMenuListChanged() { 50 void ExtensionImeMenuEventRouter::ImeMenuListChanged() {
51 extensions::EventRouter* router = extensions::EventRouter::Get(context_); 51 extensions::EventRouter* router = extensions::EventRouter::Get(context_);
52 52
53 if (!router->HasEventListener(OnImeMenuListChanged::kEventName)) 53 if (!router->HasEventListener(OnImeMenuListChanged::kEventName))
54 return; 54 return;
55 55
56 std::unique_ptr<base::ListValue> args(new base::ListValue()); 56 std::unique_ptr<base::ListValue> args(new base::ListValue());
57 57
58 // The router will only send the event to extensions that are listening. 58 // The router will only send the event to extensions that are listening.
59 std::unique_ptr<extensions::Event> event(new extensions::Event( 59 auto event = base::MakeUnique<extensions::Event>(
60 extensions::events::INPUT_METHOD_PRIVATE_ON_IME_MENU_LIST_CHANGED, 60 extensions::events::INPUT_METHOD_PRIVATE_ON_IME_MENU_LIST_CHANGED,
61 OnImeMenuListChanged::kEventName, std::move(args))); 61 OnImeMenuListChanged::kEventName, std::move(args), context_);
62 event->restrict_to_browser_context = context_;
63 router->BroadcastEvent(std::move(event)); 62 router->BroadcastEvent(std::move(event));
64 } 63 }
65 64
66 void ExtensionImeMenuEventRouter::ImeMenuItemsChanged( 65 void ExtensionImeMenuEventRouter::ImeMenuItemsChanged(
67 const std::string& engine_id, 66 const std::string& engine_id,
68 const std::vector<input_method::InputMethodManager::MenuItem>& items) { 67 const std::vector<input_method::InputMethodManager::MenuItem>& items) {
69 extensions::EventRouter* router = extensions::EventRouter::Get(context_); 68 extensions::EventRouter* router = extensions::EventRouter::Get(context_);
70 69
71 if (!router->HasEventListener(OnImeMenuItemsChanged::kEventName)) 70 if (!router->HasEventListener(OnImeMenuItemsChanged::kEventName))
72 return; 71 return;
(...skipping 19 matching lines...) Expand all
92 menu_item.visible.reset(new bool(item.visible)); 91 menu_item.visible.reset(new bool(item.visible));
93 menu_item.checked.reset(new bool(item.checked)); 92 menu_item.checked.reset(new bool(item.checked));
94 menu_item.enabled.reset(new bool(item.enabled)); 93 menu_item.enabled.reset(new bool(item.enabled));
95 menu_items.push_back(std::move(menu_item)); 94 menu_items.push_back(std::move(menu_item));
96 } 95 }
97 96
98 std::unique_ptr<base::ListValue> args = 97 std::unique_ptr<base::ListValue> args =
99 OnImeMenuItemsChanged::Create(engine_id, menu_items); 98 OnImeMenuItemsChanged::Create(engine_id, menu_items);
100 99
101 // The router will only send the event to extensions that are listening. 100 // The router will only send the event to extensions that are listening.
102 std::unique_ptr<extensions::Event> event(new extensions::Event( 101 auto event = base::MakeUnique<extensions::Event>(
103 extensions::events::INPUT_METHOD_PRIVATE_ON_IME_MENU_ITEMS_CHANGED, 102 extensions::events::INPUT_METHOD_PRIVATE_ON_IME_MENU_ITEMS_CHANGED,
104 OnImeMenuItemsChanged::kEventName, std::move(args))); 103 OnImeMenuItemsChanged::kEventName, std::move(args), context_);
105 event->restrict_to_browser_context = context_;
106 router->BroadcastEvent(std::move(event)); 104 router->BroadcastEvent(std::move(event));
107 } 105 }
108 106
109 } // namespace chromeos 107 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698