| 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/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/metrics/histogram_macros.h" | 13 #include "base/metrics/histogram_macros.h" |
| 14 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
| 15 #include "base/threading/sequenced_task_runner_handle.h" | 15 #include "base/threading/sequenced_task_runner_handle.h" |
| 16 #import "ios/web/interstitials/web_interstitial_impl.h" | 16 #import "ios/web/interstitials/web_interstitial_impl.h" |
| 17 #import "ios/web/navigation/crw_session_controller.h" | 17 #import "ios/web/navigation/crw_session_controller.h" |
| 18 #import "ios/web/navigation/legacy_navigation_manager_impl.h" | 18 #import "ios/web/navigation/legacy_navigation_manager_impl.h" |
| 19 #import "ios/web/navigation/navigation_item_impl.h" | 19 #import "ios/web/navigation/navigation_item_impl.h" |
| 20 #import "ios/web/navigation/session_storage_builder.h" | 20 #import "ios/web/navigation/session_storage_builder.h" |
| 21 #import "ios/web/navigation/wk_based_navigation_manager_impl.h" |
| 21 #include "ios/web/public/browser_state.h" | 22 #include "ios/web/public/browser_state.h" |
| 22 #import "ios/web/public/crw_session_storage.h" | 23 #import "ios/web/public/crw_session_storage.h" |
| 23 #import "ios/web/public/java_script_dialog_presenter.h" | 24 #import "ios/web/public/java_script_dialog_presenter.h" |
| 24 #import "ios/web/public/navigation_item.h" | 25 #import "ios/web/public/navigation_item.h" |
| 25 #include "ios/web/public/url_util.h" | 26 #include "ios/web/public/url_util.h" |
| 26 #import "ios/web/public/web_client.h" | 27 #import "ios/web/public/web_client.h" |
| 27 #import "ios/web/public/web_state/context_menu_params.h" | 28 #import "ios/web/public/web_state/context_menu_params.h" |
| 28 #import "ios/web/public/web_state/ui/crw_content_view.h" | 29 #import "ios/web/public/web_state/ui/crw_content_view.h" |
| 29 #import "ios/web/public/web_state/web_state_delegate.h" | 30 #import "ios/web/public/web_state/web_state_delegate.h" |
| 30 #include "ios/web/public/web_state/web_state_interface_provider.h" | 31 #include "ios/web/public/web_state/web_state_interface_provider.h" |
| 31 #include "ios/web/public/web_state/web_state_observer.h" | 32 #include "ios/web/public/web_state/web_state_observer.h" |
| 32 #import "ios/web/public/web_state/web_state_policy_decider.h" | 33 #import "ios/web/public/web_state/web_state_policy_decider.h" |
| 33 #include "ios/web/public/web_thread.h" | 34 #include "ios/web/public/web_thread.h" |
| 34 #include "ios/web/public/webui/web_ui_ios_controller.h" | 35 #include "ios/web/public/webui/web_ui_ios_controller.h" |
| 35 #include "ios/web/web_state/global_web_state_event_tracker.h" | 36 #include "ios/web/web_state/global_web_state_event_tracker.h" |
| 36 #import "ios/web/web_state/navigation_context_impl.h" | 37 #import "ios/web/web_state/navigation_context_impl.h" |
| 37 #import "ios/web/web_state/session_certificate_policy_cache_impl.h" | 38 #import "ios/web/web_state/session_certificate_policy_cache_impl.h" |
| 38 #import "ios/web/web_state/ui/crw_web_controller.h" | 39 #import "ios/web/web_state/ui/crw_web_controller.h" |
| 39 #import "ios/web/web_state/ui/crw_web_controller_container_view.h" | 40 #import "ios/web/web_state/ui/crw_web_controller_container_view.h" |
| 41 #import "ios/web/web_state/ui/crw_web_view_navigation_proxy.h" |
| 40 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h" | 42 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h" |
| 41 #include "ios/web/webui/web_ui_ios_impl.h" | 43 #include "ios/web/webui/web_ui_ios_impl.h" |
| 42 #include "net/http/http_response_headers.h" | 44 #include "net/http/http_response_headers.h" |
| 43 #include "ui/gfx/image/image.h" | 45 #include "ui/gfx/image/image.h" |
| 44 | 46 |
| 45 namespace web { | 47 namespace web { |
| 46 | 48 |
| 47 /* static */ | 49 /* static */ |
| 48 std::unique_ptr<WebState> WebState::Create(const CreateParams& params) { | 50 std::unique_ptr<WebState> WebState::Create(const CreateParams& params) { |
| 49 std::unique_ptr<WebStateImpl> web_state(new WebStateImpl(params)); | 51 std::unique_ptr<WebStateImpl> web_state(new WebStateImpl(params)); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 73 WebStateImpl::WebStateImpl(const CreateParams& params, | 75 WebStateImpl::WebStateImpl(const CreateParams& params, |
| 74 CRWSessionStorage* session_storage) | 76 CRWSessionStorage* session_storage) |
| 75 : delegate_(nullptr), | 77 : delegate_(nullptr), |
| 76 is_loading_(false), | 78 is_loading_(false), |
| 77 is_being_destroyed_(false), | 79 is_being_destroyed_(false), |
| 78 web_controller_(nil), | 80 web_controller_(nil), |
| 79 interstitial_(nullptr), | 81 interstitial_(nullptr), |
| 80 created_with_opener_(params.created_with_opener), | 82 created_with_opener_(params.created_with_opener), |
| 81 weak_factory_(this) { | 83 weak_factory_(this) { |
| 82 // Create or deserialize the NavigationManager. | 84 // Create or deserialize the NavigationManager. |
| 85 if (web::GetWebClient()->IsSlimNavigationManagerEnabled()) { |
| 86 navigation_manager_ = base::MakeUnique<WKBasedNavigationManagerImpl>(); |
| 87 } else { |
| 88 navigation_manager_ = base::MakeUnique<LegacyNavigationManagerImpl>(); |
| 89 } |
| 90 |
| 83 if (session_storage) { | 91 if (session_storage) { |
| 84 SessionStorageBuilder session_storage_builder; | 92 SessionStorageBuilder session_storage_builder; |
| 85 session_storage_builder.ExtractSessionState(this, session_storage); | 93 session_storage_builder.ExtractSessionState(this, session_storage); |
| 86 } else { | 94 } else { |
| 87 navigation_manager_ = base::WrapUnique<NavigationManagerImpl>( | |
| 88 new LegacyNavigationManagerImpl); | |
| 89 certificate_policy_cache_ = | 95 certificate_policy_cache_ = |
| 90 base::MakeUnique<SessionCertificatePolicyCacheImpl>(); | 96 base::MakeUnique<SessionCertificatePolicyCacheImpl>(); |
| 91 } | 97 } |
| 92 navigation_manager_->SetDelegate(this); | 98 navigation_manager_->SetDelegate(this); |
| 93 navigation_manager_->SetBrowserState(params.browser_state); | 99 navigation_manager_->SetBrowserState(params.browser_state); |
| 94 // Send creation event and create the web controller. | 100 // Send creation event and create the web controller. |
| 95 GlobalWebStateEventTracker::GetInstance()->OnWebStateCreated(this); | 101 GlobalWebStateEventTracker::GetInstance()->OnWebStateCreated(this); |
| 96 web_controller_.reset([[CRWWebController alloc] initWithWebState:this]); | 102 web_controller_.reset([[CRWWebController alloc] initWithWebState:this]); |
| 97 } | 103 } |
| 98 | 104 |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 void WebStateImpl::OnNavigationItemCommitted( | 736 void WebStateImpl::OnNavigationItemCommitted( |
| 731 const LoadCommittedDetails& load_details) { | 737 const LoadCommittedDetails& load_details) { |
| 732 for (auto& observer : observers_) | 738 for (auto& observer : observers_) |
| 733 observer.NavigationItemCommitted(load_details); | 739 observer.NavigationItemCommitted(load_details); |
| 734 } | 740 } |
| 735 | 741 |
| 736 WebState* WebStateImpl::GetWebState() { | 742 WebState* WebStateImpl::GetWebState() { |
| 737 return this; | 743 return this; |
| 738 } | 744 } |
| 739 | 745 |
| 746 id<CRWWebViewNavigationProxy> WebStateImpl::GetWebViewNavigationProxy() const { |
| 747 return [web_controller_ webViewNavigationProxy]; |
| 748 } |
| 749 |
| 740 } // namespace web | 750 } // namespace web |
| OLD | NEW |