summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-09 17:01:28 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-09 17:01:28 +0000
commita5ec3eacc28cd75102ef23fcc15375f6b0628bb1 (patch)
tree99e7cba3725ca1b8017face1608cacbbd198e55e /chrome
parent2f2a8e4bf18a837dbb8c786402bdafbb859ff78a (diff)
downloadchromium_src-a5ec3eacc28cd75102ef23fcc15375f6b0628bb1.zip
chromium_src-a5ec3eacc28cd75102ef23fcc15375f6b0628bb1.tar.gz
chromium_src-a5ec3eacc28cd75102ef23fcc15375f6b0628bb1.tar.bz2
Fixes regression where the wrong url was getting added for instant
navigations to the default search provider. BUG=72353 TEST=covered by test now, can also see bug for details. Review URL: http://codereview.chromium.org/6462023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74296 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/instant/instant_browsertest.cc10
-rw-r--r--chrome/browser/instant/instant_controller.cc5
-rw-r--r--chrome/browser/instant/instant_controller.h4
-rw-r--r--chrome/browser/instant/instant_loader.cc8
4 files changed, 25 insertions, 2 deletions
diff --git a/chrome/browser/instant/instant_browsertest.cc b/chrome/browser/instant/instant_browsertest.cc
index 8b3ad93..7baa1c3 100644
--- a/chrome/browser/instant/instant_browsertest.cc
+++ b/chrome/browser/instant/instant_browsertest.cc
@@ -294,6 +294,16 @@ IN_PROC_BROWSER_TEST_F(InstantTest, OnChangeEvent) {
ASSERT_EQ(ASCIIToUTF16("abcdef"), location_bar_->location_entry()->GetText());
+ // Make sure the url that will get committed when we press enter matches that
+ // of the default search provider.
+ const TemplateURL* default_turl =
+ browser()->profile()->GetTemplateURLModel()->GetDefaultSearchProvider();
+ ASSERT_TRUE(default_turl);
+ ASSERT_TRUE(default_turl->url());
+ EXPECT_EQ(default_turl->url()->ReplaceSearchTerms(
+ *default_turl, ASCIIToUTF16("abcdef"), 0, string16()),
+ browser()->instant()->GetCurrentURL().spec());
+
// Check that the value is reflected and onchange is called.
EXPECT_EQ("true 0 0 1 2 a false abc false 3 3",
GetSearchStateAsString(preview_));
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 68a9d7e..e255509 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -334,6 +334,11 @@ bool InstantController::MightSupportInstant() {
loader_manager_->active_loader()->is_showing_instant();
}
+GURL InstantController::GetCurrentURL() {
+ return loader_manager_.get() && loader_manager_->active_loader() ?
+ loader_manager_->active_loader()->url() : GURL();
+}
+
void InstantController::ShowInstantLoader(InstantLoader* loader) {
DCHECK(loader_manager_.get());
if (loader_manager_->current_loader() == loader) {
diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h
index 20a624e..8b005d8 100644
--- a/chrome/browser/instant/instant_controller.h
+++ b/chrome/browser/instant/instant_controller.h
@@ -164,6 +164,10 @@ class InstantController : public InstantLoaderDelegate {
// (until the search provider loads, then both return true).
bool MightSupportInstant();
+ // Returns the URL currently being loaded or shown if everything has finished
+ // loading.
+ GURL GetCurrentURL();
+
// InstantLoaderDelegate
virtual void ShowInstantLoader(InstantLoader* loader);
virtual void SetSuggestedTextFor(InstantLoader* loader,
diff --git a/chrome/browser/instant/instant_loader.cc b/chrome/browser/instant/instant_loader.cc
index 3c27d20..7e2b6f0 100644
--- a/chrome/browser/instant/instant_loader.cc
+++ b/chrome/browser/instant/instant_loader.cc
@@ -448,6 +448,8 @@ void InstantLoader::Update(TabContentsWrapper* tab_contents,
const string16& user_text,
bool verbatim,
string16* suggested_text) {
+ DCHECK(!url.is_empty() && url.is_valid());
+
// Strip leading ?.
string16 new_user_text =
!user_text.empty() && (UTF16ToWide(user_text)[0] == L'?') ?
@@ -469,11 +471,13 @@ void InstantLoader::Update(TabContentsWrapper* tab_contents,
(template_url_id_ &&
(new_user_text.empty() || user_text_ == new_user_text))) {
suggested_text->assign(last_suggestion_);
+ // Track the url even if we're not going to update. This is important as
+ // when we get the suggest text we set user_text_ to the new suggest text,
+ // but yet the url is much different.
+ url_ = url;
return;
}
- DCHECK(!url.is_empty() && url.is_valid());
-
url_ = url;
user_text_ = new_user_text;
verbatim_ = verbatim;