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

Unified Diff: ios/web/web_state/web_state_impl.mm

Issue 1360993002: Moved NavigationManagerImpl serialization out of CRWSessionController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: test fix Created 3 years, 11 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
« ios/web/web_state/web_state_impl.h ('K') | « ios/web/web_state/web_state_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/web_state_impl.mm
diff --git a/ios/web/web_state/web_state_impl.mm b/ios/web/web_state/web_state_impl.mm
index 6d5fe3498b4584b40cc38152cca3759fb2edbae9..8e7f5012bc5622699c0d1f9c3708bee2d897200a 100644
--- a/ios/web/web_state/web_state_impl.mm
+++ b/ios/web/web_state/web_state_impl.mm
@@ -16,6 +16,7 @@
#import "ios/web/navigation/crw_session_entry.h"
#import "ios/web/navigation/navigation_item_impl.h"
#include "ios/web/public/browser_state.h"
+#import "ios/web/public/crw_navigation_manager_serialization.h"
#import "ios/web/public/image_fetcher/image_data_fetcher.h"
#import "ios/web/public/java_script_dialog_presenter.h"
#import "ios/web/public/navigation_item.h"
@@ -47,14 +48,17 @@
/* static */
std::unique_ptr<WebState> WebState::Create(const CreateParams& params) {
std::unique_ptr<WebStateImpl> web_state(
- new WebStateImpl(params.browser_state));
-
- NSString* window_name = nil;
- NSString* opener_id = nil;
- BOOL opened_by_dom = NO;
- int opener_navigation_index = 0;
- web_state->GetNavigationManagerImpl().InitializeSession(
- window_name, opener_id, opened_by_dom, opener_navigation_index);
+ new WebStateImpl(params.browser_state, params.serialization));
+
+ if (!params.serialization) {
+ // Initialize the session if not creating from serialization.
+ NSString* window_name = nil;
+ NSString* opener_id = nil;
+ BOOL opened_by_dom = NO;
+ int opener_navigation_index = 0;
+ web_state->GetNavigationManagerImpl().InitializeSession(
+ window_name, opener_id, opened_by_dom, opener_navigation_index);
+ }
// This std::move is required to compile with the version of clang shipping
// with Xcode 8.0+. Evalute whether the issue is fixed once a new version of
@@ -63,16 +67,31 @@
}
WebStateImpl::WebStateImpl(BrowserState* browser_state)
+ : WebStateImpl(browser_state, nullptr) {}
+
+WebStateImpl::WebStateImpl(
+ BrowserState* browser_state,
+ CRWNavigationManagerSerialization* serialized_session)
: delegate_(nullptr),
is_loading_(false),
is_being_destroyed_(false),
facade_delegate_(nullptr),
web_controller_(nil),
- navigation_manager_(this, browser_state),
interstitial_(nullptr),
weak_factory_(this) {
+ // Create or deserialize the NavigationManager.
+ if (serialized_session) {
+ navigation_manager_ =
+ serialization_builder_.BuildNavigationManagerImpl(serialized_session);
+ } else {
+ navigation_manager_.reset(new NavigationManagerImpl());
+ }
+ navigation_manager_->SetDelegate(this);
+ navigation_manager_->SetBrowserState(browser_state);
+ // Send creation event and create the web controller.
GlobalWebStateEventTracker::GetInstance()->OnWebStateCreated(this);
web_controller_.reset([[CRWWebController alloc] initWithWebState:this]);
+ // Set up the image fetcher.
image_fetcher_ =
base::MakeUnique<ImageDataFetcher>(web::WebThread::GetBlockingPool());
image_fetcher_->SetRequestContextGetter(browser_state->GetRequestContext());
@@ -164,12 +183,6 @@
facade_delegate_ = facade_delegate;
}
-WebStateImpl* WebStateImpl::CopyForSessionWindow() {
- WebStateImpl* copy = new WebStateImpl(GetBrowserState());
- copy->GetNavigationManagerImpl().CopyState(&navigation_manager_);
- return copy;
-}
-
void WebStateImpl::OnNavigationCommitted(const GURL& url) {
UpdateHttpResponseHeaders(url);
}
@@ -310,11 +323,11 @@
}
NavigationManagerImpl& WebStateImpl::GetNavigationManagerImpl() {
- return navigation_manager_;
+ return *navigation_manager_;
}
const NavigationManagerImpl& WebStateImpl::GetNavigationManagerImpl() const {
- return navigation_manager_;
+ return *navigation_manager_;
}
void WebStateImpl::CreateWebUI(const GURL& url) {
@@ -346,7 +359,7 @@
// TODO(stuartmorgan): Implement the NavigationManager logic necessary to
// match the WebContents implementation of this method.
DCHECK(Configured());
- web::NavigationItem* item = navigation_manager_.GetLastCommittedItem();
+ web::NavigationItem* item = navigation_manager_->GetLastCommittedItem();
return item ? item->GetTitleForDisplay() : empty_string16_;
}
@@ -597,7 +610,7 @@
}
BrowserState* WebStateImpl::GetBrowserState() const {
- return navigation_manager_.GetBrowserState();
+ return navigation_manager_->GetBrowserState();
}
void WebStateImpl::OpenURL(const WebState::OpenURLParams& params) {
@@ -619,6 +632,11 @@
return &GetNavigationManagerImpl();
}
+CRWNavigationManagerSerialization*
+WebStateImpl::BuildSerializedNavigationManager() {
+ return serialization_builder_.BuildSerialization(navigation_manager_.get());
+}
+
CRWJSInjectionReceiver* WebStateImpl::GetJSInjectionReceiver() const {
return [web_controller_ jsInjectionReceiver];
}
@@ -656,12 +674,12 @@
}
const GURL& WebStateImpl::GetVisibleURL() const {
- web::NavigationItem* item = navigation_manager_.GetVisibleItem();
+ web::NavigationItem* item = navigation_manager_->GetVisibleItem();
return item ? item->GetVirtualURL() : GURL::EmptyGURL();
}
const GURL& WebStateImpl::GetLastCommittedURL() const {
- web::NavigationItem* item = navigation_manager_.GetLastCommittedItem();
+ web::NavigationItem* item = navigation_manager_->GetLastCommittedItem();
return item ? item->GetVirtualURL() : GURL::EmptyGURL();
}
« ios/web/web_state/web_state_impl.h ('K') | « ios/web/web_state/web_state_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698