Chromium Code Reviews| 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/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 content::WebContents::FromRenderViewHost(render_view_host()) | |
| 91 ->GetTopLevelNativeWindow()); | |
|
stevenjb
2015/06/01 21:31:57
It's kind of a minor thing, but I think I would pr
Kyle Horimoto
2015/06/01 22:01:11
Done.
| |
| 92 | |
| 93 // No response given from this API function; instead, listeners wait for the | |
| 94 // chrome.passwordsPrivate.onPlaintextPasswordRetrieved event to fire. | |
| 77 return RespondNow(NoArguments()); | 95 return RespondNow(NoArguments()); |
| 78 } | 96 } |
| 79 | 97 |
| 80 } // namespace extensions | 98 } // namespace extensions |
| OLD | NEW |