Chromium Code Reviews| 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/web_view_navigation_proxy.h" | |
| 42 #import "ios/web/web_state/ui/web_view_navigation_proxy_impl.h" | |
| 40 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h" | 43 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h" |
| 41 #include "ios/web/webui/web_ui_ios_impl.h" | 44 #include "ios/web/webui/web_ui_ios_impl.h" |
| 42 #include "net/http/http_response_headers.h" | 45 #include "net/http/http_response_headers.h" |
| 43 #include "ui/gfx/image/image.h" | 46 #include "ui/gfx/image/image.h" |
| 44 | 47 |
| 45 namespace web { | 48 namespace web { |
| 46 | 49 |
| 47 /* static */ | 50 /* static */ |
| 48 std::unique_ptr<WebState> WebState::Create(const CreateParams& params) { | 51 std::unique_ptr<WebState> WebState::Create(const CreateParams& params) { |
| 49 std::unique_ptr<WebStateImpl> web_state(new WebStateImpl(params)); | 52 std::unique_ptr<WebStateImpl> web_state(new WebStateImpl(params)); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 78 web_controller_(nil), | 81 web_controller_(nil), |
| 79 interstitial_(nullptr), | 82 interstitial_(nullptr), |
| 80 created_with_opener_(params.created_with_opener), | 83 created_with_opener_(params.created_with_opener), |
| 81 weak_factory_(this) { | 84 weak_factory_(this) { |
| 82 // Create or deserialize the NavigationManager. | 85 // Create or deserialize the NavigationManager. |
| 83 if (session_storage) { | 86 if (session_storage) { |
| 84 SessionStorageBuilder session_storage_builder; | 87 SessionStorageBuilder session_storage_builder; |
| 85 session_storage_builder.ExtractSessionState(this, session_storage); | 88 session_storage_builder.ExtractSessionState(this, session_storage); |
| 86 } else { | 89 } else { |
| 87 navigation_manager_ = base::WrapUnique<NavigationManagerImpl>( | 90 navigation_manager_ = base::WrapUnique<NavigationManagerImpl>( |
| 88 new LegacyNavigationManagerImpl); | 91 web::GetWebClient()->IsSlimNavigationManagerEnabled() |
| 92 ? (NavigationManagerImpl*)(new WKBasedNavigationManagerImpl) | |
|
Eugene But (OOO till 7-30)
2017/06/29 01:48:19
Please use C++ casting. But do you even need to ca
danyao
2017/06/29 16:05:26
The cast is needed because I want to use the ? : s
| |
| 93 : (NavigationManagerImpl*)(new LegacyNavigationManagerImpl)); | |
| 89 certificate_policy_cache_ = | 94 certificate_policy_cache_ = |
| 90 base::MakeUnique<SessionCertificatePolicyCacheImpl>(); | 95 base::MakeUnique<SessionCertificatePolicyCacheImpl>(); |
| 91 } | 96 } |
| 92 navigation_manager_->SetDelegate(this); | 97 navigation_manager_->SetDelegate(this); |
| 93 navigation_manager_->SetBrowserState(params.browser_state); | 98 navigation_manager_->SetBrowserState(params.browser_state); |
| 94 // Send creation event and create the web controller. | 99 // Send creation event and create the web controller. |
| 95 GlobalWebStateEventTracker::GetInstance()->OnWebStateCreated(this); | 100 GlobalWebStateEventTracker::GetInstance()->OnWebStateCreated(this); |
| 96 web_controller_.reset([[CRWWebController alloc] initWithWebState:this]); | 101 web_controller_.reset([[CRWWebController alloc] initWithWebState:this]); |
| 97 } | 102 } |
| 98 | 103 |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 730 void WebStateImpl::OnNavigationItemCommitted( | 735 void WebStateImpl::OnNavigationItemCommitted( |
| 731 const LoadCommittedDetails& load_details) { | 736 const LoadCommittedDetails& load_details) { |
| 732 for (auto& observer : observers_) | 737 for (auto& observer : observers_) |
| 733 observer.NavigationItemCommitted(load_details); | 738 observer.NavigationItemCommitted(load_details); |
| 734 } | 739 } |
| 735 | 740 |
| 736 WebState* WebStateImpl::GetWebState() { | 741 WebState* WebStateImpl::GetWebState() { |
| 737 return this; | 742 return this; |
| 738 } | 743 } |
| 739 | 744 |
| 745 WebViewNavigationProxy* WebStateImpl::GetWebViewNavigationProxy() const { | |
| 746 return [web_controller_ webViewNavigationProxy]; | |
| 747 } | |
| 748 | |
| 740 } // namespace web | 749 } // namespace web |
| OLD | NEW |