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

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 1836793002: [ios] Moved WebLoadParams inside NavigationManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/ui/crw_web_controller.h" 5 #import "ios/web/web_state/ui/crw_web_controller.h"
6 6
7 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 #include "ios/web/web_state/web_state_facade_delegate.h" 83 #include "ios/web/web_state/web_state_facade_delegate.h"
84 #import "ios/web/web_state/web_state_impl.h" 84 #import "ios/web/web_state/web_state_impl.h"
85 #import "net/base/mac/url_conversions.h" 85 #import "net/base/mac/url_conversions.h"
86 #include "net/base/net_errors.h" 86 #include "net/base/net_errors.h"
87 #import "ui/base/ios/cru_context_menu_holder.h" 87 #import "ui/base/ios/cru_context_menu_holder.h"
88 #include "ui/base/page_transition_types.h" 88 #include "ui/base/page_transition_types.h"
89 #include "url/gurl.h" 89 #include "url/gurl.h"
90 #include "url/url_constants.h" 90 #include "url/url_constants.h"
91 91
92 using base::UserMetricsAction; 92 using base::UserMetricsAction;
93 using web::NavigationManager;
93 using web::NavigationManagerImpl; 94 using web::NavigationManagerImpl;
94 using web::WebState; 95 using web::WebState;
95 using web::WebStateImpl; 96 using web::WebStateImpl;
96 97
97 namespace web { 98 namespace web {
98 99
99 NSString* const kContainerViewID = @"Container View"; 100 NSString* const kContainerViewID = @"Container View";
100 const char* kWindowNameSeparator = "#"; 101 const char* kWindowNameSeparator = "#";
101 NSString* const kUserIsInteractingKey = @"userIsInteracting"; 102 NSString* const kUserIsInteractingKey = @"userIsInteracting";
102 NSString* const kOriginURLKey = @"originURL"; 103 NSString* const kOriginURLKey = @"originURL";
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 const web::Referrer referrer; 1377 const web::Referrer referrer;
1377 // Unlike the WebView case, always create a new controller and view. 1378 // Unlike the WebView case, always create a new controller and view.
1378 // TODO(pinkerton): What to do if this does return nil? 1379 // TODO(pinkerton): What to do if this does return nil?
1379 [self setNativeController:[_nativeProvider controllerForURL:targetURL]]; 1380 [self setNativeController:[_nativeProvider controllerForURL:targetURL]];
1380 [self registerLoadRequest:targetURL 1381 [self registerLoadRequest:targetURL
1381 referrer:referrer 1382 referrer:referrer
1382 transition:[self currentTransition]]; 1383 transition:[self currentTransition]];
1383 [self loadNativeViewWithSuccess:YES]; 1384 [self loadNativeViewWithSuccess:YES];
1384 } 1385 }
1385 1386
1386 - (void)loadWithParams:(const web::WebLoadParams&)originalParams { 1387 - (void)loadWithParams:(const NavigationManager::WebLoadParams&)originalParams {
1387 // Make a copy of |params|, as some of the delegate methods may modify it. 1388 // Make a copy of |params|, as some of the delegate methods may modify it.
1388 web::WebLoadParams params(originalParams); 1389 NavigationManager::WebLoadParams params(originalParams);
1389 1390
1390 // Initiating a navigation from the UI, record the current page state before 1391 // Initiating a navigation from the UI, record the current page state before
1391 // the new page loads. Don't record for back/forward, as the current entry 1392 // the new page loads. Don't record for back/forward, as the current entry
1392 // has already been moved to the next entry in the history. Do, however, 1393 // has already been moved to the next entry in the history. Do, however,
1393 // record it for general reload. 1394 // record it for general reload.
1394 // TODO(jimblackler): consider a single unified call to record state whenever 1395 // TODO(jimblackler): consider a single unified call to record state whenever
1395 // the page is about to be changed. This cannot currently be done after 1396 // the page is about to be changed. This cannot currently be done after
1396 // addPendingEntry is called. 1397 // addPendingEntry is called.
1397 1398
1398 [_delegate webWillInitiateLoadWithParams:params]; 1399 [_delegate webWillInitiateLoadWithParams:params];
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1565 // implementation. This will be inaccurate if the reload fails or is 1566 // implementation. This will be inaccurate if the reload fails or is
1566 // cancelled. 1567 // cancelled.
1567 _lastUserInteraction.reset(); 1568 _lastUserInteraction.reset();
1568 web::RecordAction(UserMetricsAction("Reload")); 1569 web::RecordAction(UserMetricsAction("Reload"));
1569 if (self.webView) { 1570 if (self.webView) {
1570 web::NavigationItem* transientItem = 1571 web::NavigationItem* transientItem =
1571 _webStateImpl->GetNavigationManagerImpl().GetTransientItem(); 1572 _webStateImpl->GetNavigationManagerImpl().GetTransientItem();
1572 if (transientItem) { 1573 if (transientItem) {
1573 // If there's a transient item, a reload is considered a new navigation to 1574 // If there's a transient item, a reload is considered a new navigation to
1574 // the transient item's URL (as on other platforms). 1575 // the transient item's URL (as on other platforms).
1575 web::WebLoadParams reloadParams(transientItem->GetURL()); 1576 NavigationManager::WebLoadParams reloadParams(transientItem->GetURL());
1576 reloadParams.transition_type = ui::PAGE_TRANSITION_RELOAD; 1577 reloadParams.transition_type = ui::PAGE_TRANSITION_RELOAD;
1577 reloadParams.extra_headers.reset( 1578 reloadParams.extra_headers.reset(
1578 [transientItem->GetHttpRequestHeaders() copy]); 1579 [transientItem->GetHttpRequestHeaders() copy]);
1579 [self loadWithParams:reloadParams]; 1580 [self loadWithParams:reloadParams];
1580 } else { 1581 } else {
1581 // As with back and forward navigation, load the URL manually instead of 1582 // As with back and forward navigation, load the URL manually instead of
1582 // using the web view's reload. This ensures state processing and delegate 1583 // using the web view's reload. This ensures state processing and delegate
1583 // calls are consistent. 1584 // calls are consistent.
1584 // TODO(eugenebut): revisit this for WKWebView. 1585 // TODO(eugenebut): revisit this for WKWebView.
1585 [self loadCurrentURL]; 1586 [self loadCurrentURL];
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 isPushStateNavigationBetweenEntry:fromEntry 1752 isPushStateNavigationBetweenEntry:fromEntry
1752 andEntry:self.currentSessionEntry]; 1753 andEntry:self.currentSessionEntry];
1753 web::NavigationItemImpl* currentItem = 1754 web::NavigationItemImpl* currentItem =
1754 self.currentSessionEntry.navigationItemImpl; 1755 self.currentSessionEntry.navigationItemImpl;
1755 GURL endURL = [self URLForHistoryNavigationFromItem:fromEntry.navigationItem 1756 GURL endURL = [self URLForHistoryNavigationFromItem:fromEntry.navigationItem
1756 toItem:currentItem]; 1757 toItem:currentItem];
1757 if (shouldLoadURL) { 1758 if (shouldLoadURL) {
1758 ui::PageTransition transition = ui::PageTransitionFromInt( 1759 ui::PageTransition transition = ui::PageTransitionFromInt(
1759 ui::PAGE_TRANSITION_RELOAD | ui::PAGE_TRANSITION_FORWARD_BACK); 1760 ui::PAGE_TRANSITION_RELOAD | ui::PAGE_TRANSITION_FORWARD_BACK);
1760 1761
1761 web::WebLoadParams params(endURL); 1762 NavigationManager::WebLoadParams params(endURL);
1762 if (currentItem) { 1763 if (currentItem) {
1763 params.referrer = currentItem->GetReferrer(); 1764 params.referrer = currentItem->GetReferrer();
1764 } 1765 }
1765 params.transition_type = transition; 1766 params.transition_type = transition;
1766 [self loadWithParams:params]; 1767 [self loadWithParams:params];
1767 } 1768 }
1768 // Set the serialized state if necessary. State must be set if the document 1769 // Set the serialized state if necessary. State must be set if the document
1769 // objects are the same. This can happen if: 1770 // objects are the same. This can happen if:
1770 // - The navigation is a pushState (i.e., shouldLoadURL is NO). 1771 // - The navigation is a pushState (i.e., shouldLoadURL is NO).
1771 // - The navigation is a hash change. 1772 // - The navigation is a hash change.
(...skipping 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after
3789 if ([MIMEType isEqualToString:@"text/html"] || 3790 if ([MIMEType isEqualToString:@"text/html"] ||
3790 [MIMEType isEqualToString:@"application/xhtml+xml"] || 3791 [MIMEType isEqualToString:@"application/xhtml+xml"] ||
3791 [MIMEType isEqualToString:@"application/xml"]) { 3792 [MIMEType isEqualToString:@"application/xml"]) {
3792 return web::WEB_VIEW_DOCUMENT_TYPE_HTML; 3793 return web::WEB_VIEW_DOCUMENT_TYPE_HTML;
3793 } 3794 }
3794 3795
3795 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; 3796 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
3796 } 3797 }
3797 3798
3798 @end 3799 @end
OLDNEW
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.h ('k') | ios/web/web_state/ui/crw_wk_web_view_web_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698