| 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 "components/password_manager/sync/browser/sync_credentials_filter.h" | 5 #include "components/password_manager/sync/browser/sync_credentials_filter.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/bind.h" | 10 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 12 #include "base/macros.h" | 13 #include "base/macros.h" |
| 13 #include "base/test/histogram_tester.h" | 14 #include "base/test/histogram_tester.h" |
| 14 #include "base/test/user_action_tester.h" | 15 #include "base/test/user_action_tester.h" |
| 15 #include "components/autofill/core/common/password_form.h" | 16 #include "components/autofill/core/common/password_form.h" |
| 16 #include "components/password_manager/core/browser/stub_password_manager_client.
h" | 17 #include "components/password_manager/core/browser/stub_password_manager_client.
h" |
| 17 #include "components/password_manager/core/common/password_manager_switches.h" | 18 #include "components/password_manager/core/common/password_manager_switches.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 36 void set_last_committed_entry_url(const char* url_spec) { | 37 void set_last_committed_entry_url(const char* url_spec) { |
| 37 last_committed_entry_url_ = GURL(url_spec); | 38 last_committed_entry_url_ = GURL(url_spec); |
| 38 } | 39 } |
| 39 | 40 |
| 40 GURL last_committed_entry_url_; | 41 GURL last_committed_entry_url_; |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 bool IsFormFiltered(const CredentialsFilter* filter, const PasswordForm& form) { | 44 bool IsFormFiltered(const CredentialsFilter* filter, const PasswordForm& form) { |
| 44 ScopedVector<PasswordForm> vector; | 45 ScopedVector<PasswordForm> vector; |
| 45 vector.push_back(new PasswordForm(form)); | 46 vector.push_back(new PasswordForm(form)); |
| 46 vector = filter->FilterResults(vector.Pass()); | 47 vector = filter->FilterResults(std::move(vector)); |
| 47 return vector.empty(); | 48 return vector.empty(); |
| 48 } | 49 } |
| 49 | 50 |
| 50 } // namespace | 51 } // namespace |
| 51 | 52 |
| 52 class CredentialsFilterTest : public SyncUsernameTestBase { | 53 class CredentialsFilterTest : public SyncUsernameTestBase { |
| 53 public: | 54 public: |
| 54 struct TestCase { | 55 struct TestCase { |
| 55 enum { SYNCING_PASSWORDS, NOT_SYNCING_PASSWORDS } password_sync; | 56 enum { SYNCING_PASSWORDS, NOT_SYNCING_PASSWORDS } password_sync; |
| 56 PasswordForm form; | 57 PasswordForm form; |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 // Adding disallow switch should cause sync credential to be filtered. | 251 // Adding disallow switch should cause sync credential to be filtered. |
| 251 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 252 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 252 command_line->AppendSwitch(switches::kDisallowAutofillSyncCredential); | 253 command_line->AppendSwitch(switches::kDisallowAutofillSyncCredential); |
| 253 | 254 |
| 254 ScopedVector<autofill::PasswordForm> results; | 255 ScopedVector<autofill::PasswordForm> results; |
| 255 results.push_back(new PasswordForm(SimpleGaiaForm("test1@gmail.com"))); | 256 results.push_back(new PasswordForm(SimpleGaiaForm("test1@gmail.com"))); |
| 256 results.push_back(new PasswordForm(SimpleGaiaForm("test2@gmail.com"))); | 257 results.push_back(new PasswordForm(SimpleGaiaForm("test2@gmail.com"))); |
| 257 | 258 |
| 258 FakeSigninAs("test1@gmail.com"); | 259 FakeSigninAs("test1@gmail.com"); |
| 259 | 260 |
| 260 results = filter()->FilterResults(results.Pass()); | 261 results = filter()->FilterResults(std::move(results)); |
| 261 | 262 |
| 262 ASSERT_EQ(1u, results.size()); | 263 ASSERT_EQ(1u, results.size()); |
| 263 EXPECT_EQ(SimpleGaiaForm("test2@gmail.com"), *results[0]); | 264 EXPECT_EQ(SimpleGaiaForm("test2@gmail.com"), *results[0]); |
| 264 } | 265 } |
| 265 | 266 |
| 266 } // namespace password_manager | 267 } // namespace password_manager |
| OLD | NEW |