OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/password_manager/chrome_password_manager_client.h" | 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/sync/profile_sync_service_factory.h" | 10 #include "chrome/browser/sync/profile_sync_service_factory.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 const char kTestText[] = "abcd1234"; | 34 const char kTestText[] = "abcd1234"; |
35 | 35 |
36 class MockLogReceiver : public password_manager::LogReceiver { | 36 class MockLogReceiver : public password_manager::LogReceiver { |
37 public: | 37 public: |
38 MOCK_METHOD1(LogSavePasswordProgress, void(const std::string&)); | 38 MOCK_METHOD1(LogSavePasswordProgress, void(const std::string&)); |
39 }; | 39 }; |
40 | 40 |
41 class TestChromePasswordManagerClient : public ChromePasswordManagerClient { | 41 class TestChromePasswordManagerClient : public ChromePasswordManagerClient { |
42 public: | 42 public: |
43 explicit TestChromePasswordManagerClient(content::WebContents* web_contents) | 43 explicit TestChromePasswordManagerClient(content::WebContents* web_contents) |
44 : ChromePasswordManagerClient(web_contents, NULL), | 44 : ChromePasswordManagerClient(web_contents, nullptr), |
45 is_sync_account_credential_(false) {} | 45 is_sync_account_credential_(false) {} |
46 ~TestChromePasswordManagerClient() override {} | 46 ~TestChromePasswordManagerClient() override {} |
47 | 47 |
48 bool IsSyncAccountCredential(const std::string& username, | 48 bool IsSyncAccountCredential(const std::string& username, |
49 const std::string& origin) const override { | 49 const std::string& origin) const override { |
50 return is_sync_account_credential_; | 50 return is_sync_account_credential_; |
51 } | 51 } |
52 | 52 |
53 void set_is_sync_account_credential(bool is_sync_account_credential) { | 53 void set_is_sync_account_credential(bool is_sync_account_credential) { |
54 is_sync_account_credential_ = is_sync_account_credential; | 54 is_sync_account_credential_ = is_sync_account_credential; |
(...skipping 20 matching lines...) Expand all Loading... |
75 // copies its argument into |activation_flag| and returns true. Otherwise | 75 // copies its argument into |activation_flag| and returns true. Otherwise |
76 // returns false. | 76 // returns false. |
77 bool WasLoggingActivationMessageSent(bool* activation_flag); | 77 bool WasLoggingActivationMessageSent(bool* activation_flag); |
78 | 78 |
79 password_manager::PasswordManagerInternalsService* service_; | 79 password_manager::PasswordManagerInternalsService* service_; |
80 | 80 |
81 testing::StrictMock<MockLogReceiver> receiver_; | 81 testing::StrictMock<MockLogReceiver> receiver_; |
82 }; | 82 }; |
83 | 83 |
84 ChromePasswordManagerClientTest::ChromePasswordManagerClientTest() | 84 ChromePasswordManagerClientTest::ChromePasswordManagerClientTest() |
85 : service_(NULL) { | 85 : service_(nullptr) { |
86 } | 86 } |
87 | 87 |
88 void ChromePasswordManagerClientTest::SetUp() { | 88 void ChromePasswordManagerClientTest::SetUp() { |
89 ChromeRenderViewHostTestHarness::SetUp(); | 89 ChromeRenderViewHostTestHarness::SetUp(); |
90 ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( | 90 ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient( |
91 web_contents(), NULL); | 91 web_contents(), nullptr); |
92 service_ = password_manager::PasswordManagerInternalsServiceFactory:: | 92 service_ = password_manager::PasswordManagerInternalsServiceFactory:: |
93 GetForBrowserContext(profile()); | 93 GetForBrowserContext(profile()); |
94 ASSERT_TRUE(service_); | 94 ASSERT_TRUE(service_); |
95 } | 95 } |
96 | 96 |
97 ChromePasswordManagerClient* ChromePasswordManagerClientTest::GetClient() { | 97 ChromePasswordManagerClient* ChromePasswordManagerClientTest::GetClient() { |
98 return ChromePasswordManagerClient::FromWebContents(web_contents()); | 98 return ChromePasswordManagerClient::FromWebContents(web_contents()); |
99 } | 99 } |
100 | 100 |
101 bool ChromePasswordManagerClientTest::WasLoggingActivationMessageSent( | 101 bool ChromePasswordManagerClientTest::WasLoggingActivationMessageSent( |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 | 394 |
395 // Again, without a custom passphrase. | 395 // Again, without a custom passphrase. |
396 EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase()) | 396 EXPECT_CALL(*mock_sync_service, IsUsingSecondaryPassphrase()) |
397 .WillRepeatedly(Return(false)); | 397 .WillRepeatedly(Return(false)); |
398 | 398 |
399 EXPECT_FALSE( | 399 EXPECT_FALSE( |
400 client->IsPasswordSyncEnabled(password_manager::ONLY_CUSTOM_PASSPHRASE)); | 400 client->IsPasswordSyncEnabled(password_manager::ONLY_CUSTOM_PASSPHRASE)); |
401 EXPECT_FALSE(client->IsPasswordSyncEnabled( | 401 EXPECT_FALSE(client->IsPasswordSyncEnabled( |
402 password_manager::WITHOUT_CUSTOM_PASSPHRASE)); | 402 password_manager::WITHOUT_CUSTOM_PASSPHRASE)); |
403 } | 403 } |
OLD | NEW |