OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/web_state/web_state_impl.h" | 5 #import "ios/web/web_state/web_state_impl.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "ios/web/web_state/web_state_facade_delegate.h" | 36 #include "ios/web/web_state/web_state_facade_delegate.h" |
37 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h" | 37 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h" |
38 #include "ios/web/webui/web_ui_ios_impl.h" | 38 #include "ios/web/webui/web_ui_ios_impl.h" |
39 #include "net/http/http_response_headers.h" | 39 #include "net/http/http_response_headers.h" |
40 #include "services/service_manager/public/cpp/interface_registry.h" | 40 #include "services/service_manager/public/cpp/interface_registry.h" |
41 | 41 |
42 namespace web { | 42 namespace web { |
43 | 43 |
44 /* static */ | 44 /* static */ |
45 std::unique_ptr<WebState> WebState::Create(const CreateParams& params) { | 45 std::unique_ptr<WebState> WebState::Create(const CreateParams& params) { |
46 std::unique_ptr<WebStateImpl> web_state( | 46 std::unique_ptr<WebStateImpl> web_state(new WebStateImpl(params)); |
47 new WebStateImpl(params.browser_state)); | |
48 | 47 |
49 // Initialize the new session. | 48 // Initialize the new session. |
50 BOOL opened_by_dom = NO; | 49 web_state->GetNavigationManagerImpl().InitializeSession(); |
51 web_state->GetNavigationManagerImpl().InitializeSession(opened_by_dom); | |
52 | 50 |
53 // This std::move is required to compile with the version of clang shipping | 51 // This std::move is required to compile with the version of clang shipping |
54 // with Xcode 8.0+. Evalute whether the issue is fixed once a new version of | 52 // with Xcode 8.0+. Evalute whether the issue is fixed once a new version of |
55 // Xcode is released. | 53 // Xcode is released. |
56 return std::move(web_state); | 54 return std::move(web_state); |
57 } | 55 } |
58 | 56 |
59 /* static */ | 57 /* static */ |
60 std::unique_ptr<WebState> WebState::Create(const CreateParams& params, | 58 std::unique_ptr<WebState> WebState::Create(const CreateParams& params, |
61 CRWSessionStorage* session_storage) { | 59 CRWSessionStorage* session_storage) { |
62 std::unique_ptr<WebStateImpl> web_state( | 60 std::unique_ptr<WebStateImpl> web_state( |
63 new WebStateImpl(params.browser_state, session_storage)); | 61 new WebStateImpl(params, session_storage)); |
64 | 62 |
65 // This std::move is required to compile with the version of clang shipping | 63 // This std::move is required to compile with the version of clang shipping |
66 // with Xcode 8.0+. Evalute whether the issue is fixed once a new version of | 64 // with Xcode 8.0+. Evalute whether the issue is fixed once a new version of |
67 // Xcode is released. | 65 // Xcode is released. |
68 return std::move(web_state); | 66 return std::move(web_state); |
69 } | 67 } |
70 | 68 |
71 WebStateImpl::WebStateImpl(BrowserState* browser_state) | 69 WebStateImpl::WebStateImpl(const CreateParams& params) |
72 : WebStateImpl(browser_state, nullptr) {} | 70 : WebStateImpl(params, nullptr) {} |
73 | 71 |
74 WebStateImpl::WebStateImpl(BrowserState* browser_state, | 72 WebStateImpl::WebStateImpl(const CreateParams& params, |
75 CRWSessionStorage* session_storage) | 73 CRWSessionStorage* session_storage) |
76 : delegate_(nullptr), | 74 : delegate_(nullptr), |
77 is_loading_(false), | 75 is_loading_(false), |
78 is_being_destroyed_(false), | 76 is_being_destroyed_(false), |
79 facade_delegate_(nullptr), | 77 facade_delegate_(nullptr), |
80 web_controller_(nil), | 78 web_controller_(nil), |
81 interstitial_(nullptr), | 79 interstitial_(nullptr), |
| 80 created_with_opener_(params.created_with_opener), |
82 weak_factory_(this) { | 81 weak_factory_(this) { |
83 // Create or deserialize the NavigationManager. | 82 // Create or deserialize the NavigationManager. |
84 if (session_storage) { | 83 if (session_storage) { |
85 SessionStorageBuilder session_storage_builder; | 84 SessionStorageBuilder session_storage_builder; |
86 session_storage_builder.ExtractSessionState(this, session_storage); | 85 session_storage_builder.ExtractSessionState(this, session_storage); |
87 } else { | 86 } else { |
88 navigation_manager_.reset(new NavigationManagerImpl()); | 87 navigation_manager_.reset(new NavigationManagerImpl()); |
89 } | 88 } |
90 navigation_manager_->SetDelegate(this); | 89 navigation_manager_->SetDelegate(this); |
91 navigation_manager_->SetBrowserState(browser_state); | 90 navigation_manager_->SetBrowserState(params.browser_state); |
92 // Send creation event and create the web controller. | 91 // Send creation event and create the web controller. |
93 GlobalWebStateEventTracker::GetInstance()->OnWebStateCreated(this); | 92 GlobalWebStateEventTracker::GetInstance()->OnWebStateCreated(this); |
94 web_controller_.reset([[CRWWebController alloc] initWithWebState:this]); | 93 web_controller_.reset([[CRWWebController alloc] initWithWebState:this]); |
95 } | 94 } |
96 | 95 |
97 WebStateImpl::~WebStateImpl() { | 96 WebStateImpl::~WebStateImpl() { |
98 [web_controller_ close]; | 97 [web_controller_ close]; |
99 is_being_destroyed_ = true; | 98 is_being_destroyed_ = true; |
100 | 99 |
101 // WebUI depends on web state so it must be destroyed first in case any WebUI | 100 // WebUI depends on web state so it must be destroyed first in case any WebUI |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 const std::string& command_prefix) { | 719 const std::string& command_prefix) { |
721 DCHECK(script_command_callbacks_.find(command_prefix) != | 720 DCHECK(script_command_callbacks_.find(command_prefix) != |
722 script_command_callbacks_.end()); | 721 script_command_callbacks_.end()); |
723 script_command_callbacks_.erase(command_prefix); | 722 script_command_callbacks_.erase(command_prefix); |
724 } | 723 } |
725 | 724 |
726 id<CRWWebViewProxy> WebStateImpl::GetWebViewProxy() const { | 725 id<CRWWebViewProxy> WebStateImpl::GetWebViewProxy() const { |
727 return [web_controller_ webViewProxy]; | 726 return [web_controller_ webViewProxy]; |
728 } | 727 } |
729 | 728 |
| 729 bool WebStateImpl::HasOpener() const { |
| 730 return created_with_opener_; |
| 731 } |
| 732 |
730 void WebStateImpl::OnProvisionalNavigationStarted(const GURL& url) { | 733 void WebStateImpl::OnProvisionalNavigationStarted(const GURL& url) { |
731 for (auto& observer : observers_) | 734 for (auto& observer : observers_) |
732 observer.ProvisionalNavigationStarted(url); | 735 observer.ProvisionalNavigationStarted(url); |
733 } | 736 } |
734 | 737 |
735 #pragma mark - NavigationManagerDelegate implementation | 738 #pragma mark - NavigationManagerDelegate implementation |
736 | 739 |
737 void WebStateImpl::GoToIndex(int index) { | 740 void WebStateImpl::GoToIndex(int index) { |
738 [web_controller_ goToItemAtIndex:index]; | 741 [web_controller_ goToItemAtIndex:index]; |
739 } | 742 } |
(...skipping 21 matching lines...) Expand all Loading... |
761 const LoadCommittedDetails& load_details) { | 764 const LoadCommittedDetails& load_details) { |
762 for (auto& observer : observers_) | 765 for (auto& observer : observers_) |
763 observer.NavigationItemCommitted(load_details); | 766 observer.NavigationItemCommitted(load_details); |
764 } | 767 } |
765 | 768 |
766 WebState* WebStateImpl::GetWebState() { | 769 WebState* WebStateImpl::GetWebState() { |
767 return this; | 770 return this; |
768 } | 771 } |
769 | 772 |
770 } // namespace web | 773 } // namespace web |
OLD | NEW |