summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/favicon/DEPS4
-rw-r--r--chrome/browser/favicon/favicon_tab_helper.cc6
-rw-r--r--chrome/browser/instant/instant_extended_browsertest.cc2
-rw-r--r--chrome/browser/instant/instant_ntp.cc5
-rw-r--r--chrome/browser/ui/bookmarks/bookmark_tab_helper.cc7
-rw-r--r--chrome/browser/ui/browser.cc3
-rw-r--r--chrome/browser/ui/search/search.cc199
-rw-r--r--chrome/browser/ui/search/search.h11
-rw-r--r--chrome/browser/ui/search/search_tab_helper.cc5
-rw-r--r--chrome/browser/ui/search/search_unittest.cc94
-rw-r--r--chrome/browser/ui/toolbar/toolbar_model_impl.cc2
-rw-r--r--chrome/test/data/instant_extended.html3
12 files changed, 246 insertions, 95 deletions
diff --git a/chrome/browser/favicon/DEPS b/chrome/browser/favicon/DEPS
index f68d009..6acb6bd 100644
--- a/chrome/browser/favicon/DEPS
+++ b/chrome/browser/favicon/DEPS
@@ -24,6 +24,10 @@
"!chrome/browser/profiles/profile_dependency_manager.h",
"!chrome/browser/profiles/profile_keyed_service.h",
"!chrome/browser/profiles/profile_keyed_service_factory.h",
+ # TODO(samarth): search.h will be moved to chrome/browser/search. Update this
+ # dependency and move to list of permanently-allowed DEPS when that happens.
+ # See http://crbug.com/179184.
+ "!chrome/browser/ui/search/search.h",
"!chrome/browser/ui/webui/chrome_web_ui_controller_factory.h",
# Do not add to the list of temporarily-allowed dependencies above,
# and please do not introduce more #includes of these files.
diff --git a/chrome/browser/favicon/favicon_tab_helper.cc b/chrome/browser/favicon/favicon_tab_helper.cc
index 2000b33..a58f7f7 100644
--- a/chrome/browser/favicon/favicon_tab_helper.cc
+++ b/chrome/browser/favicon/favicon_tab_helper.cc
@@ -10,9 +10,9 @@
#include "chrome/browser/history/history_service.h"
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/search/search.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_notification_types.h"
-#include "chrome/common/url_constants.h"
#include "content/public/browser/favicon_status.h"
#include "content/public/browser/invalidate_type.h"
#include "content/public/browser/navigation_controller.h"
@@ -91,8 +91,8 @@ bool FaviconTabHelper::ShouldDisplayFavicon() {
if (controller.GetLastCommittedEntry() && controller.GetPendingEntry())
return true;
- // No favicon on New Tab Pages.
- if (web_contents()->GetURL() == GURL(chrome::kChromeUINewTabURL))
+ // No favicon on Instant New Tab Pages.
+ if (chrome::search::IsInstantNTP(web_contents()))
return false;
content::WebUI* web_ui = web_contents()->GetWebUIForCurrentState();
diff --git a/chrome/browser/instant/instant_extended_browsertest.cc b/chrome/browser/instant/instant_extended_browsertest.cc
index f7dc747..4068cc0 100644
--- a/chrome/browser/instant/instant_extended_browsertest.cc
+++ b/chrome/browser/instant/instant_extended_browsertest.cc
@@ -377,6 +377,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInNewTab) {
content::WebContents* active_tab =
browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_EQ(ntp_contents, active_tab);
+ EXPECT_TRUE(chrome::search::IsInstantNTP(active_tab));
}
IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInSameTab) {
@@ -398,6 +399,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInSameTab) {
content::WebContents* active_tab =
browser()->tab_strip_model()->GetActiveWebContents();
EXPECT_EQ(ntp_contents, active_tab);
+ EXPECT_TRUE(chrome::search::IsInstantNTP(active_tab));
}
IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxHasFocusOnNewTab) {
diff --git a/chrome/browser/instant/instant_ntp.cc b/chrome/browser/instant/instant_ntp.cc
index f23a3bf..f178ee5 100644
--- a/chrome/browser/instant/instant_ntp.cc
+++ b/chrome/browser/instant/instant_ntp.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/instant/instant_ntp.h"
-#include "chrome/common/url_constants.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/web_contents.h"
@@ -24,8 +23,6 @@ void InstantNTP::InitContents(Profile* profile,
loader_.Init(GURL(instant_url_), profile, active_tab, on_stale_callback);
SetContents(loader_.contents());
loader_.Load();
- contents()->GetController().GetPendingEntry()->SetVirtualURL(
- GURL(chrome::kChromeUINewTabURL));
}
scoped_ptr<content::WebContents> InstantNTP::ReleaseContents() {
@@ -35,8 +32,6 @@ scoped_ptr<content::WebContents> InstantNTP::ReleaseContents() {
void InstantNTP::OnSwappedContents() {
SetContents(loader_.contents());
- contents()->GetController().GetPendingEntry()->SetVirtualURL(
- GURL(chrome::kChromeUINewTabURL));
}
void InstantNTP::OnFocus() {
diff --git a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
index c6c6d56..6c412f1 100644
--- a/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
+++ b/chrome/browser/ui/bookmarks/bookmark_tab_helper.cc
@@ -10,6 +10,7 @@
#include "chrome/browser/prefs/pref_service_syncable.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper_delegate.h"
+#include "chrome/browser/ui/search/search.h"
#include "chrome/browser/ui/webui/ntp/new_tab_ui.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
@@ -29,7 +30,7 @@ bool BookmarkTabHelper::ShouldShowBookmarkBar() const {
// For non-first loads, we want to use the committed entry. This is so the
// bookmarks bar disappears at the same time the page does.
- content::NavigationEntry* entry =
+ const content::NavigationEntry* entry =
web_contents()->GetController().GetLastCommittedEntry();
if (!entry)
entry = web_contents()->GetController().GetVisibleEntry();
@@ -37,8 +38,8 @@ bool BookmarkTabHelper::ShouldShowBookmarkBar() const {
return false;
GURL url = entry->GetVirtualURL();
- if (url != GURL(chrome::kChromeUINewTabURL) ||
- url.SchemeIs(chrome::kViewSourceScheme)) {
+ if (url != GURL(chrome::kChromeUINewTabURL) &&
+ !chrome::search::NavEntryIsInstantNTP(web_contents(), entry)) {
return false;
}
diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc
index dcfbbcc..11d6d4e 100644
--- a/chrome/browser/ui/browser.cc
+++ b/chrome/browser/ui/browser.cc
@@ -149,7 +149,6 @@
#include "chrome/common/profiling.h"
#include "chrome/common/search_types.h"
#include "chrome/common/startup_metric_utils.h"
-#include "chrome/common/url_constants.h"
#include "chrome/common/web_apps.h"
#include "content/public/browser/color_chooser.h"
#include "content/public/browser/devtools_manager.h"
@@ -1381,7 +1380,7 @@ void Browser::BeforeUnloadFired(WebContents* web_contents,
}
bool Browser::ShouldFocusLocationBarByDefault(WebContents* source) {
- return source->GetURL() == GURL(chrome::kChromeUINewTabURL);
+ return chrome::search::IsInstantNTP(source);
}
void Browser::SetFocusToLocationBar(bool select_all) {
diff --git a/chrome/browser/ui/search/search.cc b/chrome/browser/ui/search/search.cc
index 3594ebd..14309b9 100644
--- a/chrome/browser/ui/search/search.cc
+++ b/chrome/browser/ui/search/search.cc
@@ -20,6 +20,9 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents.h"
+namespace chrome {
+namespace search {
+
namespace {
// Configuration options for Embedded Search.
@@ -34,8 +37,8 @@ const uint64 kEmbeddedPageVersionDisabled = 0;
const uint64 kEmbeddedPageVersionDefault = 2;
const char kInstantExtendedActivationName[] = "instant";
-const chrome::search::InstantExtendedDefault kInstantExtendedActivationDefault =
- chrome::search::INSTANT_DEFAULT_ON;
+const InstantExtendedDefault kInstantExtendedActivationDefault =
+ INSTANT_DEFAULT_ON;
// Constants for the field trial name and group prefix.
const char kInstantExtendedFieldTrialName[] = "InstantExtended";
@@ -45,13 +48,13 @@ const char kGroupNumberPrefix[] = "Group";
// be ignored and Instant Extended will not be enabled by default.
const char kDisablingSuffix[] = "DISABLED";
-chrome::search::InstantExtendedDefault InstantExtendedDefaultFromInt64(
+InstantExtendedDefault InstantExtendedDefaultFromInt64(
int64 default_value) {
switch (default_value) {
- case 0: return chrome::search::INSTANT_DEFAULT_ON;
- case 1: return chrome::search::INSTANT_USE_EXISTING;
- case 2: return chrome::search::INSTANT_DEFAULT_OFF;
- default: return chrome::search::INSTANT_USE_EXISTING;
+ case 0: return INSTANT_DEFAULT_ON;
+ case 1: return INSTANT_USE_EXISTING;
+ case 2: return INSTANT_DEFAULT_OFF;
+ default: return INSTANT_USE_EXISTING;
}
}
@@ -119,10 +122,95 @@ void RecordInstantExtendedOptInState(OptInState state) {
}
}
-} // namespace
+// Returns true if |contents| is rendered inside the Instant process for
+// |profile|.
+bool IsRenderedInInstantProcess(const content::WebContents* contents,
+ Profile* profile) {
+ const content::RenderProcessHost* process_host =
+ contents->GetRenderProcessHost();
+ if (!process_host)
+ return false;
-namespace chrome {
-namespace search {
+ const InstantService* instant_service =
+ InstantServiceFactory::GetForProfile(profile);
+ if (!instant_service)
+ return false;
+
+ return instant_service->IsInstantProcess(process_host->GetID());
+}
+
+// Returns true if |url| can be used as an Instant URL for |template_url|.
+bool IsInstantURL(const GURL& url,
+ bool extended_api_enabled,
+ TemplateURL* template_url) {
+ const TemplateURLRef& instant_url_ref = template_url->instant_url_ref();
+ GURL effective_url = url;
+ if (IsCommandLineInstantURL(url))
+ effective_url = CoerceCommandLineURLToTemplateURL(url, instant_url_ref);
+
+ if (!effective_url.is_valid())
+ return false;
+
+ if (extended_api_enabled && effective_url == GURL(kLocalOmniboxPopupURL))
+ return true;
+
+ if (extended_api_enabled && !effective_url.SchemeIsSecure())
+ return false;
+
+ if (extended_api_enabled &&
+ !template_url->HasSearchTermsReplacementKey(effective_url))
+ return false;
+
+ const GURL instant_url = TemplateURLRefToGURL(instant_url_ref);
+ if (!instant_url.is_valid())
+ return false;
+
+ if (MatchesOriginAndPath(effective_url, instant_url))
+ return true;
+
+ if (extended_api_enabled && MatchesAnySearchURL(effective_url, template_url))
+ return true;
+
+ return false;
+}
+
+string16 GetSearchTermsImpl(const content::WebContents* contents,
+ const content::NavigationEntry* entry) {
+ Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
+ if (!IsQueryExtractionEnabled(profile))
+ return string16();
+
+ // For security reasons, don't extract search terms if the page is not being
+ // rendered in the privileged Instant renderer process. This is to protect
+ // against a malicious page somehow scripting the search results page and
+ // faking search terms in the URL. Random pages can't get into the Instant
+ // renderer and scripting doesn't work cross-process, so if the page is in
+ // the Instant process, we know it isn't being exploited.
+ if (!IsRenderedInInstantProcess(contents, profile))
+ return string16();
+
+ // Check to see if search terms have already been extracted.
+ string16 search_terms = GetSearchTermsFromNavigationEntry(entry);
+ if (!search_terms.empty())
+ return search_terms;
+
+ // Otherwise, extract from the URL.
+ TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile);
+ if (!template_url)
+ return string16();
+
+ GURL url = entry->GetVirtualURL();
+
+ if (IsCommandLineInstantURL(url))
+ url = CoerceCommandLineURLToTemplateURL(url, template_url->url_ref());
+
+ if (url.SchemeIsSecure() && template_url->HasSearchTermsReplacementKey(url))
+ template_url->ExtractSearchTermsFromURL(url, &search_terms);
+
+ return search_terms;
+}
+
+} // namespace
const char kInstantExtendedSearchTermsKey[] = "search_terms";
@@ -212,53 +300,36 @@ string16 GetSearchTerms(const content::WebContents* contents) {
if (!contents)
return string16();
- Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
- if (!IsQueryExtractionEnabled(profile))
- return string16();
-
- // For security reasons, don't extract search terms if the page is not being
- // rendered in the privileged Instant renderer process. This is to protect
- // against a malicious page somehow scripting the search results page and
- // faking search terms in the URL. Random pages can't get into the Instant
- // renderer and scripting doesn't work cross-process, so if the page is in
- // the Instant process, we know it isn't being exploited.
- const content::RenderProcessHost* process_host =
- contents->GetRenderProcessHost();
- if (!process_host)
- return string16();
-
- const InstantService* instant_service =
- InstantServiceFactory::GetForProfile(profile);
- if (!instant_service)
- return string16();
-
- if (!instant_service->IsInstantProcess(process_host->GetID()))
- return string16();
-
- // Check to see if search terms have already been extracted.
const content::NavigationEntry* entry =
contents->GetController().GetVisibleEntry();
if (!entry)
return string16();
- string16 search_terms = GetSearchTermsFromNavigationEntry(entry);
- if (!search_terms.empty())
- return search_terms;
+ return GetSearchTermsImpl(contents, entry);
+}
- // Otherwise, extract from the URL.
- TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile);
- if (!template_url)
- return string16();
+bool IsInstantNTP(const content::WebContents* contents) {
+ return NavEntryIsInstantNTP(
+ contents, contents->GetController().GetVisibleEntry());
+}
- GURL url = entry->GetVirtualURL();
+bool NavEntryIsInstantNTP(const content::WebContents* contents,
+ const content::NavigationEntry* entry) {
+ if (!contents || !entry)
+ return false;
- if (IsCommandLineInstantURL(url))
- url = CoerceCommandLineURLToTemplateURL(url, template_url->url_ref());
+ Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext());
+ if (!IsRenderedInInstantProcess(contents, profile))
+ return false;
- if (url.SchemeIsSecure() && template_url->HasSearchTermsReplacementKey(url))
- template_url->ExtractSearchTermsFromURL(url, &search_terms);
+ TemplateURL* template_url = GetDefaultSearchProviderTemplateURL(profile);
+ if (!template_url)
+ return false;
- return search_terms;
+ const bool extended_enabled = IsInstantExtendedAPIEnabled(profile);
+ return extended_enabled &&
+ IsInstantURL(entry->GetVirtualURL(), extended_enabled, template_url) &&
+ GetSearchTermsImpl(contents, entry).empty();
}
bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) {
@@ -266,15 +337,8 @@ bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile) {
if (!template_url)
return false;
- GURL effective_url = url;
-
- if (IsCommandLineInstantURL(url)) {
- const TemplateURLRef& instant_url_ref = template_url->instant_url_ref();
- effective_url = CoerceCommandLineURLToTemplateURL(url, instant_url_ref);
- }
-
return ShouldAssignURLToInstantRendererImpl(
- effective_url,
+ url,
IsInstantExtendedAPIEnabled(profile),
template_url);
}
@@ -299,29 +363,8 @@ bool ShouldAssignURLToInstantRendererImpl(const GURL& url,
if (!url.is_valid())
return false;
- if (url.SchemeIs(chrome::kChromeSearchScheme))
- return true;
-
- if (extended_api_enabled && url == GURL(kLocalOmniboxPopupURL))
- return true;
-
- if (extended_api_enabled && !url.SchemeIsSecure())
- return false;
-
- if (extended_api_enabled && !template_url->HasSearchTermsReplacementKey(url))
- return false;
-
- GURL instant_url = TemplateURLRefToGURL(template_url->instant_url_ref());
- if (!instant_url.is_valid())
- return false;
-
- if (MatchesOriginAndPath(url, instant_url))
- return true;
-
- if (extended_api_enabled && MatchesAnySearchURL(url, template_url))
- return true;
-
- return false;
+ return url.SchemeIs(chrome::kChromeSearchScheme) ||
+ IsInstantURL(url, extended_api_enabled, template_url);
}
bool GetFieldTrialInfo(const std::string& group_name,
diff --git a/chrome/browser/ui/search/search.h b/chrome/browser/ui/search/search.h
index c66244e..7c72413 100644
--- a/chrome/browser/ui/search/search.h
+++ b/chrome/browser/ui/search/search.h
@@ -73,6 +73,17 @@ string16 GetSearchTerms(const content::WebContents* contents);
// Returns true if |url| should be rendered in the Instant renderer process.
bool ShouldAssignURLToInstantRenderer(const GURL& url, Profile* profile);
+// Returns true if the visible entry of |contents| is a New Tab Page rendered
+// by Instant. A page that matches the search or Instant URL of the default
+// search provider but does not have any search terms is considered an Instant
+// New Tab Page.
+bool IsInstantNTP(const content::WebContents* contents);
+
+// Same as IsInstantNTP but uses |nav_entry| to determine the URL for the page
+// instead of using the visible entry.
+bool NavEntryIsInstantNTP(const content::WebContents* contents,
+ const content::NavigationEntry* nav_entry);
+
// -----------------------------------------------------
// The following APIs are exposed for use in tests only.
// -----------------------------------------------------
diff --git a/chrome/browser/ui/search/search_tab_helper.cc b/chrome/browser/ui/search/search_tab_helper.cc
index b320565..35f5d71 100644
--- a/chrome/browser/ui/search/search_tab_helper.cc
+++ b/chrome/browser/ui/search/search_tab_helper.cc
@@ -25,7 +25,10 @@ bool IsNTP(const content::WebContents* contents) {
// whereas we want the visible entry.
const content::NavigationEntry* entry =
contents->GetController().GetVisibleEntry();
- return entry && entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL);
+ if (entry && entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL))
+ return true;
+
+ return chrome::search::IsInstantNTP(contents);
}
bool IsSearchResults(const content::WebContents* contents) {
diff --git a/chrome/browser/ui/search/search_unittest.cc b/chrome/browser/ui/search/search_unittest.cc
index 4e64bd3..20b65eb 100644
--- a/chrome/browser/ui/search/search_unittest.cc
+++ b/chrome/browser/ui/search/search_unittest.cc
@@ -2,8 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url.h"
+#include "chrome/browser/search_engines/template_url_service.h"
+#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/ui/search/search.h"
+#include "chrome/browser/ui/tabs/tab_strip_model.h"
+#include "chrome/test/base/browser_with_test_window_test.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/public/browser/navigation_entry.h"
+#include "content/public/browser/web_contents.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chrome {
@@ -130,5 +138,91 @@ TEST(SearchTest, CoerceCommandLineURLToTemplateURL) {
url.instant_url_ref()));
}
+class InstantNTPTest : public BrowserWithTestWindowTest {
+ protected:
+ virtual void SetUp() OVERRIDE {
+ BrowserWithTestWindowTest::SetUp();
+ TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse(
+ profile(), &TemplateURLServiceFactory::BuildInstanceFor);
+ TemplateURLService* template_url_service =
+ TemplateURLServiceFactory::GetForProfile(profile());
+ ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service);
+
+ TemplateURLData data;
+ data.SetURL("http://foo.com/#query={searchTerms}");
+ data.instant_url = "http://foo.com/instant";
+ data.search_terms_replacement_key = "strk";
+
+ TemplateURL* template_url = new TemplateURL(profile(), data);
+ template_url_service->Add(template_url);
+ template_url_service->SetDefaultSearchProvider(template_url);
+ }
+};
+
+static const struct {
+ const char* const url;
+ bool expected_result;
+ const char* const description;
+} kInstantNTPTestCases[] = {
+ {"https://foo.com/instant?strk=1", true, "Valid Instant URL"},
+ {"https://foo.com/?strk=1", true, "Valid search URL"},
+ {"https://foo.com/instant", false, "No search terms replacement"},
+ {"https://foo.com/?strk=1#query=abc", false, "Has query terms"},
+ {"http://foo.com/instant?strk=1", false, "Insecure URL"},
+ {"chrome://blank/", false, "chrome schema"},
+ {"chrome-search//foo", false, "chrome-search schema"},
+ {"https://bar.com/instant?strk=1", false, "Random non-search page"},
+};
+
+TEST_F(InstantNTPTest, InstantExtendedEnabled) {
+ chrome::search::EnableInstantExtendedAPIForTesting();
+ AddTab(browser(), GURL("chrome://blank"));
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kInstantNTPTestCases); ++i) {
+ NavigateAndCommitActiveTab(GURL(kInstantNTPTestCases[i].url));
+ const content::WebContents* contents =
+ browser()->tab_strip_model()->GetWebContentsAt(0);
+ EXPECT_EQ(kInstantNTPTestCases[i].expected_result, IsInstantNTP(contents))
+ << kInstantNTPTestCases[i].description << ": "
+ << kInstantNTPTestCases[i].url;
+ }
+}
+
+TEST_F(InstantNTPTest, InstantExtendedDisabled) {
+ AddTab(browser(), GURL("chrome://blank"));
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kInstantNTPTestCases); ++i) {
+ NavigateAndCommitActiveTab(GURL(kInstantNTPTestCases[i].url));
+ const content::WebContents* contents =
+ browser()->tab_strip_model()->GetWebContentsAt(0);
+ EXPECT_FALSE(IsInstantNTP(contents))
+ << kInstantNTPTestCases[i].description << ": "
+ << kInstantNTPTestCases[i].url;
+ }
+}
+
+TEST_F(InstantNTPTest, CustomNavigationEntry) {
+ chrome::search::EnableInstantExtendedAPIForTesting();
+ AddTab(browser(), GURL("chrome://blank"));
+ for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kInstantNTPTestCases); ++i) {
+ NavigateAndCommitActiveTab(GURL(kInstantNTPTestCases[i].url));
+ content::WebContents* contents =
+ browser()->tab_strip_model()->GetWebContentsAt(0);
+ content::NavigationController& controller = contents->GetController();
+ controller.SetTransientEntry(
+ controller.CreateNavigationEntry(GURL("chrome://blank"),
+ content::Referrer(),
+ content::PAGE_TRANSITION_LINK,
+ false,
+ std::string(),
+ contents->GetBrowserContext()));
+ // The active entry is chrome://blank and not an NTP.
+ ASSERT_FALSE(IsInstantNTP(contents));
+ EXPECT_EQ(kInstantNTPTestCases[i].expected_result,
+ NavEntryIsInstantNTP(contents,
+ controller.GetLastCommittedEntry()))
+ << kInstantNTPTestCases[i].description << ": "
+ << kInstantNTPTestCases[i].url;
+ }
+}
+
} // namespace search
} // namespace chrome
diff --git a/chrome/browser/ui/toolbar/toolbar_model_impl.cc b/chrome/browser/ui/toolbar/toolbar_model_impl.cc
index 37b47c4..f56406f 100644
--- a/chrome/browser/ui/toolbar/toolbar_model_impl.cc
+++ b/chrome/browser/ui/toolbar/toolbar_model_impl.cc
@@ -151,7 +151,7 @@ bool ToolbarModelImpl::ShouldDisplayURL() const {
return false;
#endif
- if (entry && entry->GetVirtualURL() == GURL(chrome::kChromeUINewTabURL))
+ if (chrome::search::IsInstantNTP(web_contents))
return false;
return true;
diff --git a/chrome/test/data/instant_extended.html b/chrome/test/data/instant_extended.html
index 1e9ce07..4d7ca55 100644
--- a/chrome/test/data/instant_extended.html
+++ b/chrome/test/data/instant_extended.html
@@ -37,8 +37,7 @@ function handleNativeSuggestions() {
}
function handleSubmit() {
- // Currently a NOOP in this testing framework, but needs to be defined
- // so Chrome can correctly determine Instant support for the page.
+ location.hash = 'q=' + encodeURIComponent(apiHandle.value);
}
function handleOnChange() {