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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 proximity_auth::ScreenlockBridge::Get()->IsLocked())); | 58 proximity_auth::ScreenlockBridge::Get()->IsLocked())); |
59 SendResponse(error_.empty()); | 59 SendResponse(error_.empty()); |
60 return true; | 60 return true; |
61 } | 61 } |
62 | 62 |
63 ScreenlockPrivateSetLockedFunction::ScreenlockPrivateSetLockedFunction() {} | 63 ScreenlockPrivateSetLockedFunction::ScreenlockPrivateSetLockedFunction() {} |
64 | 64 |
65 ScreenlockPrivateSetLockedFunction::~ScreenlockPrivateSetLockedFunction() {} | 65 ScreenlockPrivateSetLockedFunction::~ScreenlockPrivateSetLockedFunction() {} |
66 | 66 |
67 bool ScreenlockPrivateSetLockedFunction::RunAsync() { | 67 bool ScreenlockPrivateSetLockedFunction::RunAsync() { |
68 scoped_ptr<screenlock::SetLocked::Params> params( | 68 std::unique_ptr<screenlock::SetLocked::Params> params( |
69 screenlock::SetLocked::Params::Create(*args_)); | 69 screenlock::SetLocked::Params::Create(*args_)); |
70 EXTENSION_FUNCTION_VALIDATE(params.get()); | 70 EXTENSION_FUNCTION_VALIDATE(params.get()); |
71 EasyUnlockService* service = EasyUnlockService::Get(GetProfile()); | 71 EasyUnlockService* service = EasyUnlockService::Get(GetProfile()); |
72 if (params->locked) { | 72 if (params->locked) { |
73 if (extension()->id() == extension_misc::kEasyUnlockAppId && | 73 if (extension()->id() == extension_misc::kEasyUnlockAppId && |
74 AppWindowRegistry::Get(browser_context()) | 74 AppWindowRegistry::Get(browser_context()) |
75 ->GetAppWindowForAppAndKey(extension()->id(), | 75 ->GetAppWindowForAppAndKey(extension()->id(), |
76 "easy_unlock_pairing")) { | 76 "easy_unlock_pairing")) { |
77 // Mark the Easy Unlock behaviour on the lock screen as the one initiated | 77 // Mark the Easy Unlock behaviour on the lock screen as the one initiated |
78 // by the Easy Unlock setup app as a trial one. | 78 // by the Easy Unlock setup app as a trial one. |
79 // TODO(tbarzic): Move this logic to a new easyUnlockPrivate function. | 79 // TODO(tbarzic): Move this logic to a new easyUnlockPrivate function. |
80 service->SetTrialRun(); | 80 service->SetTrialRun(); |
81 } | 81 } |
82 proximity_auth::ScreenlockBridge::Get()->Lock(); | 82 proximity_auth::ScreenlockBridge::Get()->Lock(); |
83 } else { | 83 } else { |
84 proximity_auth::ScreenlockBridge::Get()->Unlock(AccountId::FromUserEmail( | 84 proximity_auth::ScreenlockBridge::Get()->Unlock(AccountId::FromUserEmail( |
85 service->proximity_auth_client()->GetAuthenticatedUsername())); | 85 service->proximity_auth_client()->GetAuthenticatedUsername())); |
86 } | 86 } |
87 SendResponse(error_.empty()); | 87 SendResponse(error_.empty()); |
88 return true; | 88 return true; |
89 } | 89 } |
90 | 90 |
91 ScreenlockPrivateAcceptAuthAttemptFunction:: | 91 ScreenlockPrivateAcceptAuthAttemptFunction:: |
92 ScreenlockPrivateAcceptAuthAttemptFunction() {} | 92 ScreenlockPrivateAcceptAuthAttemptFunction() {} |
93 | 93 |
94 ScreenlockPrivateAcceptAuthAttemptFunction:: | 94 ScreenlockPrivateAcceptAuthAttemptFunction:: |
95 ~ScreenlockPrivateAcceptAuthAttemptFunction() {} | 95 ~ScreenlockPrivateAcceptAuthAttemptFunction() {} |
96 | 96 |
97 bool ScreenlockPrivateAcceptAuthAttemptFunction::RunSync() { | 97 bool ScreenlockPrivateAcceptAuthAttemptFunction::RunSync() { |
98 scoped_ptr<screenlock::AcceptAuthAttempt::Params> params( | 98 std::unique_ptr<screenlock::AcceptAuthAttempt::Params> params( |
99 screenlock::AcceptAuthAttempt::Params::Create(*args_)); | 99 screenlock::AcceptAuthAttempt::Params::Create(*args_)); |
100 EXTENSION_FUNCTION_VALIDATE(params.get()); | 100 EXTENSION_FUNCTION_VALIDATE(params.get()); |
101 | 101 |
102 Profile* profile = Profile::FromBrowserContext(browser_context()); | 102 Profile* profile = Profile::FromBrowserContext(browser_context()); |
103 EasyUnlockService* service = EasyUnlockService::Get(profile); | 103 EasyUnlockService* service = EasyUnlockService::Get(profile); |
104 if (service) | 104 if (service) |
105 service->FinalizeUnlock(params->accept); | 105 service->FinalizeUnlock(params->accept); |
106 return true; | 106 return true; |
107 } | 107 } |
108 | 108 |
(...skipping 19 matching lines...) Expand all Loading... |
128 new base::FundamentalValue(false)); | 128 new base::FundamentalValue(false)); |
129 } | 129 } |
130 | 130 |
131 void ScreenlockPrivateEventRouter::OnFocusedUserChanged( | 131 void ScreenlockPrivateEventRouter::OnFocusedUserChanged( |
132 const AccountId& account_id) {} | 132 const AccountId& account_id) {} |
133 | 133 |
134 void ScreenlockPrivateEventRouter::DispatchEvent( | 134 void ScreenlockPrivateEventRouter::DispatchEvent( |
135 events::HistogramValue histogram_value, | 135 events::HistogramValue histogram_value, |
136 const std::string& event_name, | 136 const std::string& event_name, |
137 base::Value* arg) { | 137 base::Value* arg) { |
138 scoped_ptr<base::ListValue> args(new base::ListValue()); | 138 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
139 if (arg) | 139 if (arg) |
140 args->Append(arg); | 140 args->Append(arg); |
141 scoped_ptr<Event> event( | 141 std::unique_ptr<Event> event( |
142 new Event(histogram_value, event_name, std::move(args))); | 142 new Event(histogram_value, event_name, std::move(args))); |
143 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); | 143 EventRouter::Get(browser_context_)->BroadcastEvent(std::move(event)); |
144 } | 144 } |
145 | 145 |
146 static base::LazyInstance< | 146 static base::LazyInstance< |
147 BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>> g_factory = | 147 BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>> g_factory = |
148 LAZY_INSTANCE_INITIALIZER; | 148 LAZY_INSTANCE_INITIALIZER; |
149 | 149 |
150 // static | 150 // static |
151 BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>* | 151 BrowserContextKeyedAPIFactory<ScreenlockPrivateEventRouter>* |
152 ScreenlockPrivateEventRouter::GetFactoryInstance() { | 152 ScreenlockPrivateEventRouter::GetFactoryInstance() { |
153 return g_factory.Pointer(); | 153 return g_factory.Pointer(); |
154 } | 154 } |
155 | 155 |
156 void ScreenlockPrivateEventRouter::Shutdown() { | 156 void ScreenlockPrivateEventRouter::Shutdown() { |
157 proximity_auth::ScreenlockBridge::Get()->RemoveObserver(this); | 157 proximity_auth::ScreenlockBridge::Get()->RemoveObserver(this); |
158 } | 158 } |
159 | 159 |
160 bool ScreenlockPrivateEventRouter::OnAuthAttempted( | 160 bool ScreenlockPrivateEventRouter::OnAuthAttempted( |
161 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type, | 161 proximity_auth::ScreenlockBridge::LockHandler::AuthType auth_type, |
162 const std::string& value) { | 162 const std::string& value) { |
163 EventRouter* router = EventRouter::Get(browser_context_); | 163 EventRouter* router = EventRouter::Get(browser_context_); |
164 if (!router->HasEventListener(screenlock::OnAuthAttempted::kEventName)) | 164 if (!router->HasEventListener(screenlock::OnAuthAttempted::kEventName)) |
165 return false; | 165 return false; |
166 | 166 |
167 scoped_ptr<base::ListValue> args(new base::ListValue()); | 167 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
168 args->AppendString(screenlock::ToString(FromLockHandlerAuthType(auth_type))); | 168 args->AppendString(screenlock::ToString(FromLockHandlerAuthType(auth_type))); |
169 args->AppendString(value); | 169 args->AppendString(value); |
170 | 170 |
171 scoped_ptr<Event> event( | 171 std::unique_ptr<Event> event( |
172 new Event(events::SCREENLOCK_PRIVATE_ON_AUTH_ATTEMPTED, | 172 new Event(events::SCREENLOCK_PRIVATE_ON_AUTH_ATTEMPTED, |
173 screenlock::OnAuthAttempted::kEventName, std::move(args))); | 173 screenlock::OnAuthAttempted::kEventName, std::move(args))); |
174 router->BroadcastEvent(std::move(event)); | 174 router->BroadcastEvent(std::move(event)); |
175 return true; | 175 return true; |
176 } | 176 } |
177 | 177 |
178 } // namespace extensions | 178 } // namespace extensions |
OLD | NEW |