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

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: Address comment. Created 7 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
Index: chrome/browser/instant/instant_controller.cc
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 6314a47f70ccc5f00ee9621f207d5c4be214c077..9ae8c0aa12e98e93bb45e700ba4184d5bfcb4c05 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/instant/instant_controller.h"
#include "base/command_line.h"
+#include "base/debug/stack_trace.h"
sreeram 2013/01/25 18:17:29 Remove this before submitting.
Jered 2013/01/25 19:27:18 Done.
#include "base/metrics/histogram.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
@@ -180,7 +181,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() {
@@ -909,6 +911,8 @@ void InstantController::InstantLoaderAboutToNavigateMainFrame(const GURL& url) {
if (model_.mode().is_ntp() ||
(url.host() != instant_url.host() || url.path() != instant_url.path())) {
CommitIfPossible(INSTANT_COMMIT_NAVIGATED);
+ } else {
+ UpdateTransientHistoryEntry(url);
}
}
@@ -1088,6 +1092,8 @@ void InstantController::HideInternal() {
loader_->Update(string16(), 0, 0, true);
}
+ ResetTransientHistoryEntry();
+
// Clear the first interaction timestamp for later use.
first_interaction_time_ = base::Time();
}
@@ -1145,6 +1151,50 @@ void InstantController::ShowLoader(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();
+ // Save any transient entry already associated with the active tab.
+ content::NavigationEntry* old_transient_entry =
+ active_tab->GetController().GetTransientEntry();
+ if (old_transient_entry && !instant_set_transient_entry_)
+ transient_entry_.reset(
+ content::NavigationEntry::Create(*old_transient_entry));
+ // 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 = loader_->base_navigation_entry();
+ DCHECK(base_entry != NULL);
+ content::NavigationEntry* new_transient_entry =
+ content::NavigationEntry::Create(*base_entry);
+ active_tab->GetController().AddTransientEntry(new_transient_entry);
+ instant_set_transient_entry_ = true;
+}
+
+void InstantController::ResetTransientHistoryEntry() {
+ content::NavigationEntry* old_transient_entry = transient_entry_.release();
+ if (old_transient_entry) {
+ content::WebContents* active_tab = browser_->GetActiveWebContents();
+ active_tab->GetController().AddTransientEntry(old_transient_entry);
+ chrome::search::SearchTabHelper::FromWebContents(active_tab)->
+ NavigationEntryUpdated();
+ }
+ instant_set_transient_entry_ = false;
+}
+
+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();
+ transient_entry->SetURL(url);
+ transient_entry->SetVirtualURL(url);
+ }
}
void InstantController::SendPopupBoundsToPage() {

Powered by Google App Engine
This is Rietveld 408576698