| Index: chrome/browser/instant/instant_extended_browsertest.cc
 | 
| diff --git a/chrome/browser/instant/instant_extended_browsertest.cc b/chrome/browser/instant/instant_extended_browsertest.cc
 | 
| index ffb582022e75c81920381217b018e493e7cbe924..bbb3f36f6a83b8864b412c1f927da0fdd7300103 100644
 | 
| --- a/chrome/browser/instant/instant_extended_browsertest.cc
 | 
| +++ b/chrome/browser/instant/instant_extended_browsertest.cc
 | 
| @@ -5,7 +5,11 @@
 | 
|  #include <sstream>
 | 
|  
 | 
|  #include "base/prefs/pref_service.h"
 | 
| +#include "chrome/browser/extensions/extension_browsertest.h"
 | 
| +#include "chrome/browser/extensions/extension_service.h"
 | 
|  #include "chrome/browser/favicon/favicon_tab_helper.h"
 | 
| +#include "chrome/browser/history/history_types.h"
 | 
| +#include "chrome/browser/history/top_sites.h"
 | 
|  #include "chrome/browser/instant/instant_commit_type.h"
 | 
|  #include "chrome/browser/instant/instant_ntp.h"
 | 
|  #include "chrome/browser/instant/instant_overlay.h"
 | 
| @@ -14,21 +18,45 @@
 | 
|  #include "chrome/browser/instant/instant_tab.h"
 | 
|  #include "chrome/browser/instant/instant_test_utils.h"
 | 
|  #include "chrome/browser/profiles/profile.h"
 | 
| +#include "chrome/browser/themes/theme_service.h"
 | 
| +#include "chrome/browser/themes/theme_service_factory.h"
 | 
| +#include "chrome/browser/ui/omnibox/omnibox_view.h"
 | 
|  #include "chrome/browser/ui/search/search.h"
 | 
|  #include "chrome/browser/ui/tabs/tab_strip_model.h"
 | 
| +#include "chrome/browser/ui/webui/theme_source.h"
 | 
|  #include "chrome/common/chrome_notification_types.h"
 | 
|  #include "chrome/common/pref_names.h"
 | 
| +#include "chrome/common/thumbnail_score.h"
 | 
|  #include "chrome/common/url_constants.h"
 | 
| +#include "chrome/test/base/in_process_browser_test.h"
 | 
|  #include "chrome/test/base/interactive_test_utils.h"
 | 
|  #include "chrome/test/base/ui_test_utils.h"
 | 
|  #include "content/public/browser/notification_service.h"
 | 
|  #include "content/public/browser/render_process_host.h"
 | 
| +#include "content/public/browser/render_view_host.h"
 | 
|  #include "content/public/browser/site_instance.h"
 | 
| +#include "content/public/browser/url_data_source.h"
 | 
|  #include "content/public/browser/web_contents.h"
 | 
|  #include "content/public/browser/web_contents_view.h"
 | 
| +#include "content/public/common/bindings_policy.h"
 | 
|  #include "content/public/test/browser_test_utils.h"
 | 
| +#include "third_party/skia/include/core/SkBitmap.h"
 | 
|  
 | 
| -class InstantExtendedTest : public InstantTestBase {
 | 
| +namespace {
 | 
| +
 | 
| +// Creates a bitmap of the specified color. Caller takes ownership.
 | 
| +gfx::Image CreateBitmap(SkColor color) {
 | 
| +  SkBitmap thumbnail;
 | 
| +  thumbnail.setConfig(SkBitmap::kARGB_8888_Config, 4, 4);
 | 
| +  thumbnail.allocPixels();
 | 
| +  thumbnail.eraseColor(color);
 | 
| +  return gfx::Image::CreateFrom1xBitmap(thumbnail);  // adds ref.
 | 
| +}
 | 
| +
 | 
| +}  // namespace
 | 
| +
 | 
| +class InstantExtendedTest : public InProcessBrowserTest,
 | 
| +                            public InstantTestBase {
 | 
|   public:
 | 
|    InstantExtendedTest()
 | 
|        : on_most_visited_change_calls_(0),
 | 
| @@ -38,21 +66,10 @@ class InstantExtendedTest : public InstantTestBase {
 | 
|   protected:
 | 
|    virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
 | 
|      chrome::search::EnableInstantExtendedAPIForTesting();
 | 
| -    ASSERT_TRUE(https_test_server_.Start());
 | 
| -    instant_url_ = https_test_server_.
 | 
| -        GetURL("files/instant_extended.html?strk=1&");
 | 
| -  }
 | 
| -
 | 
| -  void FocusOmniboxAndWaitForInstantSupport() {
 | 
| -    content::WindowedNotificationObserver ntp_observer(
 | 
| -        chrome::NOTIFICATION_INSTANT_NTP_SUPPORT_DETERMINED,
 | 
| -        content::NotificationService::AllSources());
 | 
| -    content::WindowedNotificationObserver overlay_observer(
 | 
| -        chrome::NOTIFICATION_INSTANT_OVERLAY_SUPPORT_DETERMINED,
 | 
| -        content::NotificationService::AllSources());
 | 
| -    FocusOmnibox();
 | 
| -    ntp_observer.Wait();
 | 
| -    overlay_observer.Wait();
 | 
| +    ASSERT_TRUE(https_test_server().Start());
 | 
| +    GURL instant_url = https_test_server().GetURL(
 | 
| +        "files/instant_extended.html?strk=1&");
 | 
| +    InstantTestBase::Init(instant_url);
 | 
|    }
 | 
|  
 | 
|    std::string GetOmniboxText() {
 | 
| @@ -91,14 +108,51 @@ class InstantExtendedTest : public InstantTestBase {
 | 
|    int first_most_visited_item_id_;
 | 
|  };
 | 
|  
 | 
| +// Test class used to verify chrome-search: scheme and access policy from the
 | 
| +// Instant overlay.  This is a subclass of |ExtensionBrowserTest| because it
 | 
| +// loads a theme that provides a background image.
 | 
| +class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase {
 | 
| + public:
 | 
| +  InstantPolicyTest() {}
 | 
| +
 | 
| + protected:
 | 
| +  virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
 | 
| +    chrome::search::EnableInstantExtendedAPIForTesting();
 | 
| +    ASSERT_TRUE(https_test_server().Start());
 | 
| +    GURL instant_url = https_test_server().GetURL(
 | 
| +        "files/instant_extended.html?strk=1&");
 | 
| +    InstantTestBase::Init(instant_url);
 | 
| +  }
 | 
| +
 | 
| +  void InstallThemeSource() {
 | 
| +    ThemeSource* theme = new ThemeSource(profile());
 | 
| +    content::URLDataSource::Add(profile(), theme);
 | 
| +  }
 | 
| +
 | 
| +  void InstallThemeAndVerify(const std::string& theme_dir,
 | 
| +                             const std::string& theme_name) {
 | 
| +    const base::FilePath theme_path = test_data_dir_.AppendASCII(theme_dir);
 | 
| +    ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(
 | 
| +        theme_path, 1, ExtensionBrowserTest::browser()));
 | 
| +    const extensions::Extension* theme =
 | 
| +        ThemeServiceFactory::GetThemeForProfile(
 | 
| +            ExtensionBrowserTest::browser()->profile());
 | 
| +    ASSERT_NE(static_cast<extensions::Extension*>(NULL), theme);
 | 
| +    ASSERT_EQ(theme->name(), theme_name);
 | 
| +  }
 | 
| +
 | 
| + private:
 | 
| +  DISALLOW_COPY_AND_ASSIGN(InstantPolicyTest);
 | 
| +};
 | 
| +
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ExtendedModeIsOn) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
|    EXPECT_TRUE(instant()->extended_enabled_);
 | 
|  }
 | 
|  
 | 
|  // Test that Instant is preloaded when the omnibox is focused.
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
|  
 | 
|    // Explicitly unfocus the omnibox.
 | 
|    EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
 | 
| @@ -112,7 +166,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) {
 | 
|    EXPECT_FALSE(instant()->GetOverlayContents());
 | 
|  
 | 
|    // Refocus the omnibox. The InstantController should've preloaded Instant.
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    EXPECT_FALSE(ui_test_utils::IsViewFocused(browser(), VIEW_ID_TAB_CONTAINER));
 | 
|    EXPECT_TRUE(omnibox()->model()->has_focus());
 | 
| @@ -140,10 +194,10 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxFocusLoadsInstant) {
 | 
|  }
 | 
|  
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
|  
 | 
|    // Focus omnibox and confirm overlay isn't shown.
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|    content::WebContents* overlay = instant()->GetOverlayContents();
 | 
|    EXPECT_TRUE(overlay);
 | 
|    EXPECT_FALSE(instant()->IsOverlayingSearchResults());
 | 
| @@ -158,8 +212,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputShowsOverlay) {
 | 
|  // Test that middle clicking on a suggestion opens the result in a new tab.
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
 | 
|                         MiddleClickOnSuggestionOpensInNewTab) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|    EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
 | 
|  
 | 
|    EXPECT_EQ(1, browser()->tab_strip_model()->count());
 | 
| @@ -195,10 +249,9 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
 | 
|  }
 | 
|  
 | 
|  // Test that omnibox text is correctly set when overlay is committed with Enter.
 | 
| -IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
 | 
| -                       OmniboxTextUponEnterCommit) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponEnterCommit) {
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // The page will autocomplete once we set the omnibox value.
 | 
|    EXPECT_TRUE(ExecuteScript("suggestion = 'santa claus';"));
 | 
| @@ -221,10 +274,9 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
 | 
|  }
 | 
|  
 | 
|  // Test that omnibox text is correctly set when committed with focus lost.
 | 
| -IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
 | 
| -                       OmniboxTextUponFocusLostCommit) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxTextUponFocusLostCommit) {
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // Set autocomplete text (grey text).
 | 
|    EXPECT_TRUE(ExecuteScript("suggestion = 'johnny depp';"));
 | 
| @@ -258,8 +310,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
 | 
|                         MAYBE_OmniboxTextUponFocusedCommittedSERP) {
 | 
|    // Setup Instant.
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // Do a search and commit it.
 | 
|    SetOmniboxTextAndWaitForOverlayToShow("hello k");
 | 
| @@ -286,8 +338,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
 | 
|  // This test simulates a search provider using the InstantExtended API to
 | 
|  // navigate through the suggested results and back to the original user query.
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    SetOmniboxTextAndWaitForOverlayToShow("hello");
 | 
|    EXPECT_EQ("hello", GetOmniboxText());
 | 
| @@ -324,8 +376,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsWithArrowKeys) {
 | 
|  // navigate through the suggested results and hitting escape to get back to the
 | 
|  // original user query.
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    SetOmniboxTextAndWaitForOverlayToShow("hello");
 | 
|    EXPECT_EQ("hello", GetOmniboxText());
 | 
| @@ -356,8 +408,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NavigateSuggestionsAndHitEscape) {
 | 
|  
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NTPIsPreloaded) {
 | 
|    // Setup Instant.
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // NTP contents should be preloaded.
 | 
|    ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp());
 | 
| @@ -367,8 +419,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NTPIsPreloaded) {
 | 
|  
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInNewTab) {
 | 
|    // Setup Instant.
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // NTP contents should be preloaded.
 | 
|    ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp());
 | 
| @@ -389,8 +441,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInNewTab) {
 | 
|  
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInSameTab) {
 | 
|    // Setup Instant.
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // NTP contents should be preloaded.
 | 
|    ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp());
 | 
| @@ -411,8 +463,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, PreloadedNTPIsUsedInSameTab) {
 | 
|  
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxHasFocusOnNewTab) {
 | 
|    // Setup Instant.
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // Explicitly unfocus the omnibox.
 | 
|    EXPECT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser()));
 | 
| @@ -432,8 +484,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxHasFocusOnNewTab) {
 | 
|  
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxEmptyOnNewTabPage) {
 | 
|    // Setup Instant.
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // Open new tab. Preloaded NTP contents should have been used.
 | 
|    ui_test_utils::NavigateToURLWithDisposition(
 | 
| @@ -446,10 +498,11 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, OmniboxEmptyOnNewTabPage) {
 | 
|    EXPECT_TRUE(omnibox()->GetText().empty());
 | 
|  }
 | 
|  
 | 
| -IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoFaviconOnNewTabPage) {
 | 
| +// TODO(dhollowa): Fix flakes.  http://crbug.com/179930.
 | 
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_NoFaviconOnNewTabPage) {
 | 
|    // Setup Instant.
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // Open new tab. Preloaded NTP contents should have been used.
 | 
|    ui_test_utils::NavigateToURLWithDisposition(
 | 
| @@ -473,10 +526,10 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoFaviconOnNewTabPage) {
 | 
|  }
 | 
|  
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, InputOnNTPDoesntShowOverlay) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
|  
 | 
|    // Focus omnibox and confirm overlay isn't shown.
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|    content::WebContents* overlay = instant()->GetOverlayContents();
 | 
|    EXPECT_TRUE(overlay);
 | 
|    EXPECT_FALSE(instant()->IsOverlayingSearchResults());
 | 
| @@ -506,8 +559,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ProcessIsolation) {
 | 
|    EXPECT_EQ(1, instant_service->GetInstantProcessCount());
 | 
|  
 | 
|    // Setup Instant.
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // The registered Instant render process should still exist.
 | 
|    EXPECT_EQ(1, instant_service->GetInstantProcessCount());
 | 
| @@ -543,8 +596,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ProcessIsolation) {
 | 
|  // Flaky: http://crbug.com/177516
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) {
 | 
|    // Setup Instant.
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // Check that the uncommited ntp page and uncommited overlay have unrelated
 | 
|    // site instances.
 | 
| @@ -588,8 +641,8 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_UnrelatedSiteInstance) {
 | 
|  
 | 
|  // Tests that suggestions are sanity checked.
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ValidatesSuggestions) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // Do not set gray text that is not a suffix of the query.
 | 
|    EXPECT_TRUE(ExecuteScript("behavior = 2"));
 | 
| @@ -641,13 +694,14 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, ValidatesSuggestions) {
 | 
|    EXPECT_EQ(ASCIIToUTF16("www.example.com/"), omnibox()->GetText());
 | 
|  }
 | 
|  
 | 
| -IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MostVisited) {
 | 
| +// TODO(dhollowa): Fix flakes.  http://crbug.com/179930.
 | 
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_MostVisited) {
 | 
|    content::WindowedNotificationObserver observer(
 | 
|        chrome::NOTIFICATION_INSTANT_SENT_MOST_VISITED_ITEMS,
 | 
|        content::NotificationService::AllSources());
 | 
|    // Initialize Instant.
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|  
 | 
|    // Get a handle to the NTP and the current state of the JS.
 | 
|    ASSERT_NE(static_cast<InstantNTP*>(NULL), instant()->ntp());
 | 
| @@ -731,6 +785,120 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MostVisited) {
 | 
|    EXPECT_EQ(most_visited_items_count_, old_most_visited_items_count);
 | 
|  }
 | 
|  
 | 
| +IN_PROC_BROWSER_TEST_F(InstantPolicyTest, ThemeBackgroundAccess) {
 | 
| +  InstallThemeSource();
 | 
| +  ASSERT_NO_FATAL_FAILURE(InstallThemeAndVerify("theme", "camo theme"));
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
| +
 | 
| +  // The "Instant" New Tab should have access to chrome-search: scheme but not
 | 
| +  // chrome: scheme.
 | 
| +  ui_test_utils::NavigateToURLWithDisposition(
 | 
| +      browser(),
 | 
| +      GURL(chrome::kChromeUINewTabURL),
 | 
| +      NEW_FOREGROUND_TAB,
 | 
| +      ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
 | 
| +
 | 
| +  content::RenderViewHost* rvh =
 | 
| +      browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost();
 | 
| +
 | 
| +  const std::string chrome_url("chrome://theme/IDR_THEME_NTP_BACKGROUND");
 | 
| +  const std::string search_url(
 | 
| +      "chrome-search://theme/IDR_THEME_NTP_BACKGROUND");
 | 
| +  bool loaded = false;
 | 
| +  ASSERT_TRUE(LoadImage(rvh, chrome_url, &loaded));
 | 
| +  EXPECT_FALSE(loaded) << chrome_url;
 | 
| +  ASSERT_TRUE(LoadImage(rvh, search_url, &loaded));
 | 
| +  EXPECT_TRUE(loaded) << search_url;
 | 
| +}
 | 
| +
 | 
| +// TODO(dhollowa): Fix flakes.  http://crbug.com/179930.
 | 
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, DISABLED_FaviconAccess) {
 | 
| +  // Create a favicon.
 | 
| +  history::TopSites* top_sites = browser()->profile()->GetTopSites();
 | 
| +  GURL url("http://www.google.com/foo.html");
 | 
| +  gfx::Image thumbnail(CreateBitmap(SK_ColorWHITE));
 | 
| +  ThumbnailScore high_score(0.0, true, true, base::Time::Now());
 | 
| +  EXPECT_TRUE(top_sites->SetPageThumbnail(url, thumbnail, high_score));
 | 
| +
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
| +
 | 
| +  // The "Instant" New Tab should have access to chrome-search: scheme but not
 | 
| +  // chrome: scheme.
 | 
| +  ui_test_utils::NavigateToURLWithDisposition(
 | 
| +      browser(),
 | 
| +      GURL(chrome::kChromeUINewTabURL),
 | 
| +      NEW_FOREGROUND_TAB,
 | 
| +      ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
 | 
| +
 | 
| +  content::RenderViewHost* rvh =
 | 
| +      browser()->tab_strip_model()->GetActiveWebContents()->GetRenderViewHost();
 | 
| +
 | 
| +  // Get the favicons.
 | 
| +  const std::string chrome_favicon_url(
 | 
| +      "chrome://favicon/largest/http://www.google.com/foo.html");
 | 
| +  const std::string search_favicon_url(
 | 
| +      "chrome-search://favicon/largest/http://www.google.com/foo.html");
 | 
| +  bool loaded = false;
 | 
| +  ASSERT_TRUE(LoadImage(rvh, chrome_favicon_url, &loaded));
 | 
| +  EXPECT_FALSE(loaded) << chrome_favicon_url;
 | 
| +  ASSERT_TRUE(LoadImage(rvh, search_favicon_url, &loaded));
 | 
| +  EXPECT_TRUE(loaded) << search_favicon_url;
 | 
| +}
 | 
| +
 | 
| +// WebUIBindings should never be enabled on ANY Instant web contents.
 | 
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnNTP) {
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
| +
 | 
| +  ui_test_utils::NavigateToURLWithDisposition(
 | 
| +      browser(),
 | 
| +      GURL(chrome::kChromeUINewTabURL),
 | 
| +      NEW_FOREGROUND_TAB,
 | 
| +      ui_test_utils::BROWSER_TEST_WAIT_FOR_TAB);
 | 
| +  const content::WebContents* tab =
 | 
| +      browser()->tab_strip_model()->GetActiveWebContents();
 | 
| +
 | 
| +  // Instant-provided NTP should not have any bindings enabled.
 | 
| +  EXPECT_EQ(0, tab->GetRenderViewHost()->GetEnabledBindings());
 | 
| +}
 | 
| +
 | 
| +// WebUIBindings should never be enabled on ANY Instant web contents.
 | 
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnPreview) {
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
| +
 | 
| +  // Typing in the omnibox shows the overlay.
 | 
| +  SetOmniboxTextAndWaitForOverlayToShow("query");
 | 
| +  EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
 | 
| +  content::WebContents* preview = instant()->GetOverlayContents();
 | 
| +  ASSERT_NE(static_cast<content::WebContents*>(NULL), preview);
 | 
| +
 | 
| +  // Instant preview should not have any bindings enabled.
 | 
| +  EXPECT_EQ(0, preview->GetRenderViewHost()->GetEnabledBindings());
 | 
| +}
 | 
| +
 | 
| +// WebUIBindings should never be enabled on ANY Instant web contents.
 | 
| +IN_PROC_BROWSER_TEST_F(InstantExtendedTest, NoWebUIBindingsOnResults) {
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
| +
 | 
| +  // Typing in the omnibox shows the overlay.
 | 
| +  SetOmniboxTextAndWaitForOverlayToShow("query");
 | 
| +  content::WebContents* preview = instant()->GetOverlayContents();
 | 
| +  EXPECT_TRUE(instant()->model()->mode().is_search_suggestions());
 | 
| +  // Commit the search by pressing Enter.
 | 
| +  browser()->window()->GetLocationBar()->AcceptInput();
 | 
| +  EXPECT_TRUE(instant()->model()->mode().is_default());
 | 
| +  const content::WebContents* tab =
 | 
| +      browser()->tab_strip_model()->GetActiveWebContents();
 | 
| +  EXPECT_EQ(preview, tab);
 | 
| +
 | 
| +  // The commited Instant page should not have any bindings enabled.
 | 
| +  EXPECT_EQ(0, tab->GetRenderViewHost()->GetEnabledBindings());
 | 
| +}
 | 
| +
 | 
|  // Only implemented in Views and Mac currently: http://crbug.com/164723
 | 
|  #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX)
 | 
|  #define MAYBE_HomeButtonAffectsMargin HomeButtonAffectsMargin
 | 
| @@ -740,7 +908,7 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MostVisited) {
 | 
|  // Check that toggling the state of the home button changes the start-edge
 | 
|  // margin and width.
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MAYBE_HomeButtonAffectsMargin) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
|  
 | 
|    // Get the current value of the start-edge margin and width.
 | 
|    int start_margin;
 | 
| @@ -777,10 +945,10 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest, MAYBE_HomeButtonAffectsMargin) {
 | 
|  // shown at 100% height.
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
 | 
|                         MAYBE_CommitWhenFocusLostInFullHeight) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
|  
 | 
|    // Focus omnibox and confirm overlay isn't shown.
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|    content::WebContents* overlay = instant()->GetOverlayContents();
 | 
|    EXPECT_TRUE(overlay);
 | 
|    EXPECT_TRUE(instant()->model()->mode().is_default());
 | 
| @@ -807,10 +975,10 @@ IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
 | 
|  // in the omnibox.
 | 
|  IN_PROC_BROWSER_TEST_F(InstantExtendedTest,
 | 
|                         CommitWhenShownInFullHeightWithoutFocus) {
 | 
| -  ASSERT_NO_FATAL_FAILURE(SetupInstant());
 | 
| +  ASSERT_NO_FATAL_FAILURE(SetupInstant(browser()));
 | 
|  
 | 
|    // Focus omnibox and confirm overlay isn't shown.
 | 
| -  FocusOmniboxAndWaitForInstantSupport();
 | 
| +  FocusOmniboxAndWaitForInstantExtendedSupport();
 | 
|    content::WebContents* overlay = instant()->GetOverlayContents();
 | 
|    EXPECT_TRUE(overlay);
 | 
|    EXPECT_TRUE(instant()->model()->mode().is_default());
 | 
| 
 |