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

Unified Diff: chrome/browser/instant/instant_controller.cc

Issue 11416187: Commit instant loader when the instant page navigates away from instant URL. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixing issue caused due to removal of TabContents. Created 8 years 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
« no previous file with comments | « chrome/browser/instant/instant_controller.h ('k') | chrome/browser/instant/instant_loader.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/instant/instant_controller.cc
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index be835bb3703cd3a495288b0474c4388424f5e257..d3e654553b22918bb55bde6dfd1710d6fe874a4d 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -444,12 +444,12 @@ bool InstantController::CommitIfPossible(InstantCommitType type) {
return false;
}
- if (!IsPreviewingSearchResults())
+ if (!IsPreviewingSearchResults() && type != INSTANT_COMMIT_NAVIGATED)
return false;
if (type == INSTANT_COMMIT_FOCUS_LOST)
loader_->Cancel(last_omnibox_text_);
- else
+ else if (type != INSTANT_COMMIT_NAVIGATED)
loader_->Submit(last_omnibox_text_);
content::WebContents* preview = loader_->ReleaseContents();
@@ -487,7 +487,15 @@ bool InstantController::CommitIfPossible(InstantCommitType type) {
loader_->last_navigation();
if (!last_navigation.url.is_empty()) {
content::NavigationEntry* entry = preview->GetController().GetActiveEntry();
- DCHECK_EQ(last_navigation.url, entry->GetURL());
+
+ // The last navigation should be the same as the active entry if the loader
+ // is in search mode. During navigation, the active entry could have
+ // changed since DidCommitProvisionalLoadForFrame is called after the entry
+ // is changed.
+ // TODO(shishir): Should we commit the last navigation for
+ // INSTANT_COMMIT_NAVIGATED.
+ DCHECK(type == INSTANT_COMMIT_NAVIGATED ||
+ last_navigation.url == entry->GetURL());
// Add the page to history.
HistoryTabHelper* history_tab_helper =
@@ -792,6 +800,16 @@ void InstantController::InstantLoaderRenderViewGone() {
CreateDefaultLoader();
}
+void InstantController::InstantLoaderAboutToNavigateMainFrame(const GURL& url) {
+ GURL instant_url(loader_->instant_url());
+
+ // Don't commit if the URL being navigated to has the same host and path as
+ // the instant URL. This enables the instant page to change the query
+ // parameters and fragments of the URL without it navigating.
+ if (url.host() != instant_url.host() || url.path() != instant_url.path())
+ CommitIfPossible(INSTANT_COMMIT_NAVIGATED);
+}
+
bool InstantController::ResetLoader(const TemplateURL* template_url,
const content::WebContents* active_tab) {
std::string instant_url;
« no previous file with comments | « chrome/browser/instant/instant_controller.h ('k') | chrome/browser/instant/instant_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698