Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(247)

Side by Side Diff: chrome/browser/ui/views/payments/payment_request_browsertest_base.cc

Issue 2772103002: [Payments] Desktop: never return false in incognito mode for canMakePayment (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/views/payments/payment_request_browsertest_base.h" 5 #include "chrome/browser/ui/views/payments/payment_request_browsertest_base.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "ui/views/controls/label.h" 45 #include "ui/views/controls/label.h"
46 #include "ui/views/controls/styled_label.h" 46 #include "ui/views/controls/styled_label.h"
47 47
48 namespace payments { 48 namespace payments {
49 49
50 PersonalDataLoadedObserverMock::PersonalDataLoadedObserverMock() {} 50 PersonalDataLoadedObserverMock::PersonalDataLoadedObserverMock() {}
51 PersonalDataLoadedObserverMock::~PersonalDataLoadedObserverMock() {} 51 PersonalDataLoadedObserverMock::~PersonalDataLoadedObserverMock() {}
52 52
53 PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase( 53 PaymentRequestBrowserTestBase::PaymentRequestBrowserTestBase(
54 const std::string& test_file_path) 54 const std::string& test_file_path)
55 : test_file_path_(test_file_path), delegate_(nullptr) {} 55 : test_file_path_(test_file_path),
56 delegate_(nullptr),
57 incognito_for_testing_(false) {}
56 PaymentRequestBrowserTestBase::~PaymentRequestBrowserTestBase() {} 58 PaymentRequestBrowserTestBase::~PaymentRequestBrowserTestBase() {}
57 59
58 void PaymentRequestBrowserTestBase::SetUpCommandLine( 60 void PaymentRequestBrowserTestBase::SetUpCommandLine(
59 base::CommandLine* command_line) { 61 base::CommandLine* command_line) {
60 InProcessBrowserTest::SetUpCommandLine(command_line); 62 InProcessBrowserTest::SetUpCommandLine(command_line);
61 command_line->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures); 63 command_line->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures);
62 command_line->AppendSwitchASCII(switches::kEnableFeatures, 64 command_line->AppendSwitchASCII(switches::kEnableFeatures,
63 features::kWebPayments.name); 65 features::kWebPayments.name);
64 } 66 }
65 67
(...skipping 12 matching lines...) Expand all
78 // allowing the test to inject itself as a dialog observer. 80 // allowing the test to inject itself as a dialog observer.
79 content::WebContents* web_contents = GetActiveWebContents(); 81 content::WebContents* web_contents = GetActiveWebContents();
80 service_manager::InterfaceRegistry* registry = 82 service_manager::InterfaceRegistry* registry =
81 web_contents->GetMainFrame()->GetInterfaceRegistry(); 83 web_contents->GetMainFrame()->GetInterfaceRegistry();
82 registry->RemoveInterface(payments::mojom::PaymentRequest::Name_); 84 registry->RemoveInterface(payments::mojom::PaymentRequest::Name_);
83 registry->AddInterface( 85 registry->AddInterface(
84 base::Bind(&PaymentRequestBrowserTestBase::CreatePaymentRequestForTest, 86 base::Bind(&PaymentRequestBrowserTestBase::CreatePaymentRequestForTest,
85 base::Unretained(this), web_contents)); 87 base::Unretained(this), web_contents));
86 } 88 }
87 89
90 void PaymentRequestBrowserTestBase::SetIncognitoForTesting() {
91 incognito_for_testing_ = true;
92 }
93
88 void PaymentRequestBrowserTestBase::OnDialogOpened() { 94 void PaymentRequestBrowserTestBase::OnDialogOpened() {
89 if (event_observer_) 95 if (event_observer_)
90 event_observer_->Observe(DialogEvent::DIALOG_OPENED); 96 event_observer_->Observe(DialogEvent::DIALOG_OPENED);
91 } 97 }
92 98
93 void PaymentRequestBrowserTestBase::OnOrderSummaryOpened() { 99 void PaymentRequestBrowserTestBase::OnOrderSummaryOpened() {
94 if (event_observer_) 100 if (event_observer_)
95 event_observer_->Observe(DialogEvent::ORDER_SUMMARY_OPENED); 101 event_observer_->Observe(DialogEvent::ORDER_SUMMARY_OPENED);
96 } 102 }
97 103
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 personal_data_manager->RemoveObserver(&personal_data_observer); 260 personal_data_manager->RemoveObserver(&personal_data_observer);
255 EXPECT_EQ(card_count + 1, personal_data_manager->GetCreditCards().size()); 261 EXPECT_EQ(card_count + 1, personal_data_manager->GetCreditCards().size());
256 } 262 }
257 263
258 void PaymentRequestBrowserTestBase::CreatePaymentRequestForTest( 264 void PaymentRequestBrowserTestBase::CreatePaymentRequestForTest(
259 content::WebContents* web_contents, 265 content::WebContents* web_contents,
260 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request) { 266 mojo::InterfaceRequest<payments::mojom::PaymentRequest> request) {
261 DCHECK(web_contents); 267 DCHECK(web_contents);
262 std::unique_ptr<TestChromePaymentRequestDelegate> delegate = 268 std::unique_ptr<TestChromePaymentRequestDelegate> delegate =
263 base::MakeUnique<TestChromePaymentRequestDelegate>( 269 base::MakeUnique<TestChromePaymentRequestDelegate>(
264 web_contents, this /* observer */, this /* widget_observer */); 270 web_contents, this /* observer */, this /* widget_observer */,
271 incognito_for_testing_);
265 delegate_ = delegate.get(); 272 delegate_ = delegate.get();
266 PaymentRequestWebContentsManager::GetOrCreateForWebContents(web_contents) 273 PaymentRequestWebContentsManager::GetOrCreateForWebContents(web_contents)
267 ->CreatePaymentRequest(web_contents, std::move(delegate), 274 ->CreatePaymentRequest(web_contents, std::move(delegate),
268 std::move(request)); 275 std::move(request));
269 } 276 }
270 277
271 void PaymentRequestBrowserTestBase::ClickOnDialogViewAndWait( 278 void PaymentRequestBrowserTestBase::ClickOnDialogViewAndWait(
272 DialogViewID view_id) { 279 DialogViewID view_id) {
273 views::View* view = 280 views::View* view =
274 delegate_->dialog_view()->GetViewByID(static_cast<int>(view_id)); 281 delegate_->dialog_view()->GetViewByID(static_cast<int>(view_id));
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 404
398 void PaymentRequestBrowserTestBase::ResetEventObserver(DialogEvent event) { 405 void PaymentRequestBrowserTestBase::ResetEventObserver(DialogEvent event) {
399 event_observer_ = base::MakeUnique<DialogEventObserver>(event); 406 event_observer_ = base::MakeUnique<DialogEventObserver>(event);
400 } 407 }
401 408
402 void PaymentRequestBrowserTestBase::WaitForObservedEvent() { 409 void PaymentRequestBrowserTestBase::WaitForObservedEvent() {
403 event_observer_->Wait(); 410 event_observer_->Wait();
404 } 411 }
405 412
406 } // namespace payments 413 } // namespace payments
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698