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

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

Issue 2698773002: [iOS] Refactoring web CRWSessionController user agent code. (Closed)
Patch Set: Fix unit tests and rebase 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..140c760468abf0f45fe5fdaa6d512dbb8b08ed32 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,27 @@ 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,
+ NavigationInitiationType initiation_type) {
+ [session_controller_ addPendingItem:url
+ referrer:referrer
+ transition:navigation_type
+ initiationType:initiation_type];
+
+ // Do nothing if pending item is the same as last committed item.
+ if (GetPendingItem()) {
+ 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 +420,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());
« no previous file with comments | « ios/web/navigation/navigation_manager_impl.h ('k') | ios/web/navigation/navigation_manager_impl_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698