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

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

Issue 12001002: InstantExtended: Transient naventry for preview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 7 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
« 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 80f9b796a4cf181a57ac371c9af2bab3abe1c1df..fad04d677073215b45861868a1dedb4472c2fba4 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -183,7 +183,8 @@ InstantController::InstantController(chrome::BrowserInstantController* browser,
omnibox_focus_state_(OMNIBOX_FOCUS_NONE),
start_margin_(0),
end_margin_(0),
- allow_preview_to_show_search_suggestions_(false) {
+ allow_preview_to_show_search_suggestions_(false),
+ instant_set_transient_entry_(false) {
}
InstantController::~InstantController() {
@@ -933,6 +934,8 @@ void InstantController::InstantPageAboutToNavigateMainFrame(
if (model_.mode().is_ntp() ||
(url.host() != instant_url.host() || url.path() != instant_url.path())) {
CommitIfPossible(INSTANT_COMMIT_NAVIGATED);
+ } else {
+ UpdateTransientHistoryEntry(url);
}
}
@@ -1202,6 +1205,8 @@ void InstantController::HideInternal() {
overlay_->Update(string16(), 0, 0, true);
}
+ ResetTransientHistoryEntry();
+
// Clear the first interaction timestamp for later use.
first_interaction_time_ = base::Time();
}
@@ -1260,6 +1265,43 @@ void InstantController::ShowOverlay(InstantShownReason reason,
// overlay (because we're not full height).
if (reason == INSTANT_SHOWN_CLICKED_QUERY_SUGGESTION)
CommitIfPossible(INSTANT_COMMIT_CLICKED_QUERY_SUGGESTION);
+ else if (extended_enabled_ && IsFullHeight(model_))
+ SetTransientHistoryEntry();
+}
+
+void InstantController::SetTransientHistoryEntry() {
+ content::WebContents* active_tab = browser_->GetActiveWebContents();
+ // If the active tab already has a transient entry, leave it alone.
+ if (active_tab->GetController().GetTransientEntry())
+ return;
+ // The loader's base navigation entry should describe the search provider
+ // without reference to a specific query. The alternative, updating the query
+ // in the tab title as the user types, would be distracting.
+ const content::NavigationEntry* base_entry =
+ overlay_->base_navigation_entry();
+ DCHECK(base_entry != NULL);
+ content::NavigationEntry* transient_entry =
+ content::NavigationEntry::Create(*base_entry);
+ active_tab->GetController().AddTransientEntry(transient_entry);
+ instant_set_transient_entry_ = true;
+}
+
+void InstantController::UpdateTransientHistoryEntry(const GURL& url) {
+ // URL should update so that if the user presses reload, we reload the page
+ // for the current query, but title remains unchanged so it doesn't flicker.
+ if (instant_set_transient_entry_) {
+ content::WebContents* active_tab = browser_->GetActiveWebContents();
+ content::NavigationEntry* transient_entry =
+ active_tab->GetController().GetTransientEntry();
+ DCHECK(transient_entry != NULL);
+ transient_entry->SetURL(url);
+ transient_entry->SetVirtualURL(url);
+ }
+}
+
+void InstantController::ResetTransientHistoryEntry() {
+ // NavigationController will discard the entry.
+ instant_set_transient_entry_ = false;
}
void InstantController::SendPopupBoundsToPage() {
« 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