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

Unified Diff: ios/web/navigation/navigation_manager_impl.mm

Issue 2698773002: [iOS] Refactoring web CRWSessionController user agent code. (Closed)
Patch Set: Addressed feedback Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: ios/web/navigation/navigation_manager_impl.mm
diff --git a/ios/web/navigation/navigation_manager_impl.mm b/ios/web/navigation/navigation_manager_impl.mm
index b246e7e17e03c15ebaf0ace9fb3799b016ecf84a..0eab696684f141e3cf1a2ca8043012c5222e50be 100644
--- a/ios/web/navigation/navigation_manager_impl.mm
+++ b/ios/web/navigation/navigation_manager_impl.mm
@@ -68,7 +68,10 @@ bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) {
}
NavigationManagerImpl::NavigationManagerImpl()
- : delegate_(nullptr), browser_state_(nullptr), facade_delegate_(nullptr) {}
+ : override_desktop_user_agent_for_next_pending_item_(false),
+ delegate_(nullptr),
+ browser_state_(nullptr),
+ facade_delegate_(nullptr) {}
NavigationManagerImpl::~NavigationManagerImpl() {
// The facade layer should be deleted before this object.
@@ -173,6 +176,25 @@ bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) {
delegate_->GetWebState()->OpenURL(params);
}
+void NavigationManagerImpl::AddPendingItem(const GURL& url,
+ const web::Referrer& referrer,
+ ui::PageTransition navigation_type,
+ ItemInitiationType initiation_type) {
+ bool renderer_initiated =
+ initiation_type == ItemInitiationType::RENDERER_INITIATED;
+ [session_controller_ addPendingItem:url
+ referrer:referrer
+ transition:navigation_type
+ rendererInitiated:renderer_initiated];
+
+ bool use_desktop_user_agent =
+ override_desktop_user_agent_for_next_pending_item_ ||
+ (GetLastCommittedItem() &&
+ GetLastCommittedItem()->IsOverridingUserAgent());
+ GetPendingItem()->SetIsOverridingUserAgent(use_desktop_user_agent);
+ override_desktop_user_agent_for_next_pending_item_ = false;
+}
+
NavigationItem* NavigationManagerImpl::GetLastUserItem() const {
CRWSessionEntry* entry = [session_controller_ lastUserEntry];
return [entry navigationItem];
@@ -396,6 +418,13 @@ bool AreURLsInPageNavigation(const GURL& existing_url, const GURL& new_url) {
return result;
}
+void NavigationManagerImpl::OverrideDesktopUserAgentForNextPendingItem() {
+ if (GetPendingItem())
+ GetPendingItem()->SetIsOverridingUserAgent(true);
+ else
+ override_desktop_user_agent_for_next_pending_item_ = true;
+}
+
bool NavigationManagerImpl::IsRedirectItemAtIndex(int index) const {
DCHECK_GT(index, 0);
DCHECK_LT(index, GetItemCount());

Powered by Google App Engine
This is Rietveld 408576698