OLD | NEW |
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/browser/extensions/api/passwords_private/passwords_private_dele
gate_factory.h" |
9 #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" | 10 #include "components/password_manager/core/common/experiments.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 ~PasswordsPrivateRemoveSavedPasswordFunction() {} | 33 ~PasswordsPrivateRemoveSavedPasswordFunction() {} |
34 | 34 |
35 ExtensionFunction::ResponseAction | 35 ExtensionFunction::ResponseAction |
36 PasswordsPrivateRemoveSavedPasswordFunction::Run() { | 36 PasswordsPrivateRemoveSavedPasswordFunction::Run() { |
37 scoped_ptr<api::passwords_private::RemoveSavedPassword::Params> | 37 scoped_ptr<api::passwords_private::RemoveSavedPassword::Params> |
38 parameters = api::passwords_private::RemoveSavedPassword::Params:: | 38 parameters = api::passwords_private::RemoveSavedPassword::Params:: |
39 Create(*args_); | 39 Create(*args_); |
40 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 40 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
41 | 41 |
42 PasswordsPrivateDelegate* delegate = | 42 PasswordsPrivateDelegate* delegate = |
43 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context()); | 43 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), |
| 44 true /* create */); |
44 delegate->RemoveSavedPassword( | 45 delegate->RemoveSavedPassword( |
45 parameters->login_pair.origin_url, | 46 parameters->login_pair.origin_url, |
46 parameters->login_pair.username); | 47 parameters->login_pair.username); |
47 | 48 |
48 return RespondNow(NoArguments()); | 49 return RespondNow(NoArguments()); |
49 } | 50 } |
50 | 51 |
51 //////////////////////////////////////////////////////////////////////////////// | 52 //////////////////////////////////////////////////////////////////////////////// |
52 // PasswordsPrivateRemovePasswordExceptionFunction | 53 // PasswordsPrivateRemovePasswordExceptionFunction |
53 | 54 |
54 PasswordsPrivateRemovePasswordExceptionFunction:: | 55 PasswordsPrivateRemovePasswordExceptionFunction:: |
55 ~PasswordsPrivateRemovePasswordExceptionFunction() {} | 56 ~PasswordsPrivateRemovePasswordExceptionFunction() {} |
56 | 57 |
57 ExtensionFunction::ResponseAction | 58 ExtensionFunction::ResponseAction |
58 PasswordsPrivateRemovePasswordExceptionFunction::Run() { | 59 PasswordsPrivateRemovePasswordExceptionFunction::Run() { |
59 scoped_ptr<api::passwords_private::RemovePasswordException::Params> | 60 scoped_ptr<api::passwords_private::RemovePasswordException::Params> |
60 parameters = api::passwords_private::RemovePasswordException:: | 61 parameters = api::passwords_private::RemovePasswordException:: |
61 Params::Create(*args_); | 62 Params::Create(*args_); |
62 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 63 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
63 | 64 |
64 PasswordsPrivateDelegate* delegate = | 65 PasswordsPrivateDelegate* delegate = |
65 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context()); | 66 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), |
| 67 true /* create */); |
66 delegate->RemovePasswordException(parameters->exception_url); | 68 delegate->RemovePasswordException(parameters->exception_url); |
67 | 69 |
68 return RespondNow(NoArguments()); | 70 return RespondNow(NoArguments()); |
69 } | 71 } |
70 | 72 |
71 //////////////////////////////////////////////////////////////////////////////// | 73 //////////////////////////////////////////////////////////////////////////////// |
72 // PasswordsPrivateRequestPlaintextPasswordFunction | 74 // PasswordsPrivateRequestPlaintextPasswordFunction |
73 | 75 |
74 PasswordsPrivateRequestPlaintextPasswordFunction:: | 76 PasswordsPrivateRequestPlaintextPasswordFunction:: |
75 ~PasswordsPrivateRequestPlaintextPasswordFunction() {} | 77 ~PasswordsPrivateRequestPlaintextPasswordFunction() {} |
76 | 78 |
77 ExtensionFunction::ResponseAction | 79 ExtensionFunction::ResponseAction |
78 PasswordsPrivateRequestPlaintextPasswordFunction::Run() { | 80 PasswordsPrivateRequestPlaintextPasswordFunction::Run() { |
79 scoped_ptr<api::passwords_private::RequestPlaintextPassword::Params> | 81 scoped_ptr<api::passwords_private::RequestPlaintextPassword::Params> |
80 parameters = api::passwords_private::RequestPlaintextPassword::Params:: | 82 parameters = api::passwords_private::RequestPlaintextPassword::Params:: |
81 Create(*args_); | 83 Create(*args_); |
82 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 84 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
83 | 85 |
84 PasswordsPrivateDelegate* delegate = | 86 PasswordsPrivateDelegate* delegate = |
85 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context()); | 87 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), |
| 88 true /* create */); |
86 | 89 |
87 delegate->RequestShowPassword(parameters->login_pair.origin_url, | 90 delegate->RequestShowPassword(parameters->login_pair.origin_url, |
88 parameters->login_pair.username, | 91 parameters->login_pair.username, |
89 GetSenderWebContents()); | 92 GetSenderWebContents()); |
90 | 93 |
91 // No response given from this API function; instead, listeners wait for the | 94 // No response given from this API function; instead, listeners wait for the |
92 // chrome.passwordsPrivate.onPlaintextPasswordRetrieved event to fire. | 95 // chrome.passwordsPrivate.onPlaintextPasswordRetrieved event to fire. |
93 return RespondNow(NoArguments()); | 96 return RespondNow(NoArguments()); |
94 } | 97 } |
95 | 98 |
96 } // namespace extensions | 99 } // namespace extensions |
OLD | NEW |