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

Side by Side Diff: chrome/browser/extensions/api/passwords_private/passwords_private_api.cc

Issue 1142693003: Implement the chrome.passwordsPrivate API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: stevenjb comment. Created 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/passwords_private/passwords_private_api. h" 5 #include "chrome/browser/extensions/api/passwords_private/passwords_private_api. h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/extensions/api/passwords_private/passwords_private_dele gate_factory.h"
8 #include "chrome/common/extensions/api/passwords_private.h" 9 #include "chrome/common/extensions/api/passwords_private.h"
10 #include "components/password_manager/core/common/experiments.h"
11 #include "content/public/browser/web_contents.h"
9 #include "extensions/browser/extension_function_registry.h" 12 #include "extensions/browser/extension_function_registry.h"
10 13
11 namespace extensions { 14 namespace extensions {
12 15
13 //////////////////////////////////////////////////////////////////////////////// 16 ////////////////////////////////////////////////////////////////////////////////
14 // PasswordsPrivateCanPasswordAccountBeManagedFunction 17 // PasswordsPrivateCanPasswordAccountBeManagedFunction
15 18
16 PasswordsPrivateCanPasswordAccountBeManagedFunction:: 19 PasswordsPrivateCanPasswordAccountBeManagedFunction::
17 ~PasswordsPrivateCanPasswordAccountBeManagedFunction() {} 20 ~PasswordsPrivateCanPasswordAccountBeManagedFunction() {}
18 21
19 ExtensionFunction::ResponseAction 22 ExtensionFunction::ResponseAction
20 PasswordsPrivateCanPasswordAccountBeManagedFunction::Run() { 23 PasswordsPrivateCanPasswordAccountBeManagedFunction::Run() {
21 // TODO(khorimoto): Implement. 24 scoped_ptr<base::FundamentalValue> visible(new base::FundamentalValue(
22 25 password_manager::ManageAccountLinkExperimentEnabled()));
23 return RespondNow(NoArguments()); 26 return RespondNow(OneArgument(visible.Pass()));
24 } 27 }
25 28
26 //////////////////////////////////////////////////////////////////////////////// 29 ////////////////////////////////////////////////////////////////////////////////
27 // PasswordsPrivateRemoveSavedPasswordFunction 30 // PasswordsPrivateRemoveSavedPasswordFunction
28 31
29 PasswordsPrivateRemoveSavedPasswordFunction:: 32 PasswordsPrivateRemoveSavedPasswordFunction::
30 ~PasswordsPrivateRemoveSavedPasswordFunction() {} 33 ~PasswordsPrivateRemoveSavedPasswordFunction() {}
31 34
32 ExtensionFunction::ResponseAction 35 ExtensionFunction::ResponseAction
33 PasswordsPrivateRemoveSavedPasswordFunction::Run() { 36 PasswordsPrivateRemoveSavedPasswordFunction::Run() {
34 scoped_ptr<api::passwords_private::RemoveSavedPassword::Params> 37 scoped_ptr<api::passwords_private::RemoveSavedPassword::Params>
35 parameters = api::passwords_private::RemoveSavedPassword::Params:: 38 parameters = api::passwords_private::RemoveSavedPassword::Params::
36 Create(*args_); 39 Create(*args_);
37 EXTENSION_FUNCTION_VALIDATE(parameters.get()); 40 EXTENSION_FUNCTION_VALIDATE(parameters.get());
38 41
39 // TODO(khorimoto): Implement. 42 PasswordsPrivateDelegate* delegate =
43 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context());
44 delegate->RemoveSavedPassword(
45 parameters->login_pair.origin_url,
46 parameters->login_pair.username);
40 47
41 return RespondNow(NoArguments()); 48 return RespondNow(NoArguments());
42 } 49 }
43 50
44 //////////////////////////////////////////////////////////////////////////////// 51 ////////////////////////////////////////////////////////////////////////////////
45 // PasswordsPrivateRemovePasswordExceptionFunction 52 // PasswordsPrivateRemovePasswordExceptionFunction
46 53
47 PasswordsPrivateRemovePasswordExceptionFunction:: 54 PasswordsPrivateRemovePasswordExceptionFunction::
48 ~PasswordsPrivateRemovePasswordExceptionFunction() {} 55 ~PasswordsPrivateRemovePasswordExceptionFunction() {}
49 56
50 ExtensionFunction::ResponseAction 57 ExtensionFunction::ResponseAction
51 PasswordsPrivateRemovePasswordExceptionFunction::Run() { 58 PasswordsPrivateRemovePasswordExceptionFunction::Run() {
52 scoped_ptr<api::passwords_private::RemovePasswordException::Params> 59 scoped_ptr<api::passwords_private::RemovePasswordException::Params>
53 parameters = api::passwords_private::RemovePasswordException:: 60 parameters = api::passwords_private::RemovePasswordException::
54 Params::Create(*args_); 61 Params::Create(*args_);
55 EXTENSION_FUNCTION_VALIDATE(parameters.get()); 62 EXTENSION_FUNCTION_VALIDATE(parameters.get());
56 63
57 // TODO(khorimoto): Implement. 64 PasswordsPrivateDelegate* delegate =
65 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context());
66 delegate->RemovePasswordException(parameters->exception_url);
58 67
59 return RespondNow(NoArguments()); 68 return RespondNow(NoArguments());
60 } 69 }
61 70
62 //////////////////////////////////////////////////////////////////////////////// 71 ////////////////////////////////////////////////////////////////////////////////
63 // PasswordsPrivateGetPlaintextPasswordFunction 72 // PasswordsPrivateRequestPlaintextPasswordFunction
64 73
65 PasswordsPrivateGetPlaintextPasswordFunction:: 74 PasswordsPrivateRequestPlaintextPasswordFunction::
66 ~PasswordsPrivateGetPlaintextPasswordFunction() {} 75 ~PasswordsPrivateRequestPlaintextPasswordFunction() {}
67 76
68 ExtensionFunction::ResponseAction 77 ExtensionFunction::ResponseAction
69 PasswordsPrivateGetPlaintextPasswordFunction::Run() { 78 PasswordsPrivateRequestPlaintextPasswordFunction::Run() {
70 scoped_ptr<api::passwords_private::GetPlaintextPassword::Params> 79 scoped_ptr<api::passwords_private::RequestPlaintextPassword::Params>
71 parameters = api::passwords_private::GetPlaintextPassword::Params:: 80 parameters = api::passwords_private::RequestPlaintextPassword::Params::
72 Create(*args_); 81 Create(*args_);
73 EXTENSION_FUNCTION_VALIDATE(parameters.get()); 82 EXTENSION_FUNCTION_VALIDATE(parameters.get());
74 83
75 // TODO(khorimoto): Implement. 84 PasswordsPrivateDelegate* delegate =
85 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context());
76 86
87 delegate->RequestShowPassword(
88 parameters->login_pair.origin_url,
89 parameters->login_pair.username,
90 render_view_host());
91
92 // No response given from this API function; instead, listeners wait for the
93 // chrome.passwordsPrivate.onPlaintextPasswordRetrieved event to fire.
77 return RespondNow(NoArguments()); 94 return RespondNow(NoArguments());
78 } 95 }
79 96
80 } // namespace extensions 97 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698