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

Side by Side Diff: extensions/browser/api/idle/idle_manager.cc

Issue 2898383002: [Extensions] Make Event::restrict_to_browser_context const. (Closed)
Patch Set: sync @tott Created 3 years, 6 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 (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 #include "extensions/browser/api/idle/idle_manager.h" 5 #include "extensions/browser/api/idle/idle_manager.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/memory/ptr_util.h" 9 #include "base/memory/ptr_util.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 : context_(context) { 43 : context_(context) {
44 } 44 }
45 45
46 DefaultEventDelegate::~DefaultEventDelegate() { 46 DefaultEventDelegate::~DefaultEventDelegate() {
47 } 47 }
48 48
49 void DefaultEventDelegate::OnStateChanged(const std::string& extension_id, 49 void DefaultEventDelegate::OnStateChanged(const std::string& extension_id,
50 ui::IdleState new_state) { 50 ui::IdleState new_state) {
51 std::unique_ptr<base::ListValue> args(new base::ListValue()); 51 std::unique_ptr<base::ListValue> args(new base::ListValue());
52 args->Append(IdleManager::CreateIdleValue(new_state)); 52 args->Append(IdleManager::CreateIdleValue(new_state));
53 std::unique_ptr<Event> event(new Event(events::IDLE_ON_STATE_CHANGED, 53 auto event = base::MakeUnique<Event>(events::IDLE_ON_STATE_CHANGED,
54 idle::OnStateChanged::kEventName, 54 idle::OnStateChanged::kEventName,
55 std::move(args))); 55 std::move(args), context_);
56 event->restrict_to_browser_context = context_;
57 EventRouter::Get(context_) 56 EventRouter::Get(context_)
58 ->DispatchEventToExtension(extension_id, std::move(event)); 57 ->DispatchEventToExtension(extension_id, std::move(event));
59 } 58 }
60 59
61 void DefaultEventDelegate::RegisterObserver(EventRouter::Observer* observer) { 60 void DefaultEventDelegate::RegisterObserver(EventRouter::Observer* observer) {
62 EventRouter::Get(context_) 61 EventRouter::Get(context_)
63 ->RegisterObserver(observer, idle::OnStateChanged::kEventName); 62 ->RegisterObserver(observer, idle::OnStateChanged::kEventName);
64 } 63 }
65 64
66 void DefaultEventDelegate::UnregisterObserver(EventRouter::Observer* observer) { 65 void DefaultEventDelegate::UnregisterObserver(EventRouter::Observer* observer) {
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 event_delegate_->OnStateChanged(it->first, new_state); 255 event_delegate_->OnStateChanged(it->first, new_state);
257 monitor.last_state = new_state; 256 monitor.last_state = new_state;
258 listener_count += monitor.listeners; 257 listener_count += monitor.listeners;
259 } 258 }
260 259
261 if (listener_count == 0) 260 if (listener_count == 0)
262 StopPolling(); 261 StopPolling();
263 } 262 }
264 263
265 } // namespace extensions 264 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/app_runtime/app_runtime_api.cc ('k') | extensions/browser/event_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698