OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/api/screenlock_private/screenlock_private_ap
i.h" | 5 #include "chrome/browser/extensions/api/screenlock_private/screenlock_private_ap
i.h" |
6 | 6 |
| 7 #include <memory> |
7 #include <utility> | 8 #include <utility> |
8 | 9 |
9 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
10 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
11 #include "base/values.h" | 12 #include "base/values.h" |
12 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/signin/chrome_proximity_auth_client.h" | 14 #include "chrome/browser/signin/chrome_proximity_auth_client.h" |
14 #include "chrome/browser/signin/easy_unlock_service.h" | 15 #include "chrome/browser/signin/easy_unlock_service.h" |
15 #include "chrome/common/extensions/api/screenlock_private.h" | 16 #include "chrome/common/extensions/api/screenlock_private.h" |
16 #include "chrome/common/extensions/extension_constants.h" | 17 #include "chrome/common/extensions/extension_constants.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 : browser_context_(context) { | 113 : browser_context_(context) { |
113 proximity_auth::ScreenlockBridge::Get()->AddObserver(this); | 114 proximity_auth::ScreenlockBridge::Get()->AddObserver(this); |
114 } | 115 } |
115 | 116 |
116 ScreenlockPrivateEventRouter::~ScreenlockPrivateEventRouter() {} | 117 ScreenlockPrivateEventRouter::~ScreenlockPrivateEventRouter() {} |
117 | 118 |
118 void ScreenlockPrivateEventRouter::OnScreenDidLock( | 119 void ScreenlockPrivateEventRouter::OnScreenDidLock( |
119 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) { | 120 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) { |
120 DispatchEvent(events::SCREENLOCK_PRIVATE_ON_CHANGED, | 121 DispatchEvent(events::SCREENLOCK_PRIVATE_ON_CHANGED, |
121 screenlock::OnChanged::kEventName, | 122 screenlock::OnChanged::kEventName, |
122 new base::FundamentalValue(true)); | 123 base::MakeUnique<base::FundamentalValue>(true)); |
123 } | 124 } |
124 | 125 |
125 void ScreenlockPrivateEventRouter::OnScreenDidUnlock( | 126 void ScreenlockPrivateEventRouter::OnScreenDidUnlock( |
126 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) { | 127 proximity_auth::ScreenlockBridge::LockHandler::ScreenType screen_type) { |
127 DispatchEvent(events::SCREENLOCK_PRIVATE_ON_CHANGED, | 128 DispatchEvent(events::SCREENLOCK_PRIVATE_ON_CHANGED, |
128 screenlock::OnChanged::kEventName, | 129 screenlock::OnChanged::kEventName, |
129 new base::FundamentalValue(false)); | 130 base::MakeUnique<base::FundamentalValue>(false)); |
130 } | 131 } |
131 | 132 |
132 void ScreenlockPrivateEventRouter::OnFocusedUserChanged( | 133 void ScreenlockPrivateEventRouter::OnFocusedUserChanged( |
133 const AccountId& account_id) {} | 134 const AccountId& account_id) {} |
134 | 135 |
135 void ScreenlockPrivateEventRouter::DispatchEvent( | 136 void ScreenlockPrivateEventRouter::DispatchEvent( |
136 events::HistogramValue histogram_value, | 137 events::HistogramValue histogram_value, |
137 const std::string& event_name, | 138 const std::string& event_name, |
138 base::Value* arg) { | 139 std::unique_ptr<base::Value> arg) { |
139 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 140 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
140 if (arg) | 141 if (arg) |
141 args->Append(arg); | 142 args->Append(std::move(arg)); |
142 std::unique_ptr<Event> event( | 143 std::unique_ptr<Event> event( |
143 new Event(histogram_value, event_name, std::move(args))); | 144 new Event(histogram_value, event_name, std::move(args))); |
144 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); | 145 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); |
145 } | 146 } |
146 | 147 |
147 static base::LazyInstance< | 148 static base::LazyInstance< |
148 BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>> g_factory = | 149 BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>> g_factory = |
149 LAZY_INSTANCE_INITIALIZER; | 150 LAZY_INSTANCE_INITIALIZER; |
150 | 151 |
151 // static | 152 // static |
(...skipping 18 matching lines...) Expand all Loading... |
170 args->AppendString(value); | 171 args->AppendString(value); |
171 | 172 |
172 std::unique_ptr<Event> event( | 173 std::unique_ptr<Event> event( |
173 new Event(events::SCREENLOCK_PRIVATE_ON_AUTH_ATTEMPTED, | 174 new Event(events::SCREENLOCK_PRIVATE_ON_AUTH_ATTEMPTED, |
174 screenlock::OnAuthAttempted::kEventName, std::move(args))); | 175 screenlock::OnAuthAttempted::kEventName, std::move(args))); |
175 router->BroadcastEvent(std::move(event)); | 176 router->BroadcastEvent(std::move(event)); |
176 return true; | 177 return true; |
177 } | 178 } |
178 | 179 |
179 } // namespace extensions | 180 } // namespace extensions |
OLD | NEW |