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

Side by Side Diff: ios/web/public/test/fakes/test_web_state_delegate.mm

Issue 2737943003: Moved window opening callback to WebStateDelegate. (Closed)
Patch Set: Rebased 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 #import "ios/web/public/test/fakes/test_web_state_delegate.h" 5 #import "ios/web/public/test/fakes/test_web_state_delegate.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #import "ios/web/web_state/web_state_impl.h"
8 9
9 namespace web { 10 namespace web {
10 11
11 TestOpenURLRequest::TestOpenURLRequest() 12 TestOpenURLRequest::TestOpenURLRequest()
12 : params(GURL(), 13 : params(GURL(),
13 Referrer(), 14 Referrer(),
14 WindowOpenDisposition::UNKNOWN, 15 WindowOpenDisposition::UNKNOWN,
15 ui::PAGE_TRANSITION_LINK, 16 ui::PAGE_TRANSITION_LINK,
16 false) {} 17 false) {}
17 18
(...skipping 12 matching lines...) Expand all
30 31
31 TestAuthenticationRequest::~TestAuthenticationRequest() = default; 32 TestAuthenticationRequest::~TestAuthenticationRequest() = default;
32 33
33 TestAuthenticationRequest::TestAuthenticationRequest( 34 TestAuthenticationRequest::TestAuthenticationRequest(
34 const TestAuthenticationRequest&) = default; 35 const TestAuthenticationRequest&) = default;
35 36
36 TestWebStateDelegate::TestWebStateDelegate() {} 37 TestWebStateDelegate::TestWebStateDelegate() {}
37 38
38 TestWebStateDelegate::~TestWebStateDelegate() = default; 39 TestWebStateDelegate::~TestWebStateDelegate() = default;
39 40
41 WebState* TestWebStateDelegate::CreateNewWebState(WebState* source,
42 const GURL& url,
43 const GURL& opener_url,
44 bool initiated_by_user) {
45 last_create_new_web_state_request_ =
46 base::MakeUnique<TestCreateNewWebStateRequest>();
47 last_create_new_web_state_request_->web_state = source;
48 last_create_new_web_state_request_->url = url;
49 last_create_new_web_state_request_->opener_url = opener_url;
50 last_create_new_web_state_request_->initiated_by_user = initiated_by_user;
51
52 if (!initiated_by_user &&
53 allowed_popups_.find(opener_url) == allowed_popups_.end()) {
54 popups_.push_back(TestPopup(url, opener_url));
55 return nullptr;
56 }
57
58 std::unique_ptr<WebStateImpl> child(
59 base::MakeUnique<WebStateImpl>(source->GetBrowserState()));
60 child->GetNavigationManagerImpl().InitializeSession(YES /*opened_by_dom*/);
61 child->SetWebUsageEnabled(true);
62
63 child_windows_.push_back(std::move(child));
64 return child_windows_.back().get();
65 }
66
40 WebState* TestWebStateDelegate::OpenURLFromWebState( 67 WebState* TestWebStateDelegate::OpenURLFromWebState(
41 WebState* web_state, 68 WebState* web_state,
42 const WebState::OpenURLParams& params) { 69 const WebState::OpenURLParams& params) {
43 last_open_url_request_ = base::MakeUnique<TestOpenURLRequest>(); 70 last_open_url_request_ = base::MakeUnique<TestOpenURLRequest>();
44 last_open_url_request_->web_state = web_state; 71 last_open_url_request_->web_state = web_state;
45 last_open_url_request_->params = params; 72 last_open_url_request_->params = params;
46 return nullptr; 73 return nullptr;
47 } 74 }
48 75
49 JavaScriptDialogPresenter* TestWebStateDelegate::GetJavaScriptDialogPresenter( 76 JavaScriptDialogPresenter* TestWebStateDelegate::GetJavaScriptDialogPresenter(
(...skipping 28 matching lines...) Expand all
78 const AuthCallback& callback) { 105 const AuthCallback& callback) {
79 last_authentication_request_ = base::MakeUnique<TestAuthenticationRequest>(); 106 last_authentication_request_ = base::MakeUnique<TestAuthenticationRequest>();
80 last_authentication_request_->web_state = source; 107 last_authentication_request_->web_state = source;
81 last_authentication_request_->protection_space.reset( 108 last_authentication_request_->protection_space.reset(
82 [protection_space retain]); 109 [protection_space retain]);
83 last_authentication_request_->credential.reset([credential retain]); 110 last_authentication_request_->credential.reset([credential retain]);
84 last_authentication_request_->auth_callback = callback; 111 last_authentication_request_->auth_callback = callback;
85 } 112 }
86 113
87 } // namespace web 114 } // namespace web
OLDNEW
« no previous file with comments | « ios/web/public/test/fakes/test_web_state_delegate.h ('k') | ios/web/public/web_state/ui/crw_web_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698