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

Side by Side Diff: ios/web/navigation/crw_session_controller.mm

Issue 2705293014: Created web::UserAgentType. (Closed)
Patch Set: self review Created 3 years, 9 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/navigation/crw_session_controller.h" 5 #import "ios/web/navigation/crw_session_controller.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/format_macros.h" 13 #include "base/format_macros.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #import "base/mac/foundation_util.h" 15 #import "base/mac/foundation_util.h"
16 #import "base/mac/scoped_nsobject.h" 16 #import "base/mac/scoped_nsobject.h"
17 #include "base/strings/sys_string_conversions.h" 17 #include "base/strings/sys_string_conversions.h"
18 #include "ios/web/history_state_util.h" 18 #include "ios/web/history_state_util.h"
19 #import "ios/web/navigation/crw_session_certificate_policy_manager.h" 19 #import "ios/web/navigation/crw_session_certificate_policy_manager.h"
20 #import "ios/web/navigation/crw_session_controller+private_constructors.h" 20 #import "ios/web/navigation/crw_session_controller+private_constructors.h"
21 #import "ios/web/navigation/crw_session_entry.h" 21 #import "ios/web/navigation/crw_session_entry.h"
22 #import "ios/web/navigation/navigation_item_impl.h" 22 #import "ios/web/navigation/navigation_item_impl.h"
23 #include "ios/web/navigation/navigation_manager_facade_delegate.h" 23 #include "ios/web/navigation/navigation_manager_facade_delegate.h"
24 #import "ios/web/navigation/navigation_manager_impl.h" 24 #import "ios/web/navigation/navigation_manager_impl.h"
25 #include "ios/web/navigation/time_smoother.h" 25 #include "ios/web/navigation/time_smoother.h"
26 #include "ios/web/public/browser_state.h" 26 #include "ios/web/public/browser_state.h"
27 #include "ios/web/public/browser_url_rewriter.h" 27 #include "ios/web/public/browser_url_rewriter.h"
28 #include "ios/web/public/referrer.h" 28 #include "ios/web/public/referrer.h"
29 #include "ios/web/public/ssl_status.h" 29 #include "ios/web/public/ssl_status.h"
30 #import "ios/web/public/web_client.h"
30 31
31 #if !defined(__has_feature) || !__has_feature(objc_arc) 32 #if !defined(__has_feature) || !__has_feature(objc_arc)
32 #error "This file requires ARC support." 33 #error "This file requires ARC support."
33 #endif 34 #endif
34 35
35 @interface CRWSessionController () { 36 @interface CRWSessionController () {
36 // Weak pointer back to the owning NavigationManager. This is to facilitate 37 // Weak pointer back to the owning NavigationManager. This is to facilitate
37 // the incremental merging of the two classes. 38 // the incremental merging of the two classes.
38 web::NavigationManagerImpl* _navigationManager; 39 web::NavigationManagerImpl* _navigationManager;
39 40
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 501
501 web::Referrer referrer(lastCommittedItem->GetURL(), 502 web::Referrer referrer(lastCommittedItem->GetURL(),
502 web::ReferrerPolicyDefault); 503 web::ReferrerPolicyDefault);
503 base::scoped_nsobject<CRWSessionEntry> pushedEntry([self 504 base::scoped_nsobject<CRWSessionEntry> pushedEntry([self
504 sessionEntryWithURL:URL 505 sessionEntryWithURL:URL
505 referrer:referrer 506 referrer:referrer
506 transition:transition 507 transition:transition
507 initiationType:web::NavigationInitiationType::USER_INITIATED]); 508 initiationType:web::NavigationInitiationType::USER_INITIATED]);
508 509
509 web::NavigationItemImpl* pushedItem = [pushedEntry navigationItemImpl]; 510 web::NavigationItemImpl* pushedItem = [pushedEntry navigationItemImpl];
510 pushedItem->SetIsOverridingUserAgent( 511 pushedItem->SetUserAgentType(lastCommittedItem->GetUserAgentType());
511 lastCommittedItem->IsOverridingUserAgent());
512 pushedItem->SetSerializedStateObject(stateObject); 512 pushedItem->SetSerializedStateObject(stateObject);
513 pushedItem->SetIsCreatedFromPushState(true); 513 pushedItem->SetIsCreatedFromPushState(true);
514 pushedItem->GetSSL() = lastCommittedItem->GetSSL(); 514 pushedItem->GetSSL() = lastCommittedItem->GetSSL();
515 515
516 [self clearForwardItems]; 516 [self clearForwardItems];
517 // Add the new entry at the end. 517 // Add the new entry at the end.
518 [_entries addObject:pushedEntry]; 518 [_entries addObject:pushedEntry];
519 _previousNavigationIndex = _currentNavigationIndex; 519 _previousNavigationIndex = _currentNavigationIndex;
520 self.currentNavigationIndex = [_entries count] - 1; 520 self.currentNavigationIndex = [_entries count] - 1;
521 521
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 web::BrowserURLRewriter::GetInstance()->RewriteURLIfNecessary( 707 web::BrowserURLRewriter::GetInstance()->RewriteURLIfNecessary(
708 &loaded_url, _browserState); 708 &loaded_url, _browserState);
709 } 709 }
710 710
711 std::unique_ptr<web::NavigationItemImpl> item(new web::NavigationItemImpl()); 711 std::unique_ptr<web::NavigationItemImpl> item(new web::NavigationItemImpl());
712 item->SetOriginalRequestURL(loaded_url); 712 item->SetOriginalRequestURL(loaded_url);
713 item->SetURL(loaded_url); 713 item->SetURL(loaded_url);
714 item->SetReferrer(referrer); 714 item->SetReferrer(referrer);
715 item->SetTransitionType(transition); 715 item->SetTransitionType(transition);
716 item->SetNavigationInitiationType(initiationType); 716 item->SetNavigationInitiationType(initiationType);
717 if (web::GetWebClient()->IsAppSpecificURL(loaded_url))
718 item->SetUserAgentType(web::UserAgentType::NONE);
717 return [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)]; 719 return [[CRWSessionEntry alloc] initWithNavigationItem:std::move(item)];
718 } 720 }
719 721
720 - (BOOL)isRedirectTransitionForItemAtIndex:(NSInteger)index { 722 - (BOOL)isRedirectTransitionForItemAtIndex:(NSInteger)index {
721 ui::PageTransition transition = 723 ui::PageTransition transition =
722 [_entries[index] navigationItem]->GetTransitionType(); 724 [_entries[index] navigationItem]->GetTransitionType();
723 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO; 725 return (transition & ui::PAGE_TRANSITION_IS_REDIRECT_MASK) ? YES : NO;
724 } 726 }
725 727
726 - (web::NavigationItemList)itemListForEntryList:(NSArray*)entries { 728 - (web::NavigationItemList)itemListForEntryList:(NSArray*)entries {
727 web::NavigationItemList list(entries.count); 729 web::NavigationItemList list(entries.count);
728 for (size_t index = 0; index < entries.count; ++index) 730 for (size_t index = 0; index < entries.count; ++index)
729 list[index] = [entries[index] navigationItem]; 731 list[index] = [entries[index] navigationItem];
730 return list; 732 return list;
731 } 733 }
732 734
733 @end 735 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698