| 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/ui/autofill/save_card_bubble_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 12 #include "base/test/histogram_tester.h" | 13 #include "base/test/histogram_tester.h" |
| 13 #include "base/values.h" | 14 #include "base/values.h" |
| 14 #include "chrome/browser/ui/autofill/save_card_bubble_view.h" | 15 #include "chrome/browser/ui/autofill/save_card_bubble_view.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/test/base/browser_with_test_window_test.h" | 17 #include "chrome/test/base/browser_with_test_window_test.h" |
| 17 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 18 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 } | 66 } |
| 66 | 67 |
| 67 void SetLegalMessage(const std::string& message_json) { | 68 void SetLegalMessage(const std::string& message_json) { |
| 68 scoped_ptr<base::Value> value(base::JSONReader::Read(message_json)); | 69 scoped_ptr<base::Value> value(base::JSONReader::Read(message_json)); |
| 69 ASSERT_TRUE(value); | 70 ASSERT_TRUE(value); |
| 70 base::DictionaryValue* dictionary; | 71 base::DictionaryValue* dictionary; |
| 71 ASSERT_TRUE(value->GetAsDictionary(&dictionary)); | 72 ASSERT_TRUE(value->GetAsDictionary(&dictionary)); |
| 72 scoped_ptr<base::DictionaryValue> legal_message = | 73 scoped_ptr<base::DictionaryValue> legal_message = |
| 73 dictionary->CreateDeepCopy(); | 74 dictionary->CreateDeepCopy(); |
| 74 controller()->ShowBubbleForUpload(base::Bind(&SaveCardCallback), | 75 controller()->ShowBubbleForUpload(base::Bind(&SaveCardCallback), |
| 75 legal_message.Pass()); | 76 std::move(legal_message)); |
| 76 } | 77 } |
| 77 | 78 |
| 78 // Returns true if lines are the same. | 79 // Returns true if lines are the same. |
| 79 bool CompareLegalMessageLines(const LegalMessageLine& a, | 80 bool CompareLegalMessageLines(const LegalMessageLine& a, |
| 80 const LegalMessageLine& b) { | 81 const LegalMessageLine& b) { |
| 81 if (a.text != b.text) | 82 if (a.text != b.text) |
| 82 return false; | 83 return false; |
| 83 if (a.links.size() != b.links.size()) | 84 if (a.links.size() != b.links.size()) |
| 84 return false; | 85 return false; |
| 85 for (size_t i = 0; i < a.links.size(); ++i) { | 86 for (size_t i = 0; i < a.links.size(); ++i) { |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 EXPECT_THAT( | 681 EXPECT_THAT( |
| 681 histogram_tester.GetAllSamples( | 682 histogram_tester.GetAllSamples( |
| 682 "Autofill.SaveCreditCardPrompt.Upload.FirstShow"), | 683 "Autofill.SaveCreditCardPrompt.Upload.FirstShow"), |
| 683 ElementsAre( | 684 ElementsAre( |
| 684 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), | 685 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_SHOW_REQUESTED, 1), |
| 685 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_INVALID_LEGAL_MESSAGE, | 686 Bucket(AutofillMetrics::SAVE_CARD_PROMPT_END_INVALID_LEGAL_MESSAGE, |
| 686 1))); | 687 1))); |
| 687 } | 688 } |
| 688 | 689 |
| 689 } // namespace autofill | 690 } // namespace autofill |
| OLD | NEW |