| 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" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 14 #import "ios/web/interstitials/web_interstitial_impl.h" | 14 #import "ios/web/interstitials/web_interstitial_impl.h" |
| 15 #import "ios/web/navigation/crw_session_controller.h" | 15 #import "ios/web/navigation/crw_session_controller.h" |
| 16 #import "ios/web/navigation/crw_session_entry.h" | 16 #import "ios/web/navigation/crw_session_entry.h" |
| 17 #import "ios/web/navigation/navigation_item_impl.h" | 17 #import "ios/web/navigation/navigation_item_impl.h" |
| 18 #import "ios/web/net/request_group_util.h" | |
| 19 #include "ios/web/public/browser_state.h" | 18 #include "ios/web/public/browser_state.h" |
| 20 #import "ios/web/public/image_fetcher/image_data_fetcher.h" | 19 #import "ios/web/public/image_fetcher/image_data_fetcher.h" |
| 21 #import "ios/web/public/java_script_dialog_presenter.h" | 20 #import "ios/web/public/java_script_dialog_presenter.h" |
| 22 #import "ios/web/public/navigation_item.h" | 21 #import "ios/web/public/navigation_item.h" |
| 23 #include "ios/web/public/url_util.h" | 22 #include "ios/web/public/url_util.h" |
| 24 #import "ios/web/public/web_client.h" | 23 #import "ios/web/public/web_client.h" |
| 25 #import "ios/web/public/web_state/context_menu_params.h" | 24 #import "ios/web/public/web_state/context_menu_params.h" |
| 26 #include "ios/web/public/web_state/credential.h" | 25 #include "ios/web/public/web_state/credential.h" |
| 27 #import "ios/web/public/web_state/ui/crw_content_view.h" | 26 #import "ios/web/public/web_state/ui/crw_content_view.h" |
| 28 #import "ios/web/public/web_state/web_state_delegate.h" | 27 #import "ios/web/public/web_state/web_state_delegate.h" |
| 29 #include "ios/web/public/web_state/web_state_observer.h" | 28 #include "ios/web/public/web_state/web_state_observer.h" |
| 30 #import "ios/web/public/web_state/web_state_policy_decider.h" | 29 #import "ios/web/public/web_state/web_state_policy_decider.h" |
| 30 #include "ios/web/public/web_thread.h" |
| 31 #include "ios/web/public/webui/web_ui_ios_controller.h" | 31 #include "ios/web/public/webui/web_ui_ios_controller.h" |
| 32 #include "ios/web/web_state/global_web_state_event_tracker.h" | 32 #include "ios/web/web_state/global_web_state_event_tracker.h" |
| 33 #import "ios/web/web_state/ui/crw_web_controller.h" | 33 #import "ios/web/web_state/ui/crw_web_controller.h" |
| 34 #import "ios/web/web_state/ui/crw_web_controller_container_view.h" | 34 #import "ios/web/web_state/ui/crw_web_controller_container_view.h" |
| 35 #include "ios/web/web_state/web_state_facade_delegate.h" | 35 #include "ios/web/web_state/web_state_facade_delegate.h" |
| 36 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h" | 36 #include "ios/web/webui/web_ui_ios_controller_factory_registry.h" |
| 37 #include "ios/web/webui/web_ui_ios_impl.h" | 37 #include "ios/web/webui/web_ui_ios_impl.h" |
| 38 #include "net/http/http_response_headers.h" | 38 #include "net/http/http_response_headers.h" |
| 39 #include "net/url_request/url_fetcher.h" | 39 #include "net/url_request/url_fetcher.h" |
| 40 #include "net/url_request/url_request_context_getter.h" |
| 40 #include "services/service_manager/public/cpp/interface_registry.h" | 41 #include "services/service_manager/public/cpp/interface_registry.h" |
| 41 #include "skia/ext/skia_utils_ios.h" | 42 #include "skia/ext/skia_utils_ios.h" |
| 42 #include "third_party/skia/include/core/SkBitmap.h" | 43 #include "third_party/skia/include/core/SkBitmap.h" |
| 43 | 44 |
| 44 namespace web { | 45 namespace web { |
| 45 | 46 |
| 46 /* static */ | 47 /* static */ |
| 47 std::unique_ptr<WebState> WebState::Create(const CreateParams& params) { | 48 std::unique_ptr<WebState> WebState::Create(const CreateParams& params) { |
| 48 std::unique_ptr<WebStateImpl> web_state( | 49 std::unique_ptr<WebStateImpl> web_state( |
| 49 new WebStateImpl(params.browser_state)); | 50 new WebStateImpl(params.browser_state)); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 92 |
| 92 for (auto& observer : observers_) | 93 for (auto& observer : observers_) |
| 93 observer.WebStateDestroyed(); | 94 observer.WebStateDestroyed(); |
| 94 for (auto& observer : observers_) | 95 for (auto& observer : observers_) |
| 95 observer.ResetWebState(); | 96 observer.ResetWebState(); |
| 96 for (auto& observer : policy_deciders_) | 97 for (auto& observer : policy_deciders_) |
| 97 observer.WebStateDestroyed(); | 98 observer.WebStateDestroyed(); |
| 98 for (auto& observer : policy_deciders_) | 99 for (auto& observer : policy_deciders_) |
| 99 observer.ResetWebState(); | 100 observer.ResetWebState(); |
| 100 DCHECK(script_command_callbacks_.empty()); | 101 DCHECK(script_command_callbacks_.empty()); |
| 101 if (request_tracker_.get()) | |
| 102 CloseRequestTracker(); | |
| 103 SetDelegate(nullptr); | 102 SetDelegate(nullptr); |
| 104 } | 103 } |
| 105 | 104 |
| 106 WebStateDelegate* WebStateImpl::GetDelegate() { | 105 WebStateDelegate* WebStateImpl::GetDelegate() { |
| 107 return delegate_; | 106 return delegate_; |
| 108 } | 107 } |
| 109 | 108 |
| 110 void WebStateImpl::SetDelegate(WebStateDelegate* delegate) { | 109 void WebStateImpl::SetDelegate(WebStateDelegate* delegate) { |
| 111 if (delegate == delegate_) | 110 if (delegate == delegate_) |
| 112 return; | 111 return; |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 bool WebStateImpl::ShouldAllowResponse(NSURLResponse* response) { | 521 bool WebStateImpl::ShouldAllowResponse(NSURLResponse* response) { |
| 523 for (auto& policy_decider : policy_deciders_) { | 522 for (auto& policy_decider : policy_deciders_) { |
| 524 if (!policy_decider.ShouldAllowResponse(response)) | 523 if (!policy_decider.ShouldAllowResponse(response)) |
| 525 return false; | 524 return false; |
| 526 } | 525 } |
| 527 return true; | 526 return true; |
| 528 } | 527 } |
| 529 | 528 |
| 530 #pragma mark - RequestTracker management | 529 #pragma mark - RequestTracker management |
| 531 | 530 |
| 532 void WebStateImpl::InitializeRequestTracker( | |
| 533 id<CRWRequestTrackerDelegate> delegate) { | |
| 534 BrowserState* browser_state = navigation_manager_.GetBrowserState(); | |
| 535 request_tracker_ = RequestTrackerImpl::CreateTrackerForRequestGroupID( | |
| 536 GetRequestGroupID(), browser_state, browser_state->GetRequestContext(), | |
| 537 delegate); | |
| 538 } | |
| 539 | |
| 540 void WebStateImpl::CloseRequestTracker() { | |
| 541 request_tracker_->Close(); | |
| 542 request_tracker_ = NULL; | |
| 543 } | |
| 544 | |
| 545 RequestTrackerImpl* WebStateImpl::GetRequestTracker() { | |
| 546 DCHECK(request_tracker_.get()); | |
| 547 return request_tracker_.get(); | |
| 548 } | |
| 549 | |
| 550 NSString* WebStateImpl::GetRequestGroupID() { | |
| 551 if (request_group_id_.get() == nil) | |
| 552 request_group_id_.reset([GenerateNewRequestGroupID() copy]); | |
| 553 | |
| 554 return request_group_id_; | |
| 555 } | |
| 556 | |
| 557 int WebStateImpl::DownloadImage( | 531 int WebStateImpl::DownloadImage( |
| 558 const GURL& url, | 532 const GURL& url, |
| 559 bool is_favicon, | 533 bool is_favicon, |
| 560 uint32_t max_bitmap_size, | 534 uint32_t max_bitmap_size, |
| 561 bool bypass_cache, | 535 bool bypass_cache, |
| 562 const ImageDownloadCallback& callback) { | 536 const ImageDownloadCallback& callback) { |
| 563 // |is_favicon| specifies whether the download of the image occurs with | 537 // |is_favicon| specifies whether the download of the image occurs with |
| 564 // cookies or not. Currently, only downloads without cookies are supported. | 538 // cookies or not. Currently, only downloads without cookies are supported. |
| 565 // |bypass_cache| is ignored since the downloads never go through a cache. | 539 // |bypass_cache| is ignored since the downloads never go through a cache. |
| 566 DCHECK(is_favicon); | 540 DCHECK(is_favicon); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 const LoadCommittedDetails& load_details) { | 725 const LoadCommittedDetails& load_details) { |
| 752 for (auto& observer : observers_) | 726 for (auto& observer : observers_) |
| 753 observer.NavigationItemCommitted(load_details); | 727 observer.NavigationItemCommitted(load_details); |
| 754 } | 728 } |
| 755 | 729 |
| 756 WebState* WebStateImpl::GetWebState() { | 730 WebState* WebStateImpl::GetWebState() { |
| 757 return this; | 731 return this; |
| 758 } | 732 } |
| 759 | 733 |
| 760 } // namespace web | 734 } // namespace web |
| OLD | NEW |