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 "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/image_loader.h" | 9 #include "chrome/browser/extensions/image_loader.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 GetExtension(), GetExtension()->GetResource(params->icon), | 121 GetExtension(), GetExtension()->GetResource(params->icon), |
122 gfx::Size(kMaxButtonIconSize, kMaxButtonIconSize), | 122 gfx::Size(kMaxButtonIconSize, kMaxButtonIconSize), |
123 base::Bind(&ScreenlockPrivateShowButtonFunction::OnImageLoaded, this)); | 123 base::Bind(&ScreenlockPrivateShowButtonFunction::OnImageLoaded, this)); |
124 return true; | 124 return true; |
125 } | 125 } |
126 | 126 |
127 void ScreenlockPrivateShowButtonFunction::OnImageLoaded( | 127 void ScreenlockPrivateShowButtonFunction::OnImageLoaded( |
128 const gfx::Image& image) { | 128 const gfx::Image& image) { |
129 ScreenlockBridge::LockHandler* locker = | 129 ScreenlockBridge::LockHandler* locker = |
130 ScreenlockBridge::Get()->lock_handler(); | 130 ScreenlockBridge::Get()->lock_handler(); |
131 ScreenlockPrivateEventRouter* router = | |
132 ScreenlockPrivateEventRouter::GetFactoryInstance()->Get(GetProfile()); | |
133 locker->ShowUserPodButton( | 131 locker->ShowUserPodButton( |
134 ScreenlockBridge::GetAuthenticatedUserEmail(GetProfile()), | 132 ScreenlockBridge::GetAuthenticatedUserEmail(GetProfile()), |
135 image, | 133 image); |
136 base::Bind(&ScreenlockPrivateEventRouter::OnButtonClicked, | |
137 base::Unretained(router))); | |
138 SendResponse(error_.empty()); | 134 SendResponse(error_.empty()); |
139 } | 135 } |
140 | 136 |
141 ScreenlockPrivateHideButtonFunction::ScreenlockPrivateHideButtonFunction() {} | 137 ScreenlockPrivateHideButtonFunction::ScreenlockPrivateHideButtonFunction() {} |
142 | 138 |
143 ScreenlockPrivateHideButtonFunction::~ScreenlockPrivateHideButtonFunction() {} | 139 ScreenlockPrivateHideButtonFunction::~ScreenlockPrivateHideButtonFunction() {} |
144 | 140 |
145 bool ScreenlockPrivateHideButtonFunction::RunAsync() { | 141 bool ScreenlockPrivateHideButtonFunction::RunAsync() { |
146 ScreenlockBridge::LockHandler* locker = | 142 ScreenlockBridge::LockHandler* locker = |
147 ScreenlockBridge::Get()->lock_handler(); | 143 ScreenlockBridge::Get()->lock_handler(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 // static | 257 // static |
262 extensions::BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>* | 258 extensions::BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>* |
263 ScreenlockPrivateEventRouter::GetFactoryInstance() { | 259 ScreenlockPrivateEventRouter::GetFactoryInstance() { |
264 return g_factory.Pointer(); | 260 return g_factory.Pointer(); |
265 } | 261 } |
266 | 262 |
267 void ScreenlockPrivateEventRouter::Shutdown() { | 263 void ScreenlockPrivateEventRouter::Shutdown() { |
268 ScreenlockBridge::Get()->RemoveObserver(this); | 264 ScreenlockBridge::Get()->RemoveObserver(this); |
269 } | 265 } |
270 | 266 |
271 void ScreenlockPrivateEventRouter::OnButtonClicked() { | |
272 DispatchEvent(screenlock::OnButtonClicked::kEventName, NULL); | |
273 } | |
274 | |
275 void ScreenlockPrivateEventRouter::OnAuthAttempted( | 267 void ScreenlockPrivateEventRouter::OnAuthAttempted( |
276 ScreenlockBridge::LockHandler::AuthType auth_type, | 268 ScreenlockBridge::LockHandler::AuthType auth_type, |
277 const std::string& value) { | 269 const std::string& value) { |
278 scoped_ptr<base::ListValue> args(new base::ListValue()); | 270 scoped_ptr<base::ListValue> args(new base::ListValue()); |
279 args->AppendString(screenlock::ToString(FromLockHandlerAuthType(auth_type))); | 271 args->AppendString(screenlock::ToString(FromLockHandlerAuthType(auth_type))); |
280 args->AppendString(value); | 272 args->AppendString(value); |
281 | 273 |
282 scoped_ptr<extensions::Event> event(new extensions::Event( | 274 scoped_ptr<extensions::Event> event(new extensions::Event( |
283 screenlock::OnAuthAttempted::kEventName, args.Pass())); | 275 screenlock::OnAuthAttempted::kEventName, args.Pass())); |
284 extensions::EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); | 276 extensions::EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass()); |
285 } | 277 } |
286 | 278 |
287 } // namespace extensions | 279 } // namespace extensions |
OLD | NEW |