summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-18 03:22:50 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-18 03:22:50 +0000
commite4e15dca9f700cf5f0e9ff708622ff0cebe94100 (patch)
tree34c1e4ffc83ea2144a1b36477c8845ce7bb3b79b
parentb35c81cc0bd12bc4182105b40f8e2702ab684ea8 (diff)
downloadchromium_src-e4e15dca9f700cf5f0e9ff708622ff0cebe94100.zip
chromium_src-e4e15dca9f700cf5f0e9ff708622ff0cebe94100.tar.gz
chromium_src-e4e15dca9f700cf5f0e9ff708622ff0cebe94100.tar.bz2
Refactor Instant to separate out preview control
Separates out Show/Hide logic into a separate |InstantPreviewController| class. This class follows an observer pattern, observing the |InstantModel| changes. The model is held by the |InstantController|. The goal with this is to pave the way for future changes that will expand the complexity of the "view" logic, especially in the area of coordinating the animations used with --enable-instant-extended-api features. BUG=142785 TEST=No functional change. Refactoring only. R=sreeram@chromium.org, jered@chromium.org, samarth@chromium.org Review URL: https://chromiumcodereview.appspot.com/11144004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@162633 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/instant/instant_browsertest.cc80
-rw-r--r--chrome/browser/instant/instant_controller.cc36
-rw-r--r--chrome/browser/instant/instant_controller.h18
-rw-r--r--chrome/browser/instant/instant_controller_delegate.h6
-rw-r--r--chrome/browser/instant/instant_model.cc61
-rw-r--r--chrome/browser/instant/instant_model.h69
-rw-r--r--chrome/browser/instant/instant_model_observer.h24
-rw-r--r--chrome/browser/instant/instant_preview_controller.cc39
-rw-r--r--chrome/browser/instant/instant_preview_controller.h42
-rw-r--r--chrome/browser/ui/browser_instant_controller.cc15
-rw-r--r--chrome/browser/ui/browser_instant_controller.h2
-rw-r--r--chrome/browser/ui/browser_window.h8
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.h4
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.mm12
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller.h2
-rw-r--r--chrome/browser/ui/cocoa/browser_window_controller.mm18
-rw-r--r--chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.h39
-rw-r--r--chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.mm36
-rw-r--r--chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h13
-rw-r--r--chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm11
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc64
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.h14
-rw-r--r--chrome/browser/ui/gtk/instant_preview_controller_gtk.cc45
-rw-r--r--chrome/browser/ui/gtk/instant_preview_controller_gtk.h41
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc44
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h29
-rw-r--r--chrome/browser/ui/views/frame/instant_preview_controller_views.cc61
-rw-r--r--chrome/browser/ui/views/frame/instant_preview_controller_views.h59
-rw-r--r--chrome/chrome_browser.gypi5
-rw-r--r--chrome/chrome_browser_ui.gypi6
-rw-r--r--chrome/common/chrome_notification_types.h10
-rw-r--r--chrome/test/base/test_browser_window.h4
32 files changed, 698 insertions, 219 deletions
diff --git a/chrome/browser/instant/instant_browsertest.cc b/chrome/browser/instant/instant_browsertest.cc
index 5ee0d48..97d0c3b 100644
--- a/chrome/browser/instant/instant_browsertest.cc
+++ b/chrome/browser/instant/instant_browsertest.cc
@@ -7,6 +7,8 @@
#include "chrome/browser/history/history_service_factory.h"
#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/instant/instant_loader.h"
+#include "chrome/browser/instant/instant_model.h"
+#include "chrome/browser/instant/instant_model_observer.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
@@ -29,6 +31,32 @@
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
+class InstantTestModelObserver : public InstantModelObserver {
+ public:
+ explicit InstantTestModelObserver(const InstantModel* model) : model_(model) {
+ model_->AddObserver(this);
+ }
+
+ ~InstantTestModelObserver() {
+ model_->RemoveObserver(this);
+ }
+
+ void WaitUntilDisplayStateChanged() {
+ run_loop_.Run();
+ }
+
+ // InstantModelObserver overrides:
+ virtual void DisplayStateChanged(const InstantModel& model) OVERRIDE {
+ run_loop_.Quit();
+ }
+
+ private:
+ const InstantModel* const model_;
+ base::RunLoop run_loop_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(InstantTestModelObserver);
+};
+
class InstantTest : public InProcessBrowserTest {
protected:
void SetupInstant(const std::string& page) {
@@ -83,11 +111,9 @@ class InstantTest : public InProcessBrowserTest {
}
void SetOmniboxTextAndWaitForInstantToShow(const std::string& text) {
- content::WindowedNotificationObserver observer(
- chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN,
- content::NotificationService::AllSources());
+ InstantTestModelObserver observer(instant()->model());
SetOmniboxText(text);
- observer.Wait();
+ observer.WaitUntilDisplayStateChanged();
}
std::wstring WrapScript(const std::string& script) const {
@@ -182,7 +208,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, OmniboxFocusLoadsInstant) {
// Check that the page supports Instant, but it isn't showing.
EXPECT_TRUE(instant()->loader()->supports_instant());
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
// Adding a new tab shouldn't delete or recreate the TabContents; otherwise,
// what's the point of preloading?
@@ -200,7 +226,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, OmniboxFocusLoadsInstant) {
// Doing a search should also use the same preloaded page.
SetOmniboxTextAndWaitForInstantToShow("query");
- EXPECT_TRUE(instant()->is_showing());
+ EXPECT_TRUE(instant()->model()->is_ready());
EXPECT_EQ(preview_tab, instant()->GetPreviewContents());
}
@@ -254,7 +280,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, OnSubmitEvent) {
// After the commit, Instant should not be showing.
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
// The old loader is deleted and a new one is created.
EXPECT_TRUE(instant()->GetPreviewContents());
@@ -314,7 +340,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, OnCancelEvent) {
// After the commit, Instant should not be showing.
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
// The old loader is deleted and a new one is created.
EXPECT_TRUE(instant()->GetPreviewContents());
@@ -538,15 +564,15 @@ IN_PROC_BROWSER_TEST_F(InstantTest, RejectsURLs) {
// Instant doesn't try to process them.
SetOmniboxText(chrome::kChromeUICrashURL);
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
SetOmniboxText(chrome::kChromeUIHangURL);
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
SetOmniboxText(chrome::kChromeUIKillURL);
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
// Make sure that the URLs were never sent to the preview page.
EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents()));
@@ -581,7 +607,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, TransitionsBetweenSearchAndURL) {
// place to indicate that the search is "out of date".
EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents()));
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
EXPECT_EQ(2, onchangecalls_);
EXPECT_EQ("", value_);
@@ -589,7 +615,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, TransitionsBetweenSearchAndURL) {
SetOmniboxTextAndWaitForInstantToShow("search");
EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents()));
EXPECT_TRUE(instant()->IsCurrent());
- EXPECT_TRUE(instant()->is_showing());
+ EXPECT_TRUE(instant()->model()->is_ready());
EXPECT_EQ(3, onchangecalls_);
EXPECT_EQ("search", value_);
@@ -597,7 +623,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, TransitionsBetweenSearchAndURL) {
SetOmniboxText("http://terrible/terror");
EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents()));
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
EXPECT_EQ(4, onchangecalls_);
EXPECT_EQ("", value_);
@@ -605,7 +631,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, TransitionsBetweenSearchAndURL) {
SetOmniboxTextAndWaitForInstantToShow("search");
EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents()));
EXPECT_TRUE(instant()->IsCurrent());
- EXPECT_TRUE(instant()->is_showing());
+ EXPECT_TRUE(instant()->model()->is_ready());
EXPECT_EQ(5, onchangecalls_);
EXPECT_EQ("search", value_);
@@ -613,7 +639,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, TransitionsBetweenSearchAndURL) {
omnibox()->RevertAll();
EXPECT_TRUE(UpdateSearchState(instant()->GetPreviewContents()));
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
EXPECT_EQ(6, onchangecalls_);
EXPECT_EQ("", value_);
}
@@ -626,7 +652,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, DoesNotCommitURLsOne) {
// Type a URL. The Instant preview shouldn't be showing.
SetOmniboxText("http://deadly/nadder");
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
// Unfocus and refocus the omnibox.
ui_test_utils::ClickOnView(browser(), VIEW_ID_TAB_CONTAINER);
@@ -639,7 +665,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, DoesNotCommitURLsOne) {
// The omnibox text hasn't changed, so Instant still shouldn't be showing.
EXPECT_EQ(ASCIIToUTF16("http://deadly/nadder"), omnibox()->GetText());
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
// Commit the URL. The omnibox should reflect the URL minus the scheme.
browser()->window()->GetLocationBar()->AcceptInput();
@@ -650,7 +676,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, DoesNotCommitURLsOne) {
// Instant shouldn't have done anything.
EXPECT_EQ(preview_tab, instant()->GetPreviewContents());
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
}
// Test that Instant can't be fooled into committing a URL.
@@ -667,7 +693,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, DoesNotCommitURLsTwo) {
// Type a URL. This causes the preview to be hidden.
SetOmniboxText("http://hideous/zippleback");
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
// Pretend the omnibox got focus. It already had focus, so we are just trying
// to tickle a different code path.
@@ -682,7 +708,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, DoesNotCommitURLsTwo) {
// As before, Instant shouldn't have done anything.
EXPECT_EQ(preview_tab, instant()->GetPreviewContents());
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
}
// Test that a non-Instant search provider shows no previews.
@@ -851,19 +877,17 @@ IN_PROC_BROWSER_TEST_F(InstantTest, NewWindowDismissesInstant) {
Browser* previous_window = browser();
EXPECT_TRUE(instant()->IsCurrent());
- EXPECT_TRUE(instant()->is_showing());
+ EXPECT_TRUE(instant()->model()->is_ready());
- content::WindowedNotificationObserver instant_hidden_observer(
- chrome::NOTIFICATION_INSTANT_CONTROLLER_HIDDEN,
- content::NotificationService::AllSources());
+ InstantTestModelObserver observer(instant()->model());
chrome::NewEmptyWindow(browser()->profile());
- instant_hidden_observer.Wait();
+ observer.WaitUntilDisplayStateChanged();
// Even though we just created a new Browser object (for the new window), the
// browser() accessor should still give us the first window's Browser object.
EXPECT_EQ(previous_window, browser());
EXPECT_FALSE(instant()->IsCurrent());
- EXPECT_FALSE(instant()->is_showing());
+ EXPECT_FALSE(instant()->model()->is_ready());
}
// Test that:
@@ -885,7 +909,7 @@ IN_PROC_BROWSER_TEST_F(InstantTest, InstantLoaderRefresh) {
// Instant is showing, so OnStaleLoader() shouldn't kill the preview.
instant()->stale_loader_timer_.Stop();
instant()->OnStaleLoader();
- EXPECT_TRUE(instant()->is_showing());
+ EXPECT_TRUE(instant()->model()->is_ready());
// The preview should be recreated once the omnibox loses focus.
EXPECT_TRUE(instant()->loader()->supports_instant());
diff --git a/chrome/browser/instant/instant_controller.cc b/chrome/browser/instant/instant_controller.cc
index 385fe87..662b8d2 100644
--- a/chrome/browser/instant/instant_controller.cc
+++ b/chrome/browser/instant/instant_controller.cc
@@ -305,15 +305,8 @@ TabContents* InstantController::GetPreviewContents() const {
void InstantController::Hide() {
last_active_tab_ = NULL;
- if (is_showing_) {
- is_showing_ = false;
- delegate_->HideInstant();
+ model_.SetDisplayState(InstantModel::NOT_READY, 0, INSTANT_SIZE_PERCENT);
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_INSTANT_CONTROLLER_HIDDEN,
- content::Source<InstantController>(this),
- content::NotificationService::NoDetails());
- }
if (GetPreviewContents() && !last_full_text_.empty()) {
// Send a blank query to ask the preview to clear out old results.
last_full_text_.clear();
@@ -434,7 +427,7 @@ void InstantController::OnAutocompleteLostFocus(
loader_->OnAutocompleteLostFocus();
// If the preview is not showing, only need to check for loader staleness.
- if (!is_showing_) {
+ if (!model_.is_ready()) {
MaybeOnStaleLoader();
return;
}
@@ -580,7 +573,7 @@ void InstantController::SetSuggestions(
}
void InstantController::CommitInstantLoader(InstantLoader* loader) {
- if (loader_ != loader || !is_showing_ || IsOutOfDate())
+ if (loader_ != loader || !model_.is_ready() || IsOutOfDate())
return;
CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST);
@@ -626,15 +619,15 @@ void InstantController::InstantSupportDetermined(InstantLoader* loader,
}
void InstantController::SwappedTabContents(InstantLoader* loader) {
- if (loader_ == loader && is_showing_)
- delegate_->ShowInstant(100, INSTANT_SIZE_PERCENT);
+ if (loader_ == loader)
+ model_.SetPreviewContents(GetPreviewContents());
}
void InstantController::InstantLoaderContentsFocused(InstantLoader* loader) {
#if defined(USE_AURA)
// On aura the omnibox only receives a focus lost if we initiate the focus
// change. This does that.
- if (is_showing_ && !IsOutOfDate())
+ if (model_.is_ready() && !IsOutOfDate())
delegate_->InstantPreviewFocused();
#endif
}
@@ -642,12 +635,12 @@ void InstantController::InstantLoaderContentsFocused(InstantLoader* loader) {
InstantController::InstantController(InstantControllerDelegate* delegate,
Mode mode)
: delegate_(delegate),
+ model_(ALLOW_THIS_IN_INITIALIZER_LIST(this)),
mode_(mode),
last_active_tab_(NULL),
last_verbatim_(false),
last_transition_type_(content::PAGE_TRANSITION_LINK),
last_match_was_search_(false),
- is_showing_(false),
loader_processed_last_update_(false),
is_omnibox_focused_(false),
active_tab_is_ntp_(false) {
@@ -700,7 +693,7 @@ bool InstantController::CreateDefaultLoader() {
void InstantController::OnStaleLoader() {
// If the loader is showing, do not delete it. It will get deleted the next
// time the autocomplete loses focus.
- if (is_showing_)
+ if (model_.is_ready())
return;
DeleteLoader();
@@ -719,7 +712,7 @@ void InstantController::DeleteLoader() {
last_verbatim_ = false;
last_suggestion_ = InstantSuggestion();
last_match_was_search_ = false;
- is_showing_ = false;
+ model_.SetDisplayState(InstantModel::NOT_READY, 0, INSTANT_SIZE_PERCENT);
loader_processed_last_update_ = false;
last_omnibox_bounds_ = gfx::Rect();
url_for_history_ = GURL();
@@ -730,16 +723,9 @@ void InstantController::DeleteLoader() {
void InstantController::Show(int height, InstantSizeUnits units) {
// Call even if showing in case height changed.
- delegate_->ShowInstant(height, units);
- if (!is_showing_) {
- is_showing_ = true;
+ if (!model_.is_ready())
AddPreviewUsageForHistogram(mode_, PREVIEW_SHOWED);
-
- content::NotificationService::current()->Notify(
- chrome::NOTIFICATION_INSTANT_CONTROLLER_SHOWN,
- content::Source<InstantController>(this),
- content::NotificationService::NoDetails());
- }
+ model_.SetDisplayState(InstantModel::QUERY_RESULTS, height, units);
}
void InstantController::SendBoundsToPage() {
diff --git a/chrome/browser/instant/instant_controller.h b/chrome/browser/instant/instant_controller.h
index 4956e04..3073a40 100644
--- a/chrome/browser/instant/instant_controller.h
+++ b/chrome/browser/instant/instant_controller.h
@@ -17,6 +17,7 @@
#include "base/timer.h"
#include "chrome/browser/instant/instant_commit_type.h"
#include "chrome/browser/instant/instant_loader_delegate.h"
+#include "chrome/browser/instant/instant_model.h"
#include "chrome/common/instant_types.h"
#include "content/public/common/page_transition_types.h"
#include "googleurl/src/gurl.h"
@@ -37,10 +38,10 @@ class TemplateURL;
// BrowserInstantController.
//
// At any time the WebContents maintained by InstantController may be hidden
-// from view by way of Hide(), which may result in HideInstant() being invoked
-// on the delegate. Similarly the preview may be committed at any time by
-// invoking CommitCurrentPreview(), which results in CommitInstant() being
-// invoked on the delegate.
+// from view by way of Hide(), which may result in a change in the model's
+// display state and subsequent change in model observers. Similarly the preview
+// may be committed at any time by invoking CommitCurrentPreview(), which
+// results in CommitInstant() being invoked on the delegate.
class InstantController : public InstantLoaderDelegate {
public:
// Amount of time to wait before starting the animation for suggested text.
@@ -169,10 +170,11 @@ class InstantController : public InstantLoaderDelegate {
#if defined(UNIT_TEST)
// Accessors used only in tests.
- bool is_showing() const { return is_showing_; }
InstantLoader* loader() const { return loader_.get(); }
#endif
+ const InstantModel* model() const { return &model_; }
+
private:
FRIEND_TEST_ALL_PREFIXES(InstantTest, InstantLoaderRefresh);
@@ -219,6 +221,8 @@ class InstantController : public InstantLoaderDelegate {
InstantControllerDelegate* const delegate_;
+ InstantModel model_;
+
scoped_ptr<InstantLoader> loader_;
// See the enum description above.
@@ -249,10 +253,6 @@ class InstantController : public InstantLoaderDelegate {
// True if the last match passed to Update() was a search (versus a URL).
bool last_match_was_search_;
- // True if the preview is currently being displayed. Guaranteed to be false
- // if IsOutOfDate() is true.
- bool is_showing_;
-
// True if we've received a response from the loader for the last Update(),
// thus indicating that the page is ready to be shown.
bool loader_processed_last_update_;
diff --git a/chrome/browser/instant/instant_controller_delegate.h b/chrome/browser/instant/instant_controller_delegate.h
index e37c852..11c10f6 100644
--- a/chrome/browser/instant/instant_controller_delegate.h
+++ b/chrome/browser/instant/instant_controller_delegate.h
@@ -22,12 +22,6 @@ class Rect;
// (note that it may return NULL).
class InstantControllerDelegate {
public:
- // Show the preview with the given |height|.
- virtual void ShowInstant(int height, InstantSizeUnits units) = 0;
-
- // Hide any preview currently being shown.
- virtual void HideInstant() = 0;
-
// Commit the |preview| by merging it into the active tab or adding it as a
// new tab, based on |in_new_tab|. Delegate takes ownership of |preview|.
virtual void CommitInstant(TabContents* preview, bool in_new_tab) = 0;
diff --git a/chrome/browser/instant/instant_model.cc b/chrome/browser/instant/instant_model.cc
new file mode 100644
index 0000000..fabd25a
--- /dev/null
+++ b/chrome/browser/instant/instant_model.cc
@@ -0,0 +1,61 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/instant/instant_model.h"
+
+#include "chrome/browser/instant/instant_controller.h"
+#include "chrome/browser/instant/instant_model_observer.h"
+
+InstantModel::InstantModel(InstantController* controller)
+ : display_state_(NOT_READY),
+ height_(0),
+ height_units_(INSTANT_SIZE_PIXELS),
+ preview_contents_(NULL),
+ controller_(controller) {
+}
+
+InstantModel::~InstantModel() {
+}
+
+void InstantModel::SetDisplayState(DisplayState display_state,
+ int height,
+ InstantSizeUnits height_units) {
+ if (display_state_ == display_state &&
+ height_ == height &&
+ height_units_ == height_units)
+ return;
+
+ display_state_ = display_state;
+ height_ = height;
+ height_units_ = height_units;
+
+ FOR_EACH_OBSERVER(InstantModelObserver, observers_,
+ DisplayStateChanged(*this));
+}
+
+void InstantModel::SetPreviewContents(TabContents* preview_contents) {
+ if (preview_contents_ == preview_contents)
+ return;
+
+ preview_contents_ = preview_contents;
+
+ FOR_EACH_OBSERVER(InstantModelObserver, observers_,
+ DisplayStateChanged(*this));
+}
+
+TabContents* InstantModel::GetPreviewContents() const {
+ return controller_->GetPreviewContents();
+}
+
+void InstantModel::AddObserver(InstantModelObserver* observer) const {
+ observers_.AddObserver(observer);
+}
+
+void InstantModel::RemoveObserver(InstantModelObserver* observer) const {
+ observers_.RemoveObserver(observer);
+}
+
+bool InstantModel::HasObserver(InstantModelObserver* observer) const {
+ return observers_.HasObserver(observer);
+}
diff --git a/chrome/browser/instant/instant_model.h b/chrome/browser/instant/instant_model.h
new file mode 100644
index 0000000..c07f2fe
--- /dev/null
+++ b/chrome/browser/instant/instant_model.h
@@ -0,0 +1,69 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+#ifndef CHROME_BROWSER_INSTANT_INSTANT_MODEL_H_
+#define CHROME_BROWSER_INSTANT_INSTANT_MODEL_H_
+
+#include "base/basictypes.h"
+#include "base/observer_list.h"
+#include "chrome/common/instant_types.h"
+
+class InstantController;
+class InstantModelObserver;
+class TabContents;
+
+// Holds state that is important to any views concerned with visibility and
+// layout of the Instant preview.
+class InstantModel {
+ public:
+ enum DisplayState {
+ // When the preview contents are out of date, the preview should not be
+ // shown.
+ NOT_READY,
+
+ // When the preview contents is updated and ready for display its state
+ // transitions to |QUERY_RESULTS|.
+ QUERY_RESULTS,
+ };
+
+ explicit InstantModel(InstantController* controller);
+ ~InstantModel();
+
+ void SetDisplayState(DisplayState display,
+ int height, InstantSizeUnits height_units);
+ DisplayState display_state() const { return display_state_; }
+ bool is_ready() const { return display_state_ != NOT_READY; }
+ int height() const { return height_; }
+ InstantSizeUnits height_units() const { return height_units_; }
+
+ void SetPreviewContents(TabContents* preview_contents);
+ TabContents* GetPreviewContents() const;
+
+ // Add, remove, check observers.
+ void AddObserver(InstantModelObserver* observer) const;
+ void RemoveObserver(InstantModelObserver* observer) const;
+ bool HasObserver(InstantModelObserver* observer) const;
+
+ private:
+ // |QUERY_RESULTS| if the preview should be displayed. Guaranteed to be
+ // |NOT_READY| if InstantController::IsOutOfDate() is true.
+ DisplayState display_state_;
+ int height_;
+ InstantSizeUnits height_units_;
+
+ // Weak. Remembers the last set preview contents to detect changes.
+ // Actual preview contents is fetched from the |controller_| as this
+ // may not always reflect the actual preview in effect.
+ TabContents* preview_contents_;
+
+ // Weak. The controller currently holds some model state.
+ // TODO(dhollowa): Remove this, transfer all model state to InstantModel.
+ InstantController* const controller_;
+
+ // Observers.
+ mutable ObserverList<InstantModelObserver> observers_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(InstantModel);
+};
+
+#endif // CHROME_BROWSER_INSTANT_INSTANT_MODEL_H_
diff --git a/chrome/browser/instant/instant_model_observer.h b/chrome/browser/instant/instant_model_observer.h
new file mode 100644
index 0000000..a996ee7
--- /dev/null
+++ b/chrome/browser/instant/instant_model_observer.h
@@ -0,0 +1,24 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_INSTANT_INSTANT_MODEL_OBSERVER_H_
+#define CHROME_BROWSER_INSTANT_INSTANT_MODEL_OBSERVER_H_
+
+#include "chrome/common/instant_types.h"
+
+class InstantModel;
+
+// This class defines the observer interface for the |InstantModel|.
+class InstantModelObserver {
+ public:
+ // Informs the observer that the preview state has has changed.
+ // This can mean the model state has changed, or the contents of the
+ // preview.
+ virtual void DisplayStateChanged(const InstantModel& model) = 0;
+
+ protected:
+ virtual ~InstantModelObserver() {}
+};
+
+#endif // CHROME_BROWSER_INSTANT_INSTANT_MODEL_OBSERVER_H_
diff --git a/chrome/browser/instant/instant_preview_controller.cc b/chrome/browser/instant/instant_preview_controller.cc
new file mode 100644
index 0000000..3283742d
--- /dev/null
+++ b/chrome/browser/instant/instant_preview_controller.cc
@@ -0,0 +1,39 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/instant/instant_preview_controller.h"
+
+#include "chrome/browser/instant/instant_model.h"
+#include "chrome/browser/instant/instant_controller.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_instant_controller.h"
+#include "chrome/common/chrome_notification_types.h"
+#include "content/public/browser/notification_service.h"
+
+InstantPreviewController::InstantPreviewController(Browser* browser)
+ : browser_(browser) {
+ registrar_.Add(this, chrome::NOTIFICATION_BROWSER_INSTANT_RESET,
+ content::NotificationService::AllSources());
+ ResetInstant();
+}
+
+InstantPreviewController::~InstantPreviewController() {
+ InstantController* instant = browser_->instant_controller()->instant();
+ if (instant)
+ instant->model()->RemoveObserver(this);
+}
+
+void InstantPreviewController::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK_EQ(chrome::NOTIFICATION_BROWSER_INSTANT_RESET, type);
+ ResetInstant();
+}
+
+void InstantPreviewController::ResetInstant() {
+ InstantController* instant = browser_->instant_controller()->instant();
+ if (instant && !instant->model()->HasObserver(this))
+ instant->model()->AddObserver(this);
+}
diff --git a/chrome/browser/instant/instant_preview_controller.h b/chrome/browser/instant/instant_preview_controller.h
new file mode 100644
index 0000000..fd11403
--- /dev/null
+++ b/chrome/browser/instant/instant_preview_controller.h
@@ -0,0 +1,42 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_INSTANT_INSTANT_PREVIEW_CONTROLLER_H_
+#define CHROME_BROWSER_INSTANT_INSTANT_PREVIEW_CONTROLLER_H_
+
+#include "base/compiler_specific.h"
+#include "chrome/browser/instant/instant_model_observer.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+class Browser;
+class InstantModel;
+
+// Abstract base class for platform-specific Instant preview controllers.
+class InstantPreviewController : public InstantModelObserver,
+ public content::NotificationObserver {
+ public:
+ explicit InstantPreviewController(Browser* browser);
+ virtual ~InstantPreviewController();
+
+ // Overridden from InstantModelObserver:
+ virtual void DisplayStateChanged(const InstantModel& model) OVERRIDE = 0;
+
+ // Overridden from content::NotificationObserver:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ protected:
+ Browser* const browser_;
+
+ private:
+ void ResetInstant();
+
+ content::NotificationRegistrar registrar_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(InstantPreviewController);
+};
+
+#endif // CHROME_BROWSER_INSTANT_INSTANT_PREVIEW_CONTROLLER_H_
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc
index 6b35042..bca5105 100644
--- a/chrome/browser/ui/browser_instant_controller.cc
+++ b/chrome/browser/ui/browser_instant_controller.cc
@@ -62,15 +62,6 @@ bool BrowserInstantController::OpenInstant(WindowOpenDisposition disposition) {
////////////////////////////////////////////////////////////////////////////////
// BrowserInstantController, InstantControllerDelegate implementation:
-void BrowserInstantController::ShowInstant(int height, InstantSizeUnits units) {
- browser_->window()->ShowInstant(instant_->GetPreviewContents(),
- height, units);
-}
-
-void BrowserInstantController::HideInstant() {
- browser_->window()->HideInstant();
-}
-
void BrowserInstantController::CommitInstant(TabContents* preview,
bool in_new_tab) {
if (in_new_tab) {
@@ -154,6 +145,12 @@ void BrowserInstantController::ResetInstant() {
!browser_shutdown::ShuttingDownWithoutClosingBrowsers() &&
browser_->is_type_tabbed() ?
InstantController::CreateInstant(browser_->profile(), this) : NULL);
+
+ // Notify any observers that they need to reset.
+ content::NotificationService::current()->Notify(
+ chrome::NOTIFICATION_BROWSER_INSTANT_RESET,
+ content::Source<BrowserInstantController>(this),
+ content::NotificationService::NoDetails());
}
} // namespace chrome
diff --git a/chrome/browser/ui/browser_instant_controller.h b/chrome/browser/ui/browser_instant_controller.h
index d7a8f76..d56c888 100644
--- a/chrome/browser/ui/browser_instant_controller.h
+++ b/chrome/browser/ui/browser_instant_controller.h
@@ -52,8 +52,6 @@ class BrowserInstantController : public InstantControllerDelegate,
private:
// Overridden from InstantControllerDelegate:
- virtual void ShowInstant(int height, InstantSizeUnits units) OVERRIDE;
- virtual void HideInstant() OVERRIDE;
virtual void CommitInstant(TabContents* preview, bool in_new_tab) OVERRIDE;
virtual void SetSuggestedText(const string16& text,
InstantCompleteBehavior behavior) OVERRIDE;
diff --git a/chrome/browser/ui/browser_window.h b/chrome/browser/ui/browser_window.h
index da7210b..212cc9b 100644
--- a/chrome/browser/ui/browser_window.h
+++ b/chrome/browser/ui/browser_window.h
@@ -318,14 +318,6 @@ class BrowserWindow : public BaseWindow {
virtual bool InPresentationMode() = 0;
#endif
- // Invoked when instant's tab contents should be shown with given |height|.
- virtual void ShowInstant(TabContents* preview,
- int height,
- InstantSizeUnits units) = 0;
-
- // Invoked when instant's tab contents should be hidden.
- virtual void HideInstant() = 0;
-
// Returns the desired bounds for instant in screen coordinates. Note that if
// instant isn't currently visible this returns the bounds instant would be
// placed at.
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.h b/chrome/browser/ui/cocoa/browser_window_cocoa.h
index db4dfc9..822ec24 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.h
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.h
@@ -136,10 +136,6 @@ class BrowserWindowCocoa :
FullscreenExitBubbleType bubble_type) OVERRIDE;
virtual void ExitPresentationMode() OVERRIDE;
virtual bool InPresentationMode() OVERRIDE;
- virtual void ShowInstant(TabContents* preview,
- int height,
- InstantSizeUnits units) OVERRIDE;
- virtual void HideInstant() OVERRIDE;
virtual gfx::Rect GetInstantBounds() OVERRIDE;
virtual bool IsInstantTabShowing() OVERRIDE;
virtual WindowOpenDisposition GetDispositionForPopupBounds(
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index 9d34a89..13f06d4 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -568,18 +568,6 @@ bool BrowserWindowCocoa::InPresentationMode() {
return [controller_ inPresentationMode];
}
-void BrowserWindowCocoa::ShowInstant(TabContents* preview,
- int height,
- InstantSizeUnits units) {
- // TODO(jered): Support height < 100%.
- DCHECK(height == 100 && units == INSTANT_SIZE_PERCENT);
- [controller_ showInstant:preview->web_contents()];
-}
-
-void BrowserWindowCocoa::HideInstant() {
- [controller_ hideInstant];
-}
-
gfx::Rect BrowserWindowCocoa::GetInstantBounds() {
// Flip coordinates based on the primary screen.
NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.h b/chrome/browser/ui/cocoa/browser_window_controller.h
index 7525bc9..3dbdd5d 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.h
+++ b/chrome/browser/ui/cocoa/browser_window_controller.h
@@ -324,8 +324,6 @@ class WebContents;
- (NSPoint)bookmarkBubblePoint;
// Shows or hides the Instant preview contents.
-- (void)showInstant:(content::WebContents*)previewContents;
-- (void)hideInstant;
- (void)commitInstant;
- (BOOL)isInstantTabShowing;
diff --git a/chrome/browser/ui/cocoa/browser_window_controller.mm b/chrome/browser/ui/cocoa/browser_window_controller.mm
index 476fb69..418ed1f 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller.mm
@@ -303,7 +303,8 @@ enum {
// Create the previewable contents controller. This provides the switch
// view that TabStripController needs.
previewableContentsController_.reset(
- [[PreviewableContentsController alloc] init]);
+ [[PreviewableContentsController alloc] initWithBrowser:browser
+ windowController:self]);
[[previewableContentsController_ view]
setFrame:[[devToolsController_ view] bounds]];
[[devToolsController_ view]
@@ -1908,21 +1909,6 @@ willAnimateFromState:(bookmarks::VisualState)oldState
return fullscreenExitBubbleController_.get();
}
-- (void)showInstant:(WebContents*)previewContents {
- [previewableContentsController_ showPreview:previewContents];
- [self updateBookmarkBarVisibilityWithAnimation:NO];
-}
-
-- (void)hideInstant {
- // TODO(rohitrao): Revisit whether or not this method should be called when
- // instant isn't showing.
- if (![previewableContentsController_ isShowingPreview])
- return;
-
- [previewableContentsController_ hidePreview];
- [self updateBookmarkBarVisibilityWithAnimation:NO];
-}
-
- (void)commitInstant {
InstantController* instant = browser_->instant_controller()->instant();
if (instant && instant->IsCurrent())
diff --git a/chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.h b/chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.h
new file mode 100644
index 0000000..33d8fc8
--- /dev/null
+++ b/chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.h
@@ -0,0 +1,39 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_INSTANT_PREVIEW_CONTROLLER_MAC_H_
+#define CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_INSTANT_PREVIEW_CONTROLLER_MAC_H_
+
+#include "base/compiler_specific.h"
+#include "chrome/browser/instant/instant_model_observer.h"
+#include "chrome/browser/instant/instant_preview_controller.h"
+
+class Browser;
+@class BrowserWindowController;
+@class PreviewableContentsController;
+
+class InstantPreviewControllerMac : public InstantPreviewController {
+ public:
+ InstantPreviewControllerMac(
+ Browser* browser,
+ BrowserWindowController* window_controller,
+ PreviewableContentsController* previewable_contents_controller);
+ virtual ~InstantPreviewControllerMac();
+
+ // InstantModelObserver overrides:
+ virtual void DisplayStateChanged(const InstantModel& model) OVERRIDE;
+
+ private:
+
+ // Weak.
+ BrowserWindowController* window_controller_;
+
+ // Weak. Owns us.
+ PreviewableContentsController* previewable_contents_controller_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstantPreviewControllerMac);
+};
+
+
+#endif // CHROME_BROWSER_UI_COCOA_TAB_CONTENTS_INSTANT_PREVIEW_CONTROLLER_MAC_H_
diff --git a/chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.mm b/chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.mm
new file mode 100644
index 0000000..0980028
--- /dev/null
+++ b/chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.mm
@@ -0,0 +1,36 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.h"
+
+#include "chrome/browser/instant/instant_model.h"
+#import "chrome/browser/ui/cocoa/browser_window_controller.h"
+#import "chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h"
+#include "chrome/browser/ui/tab_contents/tab_contents.h"
+
+InstantPreviewControllerMac::InstantPreviewControllerMac(
+ Browser* browser,
+ BrowserWindowController* window_controller,
+ PreviewableContentsController* previewable_contents_controller)
+ : InstantPreviewController(browser),
+ window_controller_(window_controller),
+ previewable_contents_controller_(previewable_contents_controller) {
+}
+
+InstantPreviewControllerMac::~InstantPreviewControllerMac() {
+}
+
+void InstantPreviewControllerMac::DisplayStateChanged(
+ const InstantModel& model) {
+ if (model.is_ready()) {
+ // TODO(dhollowa): Needs height and units implementation on Mac.
+ [previewable_contents_controller_
+ showPreview:model.GetPreviewContents()->web_contents()];
+ } else {
+ if (![previewable_contents_controller_ isShowingPreview])
+ return;
+ [previewable_contents_controller_ hidePreview];
+ }
+ [window_controller_ updateBookmarkBarVisibilityWithAnimation:NO];
+}
diff --git a/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h b/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h
index 947a945..bd0c46d 100644
--- a/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h
+++ b/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.h
@@ -7,6 +7,12 @@
#import <Cocoa/Cocoa.h>
+#include "base/memory/scoped_ptr.h"
+
+class Browser;
+class InstantPreviewControllerMac;
+@class BrowserWindowController;
+
namespace content {
class WebContents;
}
@@ -29,10 +35,17 @@ class WebContents;
// The preview WebContents. Will be NULL if no preview is currently showing.
content::WebContents* previewContents_; // weak
+
+ // C++ bridge to the Instant model change interface.
+ scoped_ptr<InstantPreviewControllerMac> instantPreviewController_;
}
@property(readonly, nonatomic) NSView* activeContainer;
+// Initialization.
+- (id)initWithBrowser:(Browser*)browser
+ windowController:(BrowserWindowController*)windowController;
+
// Sets the current preview and installs its WebContentsView into the view
// hierarchy. Hides the active view. |preview| must not be NULL.
- (void)showPreview:(content::WebContents*)preview;
diff --git a/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm b/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm
index cc0a4b9..3e430019 100644
--- a/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm
+++ b/chrome/browser/ui/cocoa/tab_contents/previewable_contents_controller.mm
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/mac/bundle_locations.h"
#include "base/mac/mac_util.h"
+#include "chrome/browser/ui/cocoa/tab_contents/instant_preview_controller_mac.h"
#include "content/public/browser/web_contents.h"
using content::WebContents;
@@ -15,6 +16,7 @@ using content::WebContents;
@synthesize activeContainer = activeContainer_;
+// For testing. Use |-initWithBrowser:| for production.
- (id)init {
if ((self = [super initWithNibName:@"PreviewableContents"
bundle:base::mac::FrameworkBundle()])) {
@@ -22,6 +24,15 @@ using content::WebContents;
return self;
}
+- (id)initWithBrowser:(Browser*)browser
+ windowController:(BrowserWindowController*)windowController {
+ if ((self = [self init])) {
+ instantPreviewController_.reset(
+ new InstantPreviewControllerMac(browser, windowController, self));
+ }
+ return self;
+}
+
- (void)showPreview:(WebContents*)preview {
DCHECK(preview);
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index 4ac7cf0..24fe60b 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -65,6 +65,7 @@
#include "chrome/browser/ui/gtk/gtk_window_util.h"
#include "chrome/browser/ui/gtk/infobars/infobar_container_gtk.h"
#include "chrome/browser/ui/gtk/infobars/infobar_gtk.h"
+#include "chrome/browser/ui/gtk/instant_preview_controller_gtk.h"
#include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
#include "chrome/browser/ui/gtk/nine_box.h"
#include "chrome/browser/ui/gtk/one_click_signin_bubble_gtk.h"
@@ -1134,20 +1135,6 @@ void BrowserWindowGtk::Paste() {
window_, chrome::GetActiveWebContents(browser_.get()));
}
-void BrowserWindowGtk::ShowInstant(TabContents* preview,
- int height,
- InstantSizeUnits units) {
- // TODO(jered): Support height < 100%.
- DCHECK(height == 100 && units == INSTANT_SIZE_PERCENT);
- contents_container_->SetPreview(preview);
- MaybeShowBookmarkBar(false);
-}
-
-void BrowserWindowGtk::HideInstant() {
- contents_container_->SetPreview(NULL);
- MaybeShowBookmarkBar(false);
-}
-
gfx::Rect BrowserWindowGtk::GetInstantBounds() {
return ui::GetWidgetScreenBounds(contents_container_->widget());
}
@@ -1326,28 +1313,6 @@ extensions::ActiveTabPermissionGranter*
active_tab_permission_granter();
}
-void BrowserWindowGtk::MaybeShowBookmarkBar(bool animate) {
- TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::MaybeShowBookmarkBar");
- if (!IsBookmarkBarSupported())
- return;
-
- TabContents* tab = GetDisplayedTab();
-
- if (tab)
- bookmark_bar_->SetPageNavigator(browser_.get());
-
- BookmarkBar::State state = browser_->bookmark_bar_state();
- if (contents_container_->HasPreview() && state == BookmarkBar::DETACHED)
- state = BookmarkBar::HIDDEN;
-
- toolbar_->UpdateForBookmarkBarVisibility(state == BookmarkBar::DETACHED);
- PlaceBookmarkBar(state == BookmarkBar::DETACHED);
- bookmark_bar_->SetBookmarkBarState(
- state,
- animate ? BookmarkBar::ANIMATE_STATE_CHANGE :
- BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
-}
-
void BrowserWindowGtk::UpdateDevToolsForContents(WebContents* contents) {
TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::UpdateDevToolsForContents");
TabContents* old_devtools = devtools_container_->tab();
@@ -1822,6 +1787,11 @@ void BrowserWindowGtk::InitWidgets() {
gtk_box_pack_end(GTK_BOX(window_vbox_), render_area_event_box_,
TRUE, TRUE, 0);
+ instant_preview_controller_.reset(
+ new InstantPreviewControllerGtk(browser_.get(),
+ this,
+ contents_container_.get()));
+
if (IsBookmarkBarSupported()) {
bookmark_bar_.reset(new BookmarkBarGtk(this,
browser_.get(),
@@ -2054,6 +2024,28 @@ int BrowserWindowGtk::GetXPositionOfLocationIcon(GtkWidget* relative_to) {
return x;
}
+void BrowserWindowGtk::MaybeShowBookmarkBar(bool animate) {
+ TRACE_EVENT0("ui::gtk", "BrowserWindowGtk::MaybeShowBookmarkBar");
+ if (!IsBookmarkBarSupported())
+ return;
+
+ TabContents* tab = GetDisplayedTab();
+
+ if (tab)
+ bookmark_bar_->SetPageNavigator(browser_.get());
+
+ BookmarkBar::State state = browser_->bookmark_bar_state();
+ if (contents_container_->HasPreview() && state == BookmarkBar::DETACHED)
+ state = BookmarkBar::HIDDEN;
+
+ toolbar_->UpdateForBookmarkBarVisibility(state == BookmarkBar::DETACHED);
+ PlaceBookmarkBar(state == BookmarkBar::DETACHED);
+ bookmark_bar_->SetBookmarkBarState(
+ state,
+ animate ? BookmarkBar::ANIMATE_STATE_CHANGE :
+ BookmarkBar::DONT_ANIMATE_STATE_CHANGE);
+}
+
void BrowserWindowGtk::OnLocationIconSizeAllocate(GtkWidget* sender,
GtkAllocation* allocation) {
// The position of the arrow may have changed, so we'll have to redraw it.
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h
index 5caa6b4..f4599d4 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.h
+++ b/chrome/browser/ui/gtk/browser_window_gtk.h
@@ -35,6 +35,7 @@ class FindBarGtk;
class FullscreenExitBubbleGtk;
class GlobalMenuBar;
class InfoBarContainerGtk;
+class InstantPreviewControllerGtk;
class LocationBar;
class PrefService;
class StatusBubbleGtk;
@@ -159,10 +160,6 @@ class BrowserWindowGtk
virtual void Cut() OVERRIDE;
virtual void Copy() OVERRIDE;
virtual void Paste() OVERRIDE;
- virtual void ShowInstant(TabContents* preview,
- int height,
- InstantSizeUnits units) OVERRIDE;
- virtual void HideInstant() OVERRIDE;
virtual gfx::Rect GetInstantBounds() OVERRIDE;
virtual bool IsInstantTabShowing() OVERRIDE;
virtual WindowOpenDisposition GetDispositionForPopupBounds(
@@ -269,6 +266,9 @@ class BrowserWindowGtk
// |relative_to| coordinates. This is the middle of the omnibox location icon.
int GetXPositionOfLocationIcon(GtkWidget* relative_to);
+ // Show or hide the bookmark bar.
+ void MaybeShowBookmarkBar(bool animate);
+
protected:
virtual void DestroyBrowser() OVERRIDE;
@@ -315,9 +315,6 @@ class BrowserWindowGtk
scoped_ptr<Browser> browser_;
private:
- // Show or hide the bookmark bar.
- void MaybeShowBookmarkBar(bool animate);
-
// Connect to signals on |window_|.
void ConnectHandlersToSignals();
@@ -495,6 +492,9 @@ class BrowserWindowGtk
// selected tab contents.
scoped_ptr<TabContentsContainerGtk> devtools_container_;
+ // A sub-controller that manages the Instant preview visual state.
+ scoped_ptr<InstantPreviewControllerGtk> instant_preview_controller_;
+
// The Extension Keybinding Registry responsible for registering listeners for
// accelerators that are sent to the window, that are destined to be turned
// into events and sent to the extension.
diff --git a/chrome/browser/ui/gtk/instant_preview_controller_gtk.cc b/chrome/browser/ui/gtk/instant_preview_controller_gtk.cc
new file mode 100644
index 0000000..bc924ab
--- /dev/null
+++ b/chrome/browser/ui/gtk/instant_preview_controller_gtk.cc
@@ -0,0 +1,45 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/gtk/instant_preview_controller_gtk.h"
+
+#include "chrome/browser/ui/gtk/browser_window_gtk.h"
+#include "chrome/browser/ui/gtk/tab_contents_container_gtk.h"
+#include "chrome/browser/instant/instant_model.h"
+
+InstantPreviewControllerGtk::InstantPreviewControllerGtk(
+ Browser* browser,
+ BrowserWindowGtk* window,
+ TabContentsContainerGtk* contents)
+ : InstantPreviewController(browser),
+ window_(window),
+ contents_(contents) {
+}
+
+InstantPreviewControllerGtk::~InstantPreviewControllerGtk() {
+}
+
+void InstantPreviewControllerGtk::DisplayStateChanged(
+ const InstantModel& model) {
+ if (model.is_ready()) {
+ ShowInstant(model.GetPreviewContents(),
+ model.height(), model.height_units());
+ } else {
+ HideInstant();
+ }
+}
+
+void InstantPreviewControllerGtk::ShowInstant(TabContents* preview,
+ int height,
+ InstantSizeUnits units) {
+ // TODO(jered): Support height < 100%.
+ DCHECK(height == 100 && units == INSTANT_SIZE_PERCENT);
+ contents_->SetPreview(preview);
+ window_->MaybeShowBookmarkBar(false);
+}
+
+void InstantPreviewControllerGtk::HideInstant() {
+ contents_->SetPreview(NULL);
+ window_->MaybeShowBookmarkBar(false);
+}
diff --git a/chrome/browser/ui/gtk/instant_preview_controller_gtk.h b/chrome/browser/ui/gtk/instant_preview_controller_gtk.h
new file mode 100644
index 0000000..9038df3
--- /dev/null
+++ b/chrome/browser/ui/gtk/instant_preview_controller_gtk.h
@@ -0,0 +1,41 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_GTK_INSTANT_PREVIEW_CONTROLLER_GTK_H_
+#define CHROME_BROWSER_UI_GTK_INSTANT_PREVIEW_CONTROLLER_GTK_H_
+
+#include "base/compiler_specific.h"
+#include "chrome/browser/instant/instant_model_observer.h"
+#include "chrome/browser/instant/instant_preview_controller.h"
+
+class Browser;
+class BrowserWindowGtk;
+class InstantModel;
+class TabContents;
+class TabContentsContainerGtk;
+
+class InstantPreviewControllerGtk : public InstantPreviewController {
+ public:
+ InstantPreviewControllerGtk(Browser* browser,
+ BrowserWindowGtk* window,
+ TabContentsContainerGtk* contents);
+ virtual ~InstantPreviewControllerGtk();
+
+ // InstantModelObserver overrides:
+ virtual void DisplayStateChanged(const InstantModel& model) OVERRIDE;
+
+ private:
+ void ShowInstant(TabContents* preview, int height, InstantSizeUnits units);
+ void HideInstant();
+
+ // Weak.
+ BrowserWindowGtk* window_;
+
+ // Weak.
+ TabContentsContainerGtk* contents_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstantPreviewControllerGtk);
+};
+
+#endif // CHROME_BROWSER_UI_GTK_INSTANT_PREVIEW_CONTROLLER_GTK_H_
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 2f76f32..02addb8 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -19,6 +19,7 @@
#include "chrome/browser/debugger/devtools_window.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
+#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/managed_mode.h"
#include "chrome/browser/native_window_notification_source.h"
#include "chrome/browser/ntp_background_util.h"
@@ -39,6 +40,7 @@
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_instant_controller.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window_state.h"
@@ -61,6 +63,7 @@
#include "chrome/browser/ui/views/download/download_shelf_view.h"
#include "chrome/browser/ui/views/frame/browser_view_layout.h"
#include "chrome/browser/ui/views/frame/contents_container.h"
+#include "chrome/browser/ui/views/frame/instant_preview_controller_views.h"
#include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h"
#include "chrome/browser/ui/views/infobars/infobar_container_view.h"
#include "chrome/browser/ui/views/location_bar/location_bar_container.h"
@@ -339,7 +342,6 @@ BrowserView::BrowserView(Browser* browser)
infobar_container_(NULL),
contents_container_(NULL),
devtools_container_(NULL),
- preview_container_(NULL),
contents_(NULL),
contents_split_(NULL),
devtools_dock_side_(DEVTOOLS_DOCK_SIDE_BOTTOM),
@@ -368,6 +370,8 @@ BrowserView::~BrowserView() {
search_view_controller_.reset(NULL);
#endif
+ preview_controller_.reset(NULL);
+
browser_->tab_strip_model()->RemoveObserver(this);
browser_->search_model()->RemoveObserver(this);
@@ -1366,36 +1370,12 @@ void BrowserView::Paste() {
}
}
-void BrowserView::ShowInstant(TabContents* preview,
- int height,
- InstantSizeUnits units) {
- if (!preview_container_) {
- preview_container_ = new views::WebView(browser_->profile());
- preview_container_->set_id(VIEW_ID_TAB_CONTAINER);
- }
- contents_->SetPreview(preview_container_, preview->web_contents(),
- height, units);
- preview_container_->SetWebContents(preview->web_contents());
- RestackLocationBarContainer();
-}
-
-void BrowserView::HideInstant() {
- if (!preview_container_)
- return;
-
- // The contents must be changed before SetPreview is invoked.
- preview_container_->SetWebContents(NULL);
- contents_->SetPreview(NULL, NULL, 100, INSTANT_SIZE_PERCENT);
- delete preview_container_;
- preview_container_ = NULL;
-}
-
gfx::Rect BrowserView::GetInstantBounds() {
return contents_->GetPreviewBounds();
}
bool BrowserView::IsInstantTabShowing() {
- return preview_container_ != NULL;
+ return preview_controller_->preview_container() != NULL;
}
WindowOpenDisposition BrowserView::GetDispositionForPopupBounds(
@@ -1491,10 +1471,9 @@ void BrowserView::TabReplacedAt(TabStripModel* tab_strip_model,
// delete what was the active.
contents_->MakePreviewContentsActiveContents();
views::WebView* old_container = contents_container_;
- contents_container_ = preview_container_;
+ contents_container_ = preview_controller_->release_preview_container();
old_container->SetWebContents(NULL);
delete old_container;
- preview_container_ = NULL;
}
// Update the UI for the new contents.
ProcessTabSelected(new_contents);
@@ -2004,6 +1983,9 @@ void BrowserView::Init() {
}
#endif
+ preview_controller_.reset(
+ new InstantPreviewControllerViews(browser(), this, contents_));
+
SkColor bg_color = GetWidget()->GetThemeProvider()->
GetColor(ThemeService::COLOR_TOOLBAR);
@@ -2651,11 +2633,13 @@ void BrowserView::RestackLocationBarContainer() {
#if defined(USE_AURA)
if (search_view_controller_.get())
search_view_controller_->StackAtTop();
- if (preview_container_ && preview_container_->web_contents()) {
+ if (preview_controller_ && preview_controller_->preview_container() &&
+ preview_controller_->preview_container()->web_contents()) {
// Keep the preview on top so that a doodle can be shown on the NTP in
// InstantExtended mode.
ui::Layer* native_view_layer =
- preview_container_->web_contents()->GetNativeView()->layer();
+ preview_controller_->preview_container()->web_contents()->
+ GetNativeView()->layer();
native_view_layer->parent()->StackAtTop(native_view_layer);
}
#endif
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index ac8bc40..a5a26cd 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -45,6 +45,7 @@ class ContentsContainer;
class DownloadShelfView;
class FullscreenExitBubbleViews;
class InfoBarContainerView;
+class InstantPreviewControllerViews;
class LocationBarView;
class StatusBubbleViews;
class TabStrip;
@@ -337,10 +338,6 @@ class BrowserView : public BrowserWindow,
virtual void Cut() OVERRIDE;
virtual void Copy() OVERRIDE;
virtual void Paste() OVERRIDE;
- virtual void ShowInstant(TabContents* preview,
- int height,
- InstantSizeUnits units) OVERRIDE;
- virtual void HideInstant() OVERRIDE;
virtual gfx::Rect GetInstantBounds() OVERRIDE;
virtual bool IsInstantTabShowing() OVERRIDE;
virtual WindowOpenDisposition GetDispositionForPopupBounds(
@@ -427,6 +424,12 @@ class BrowserView : public BrowserWindow,
// which layout is being shown and whether we are full-screen.
int GetOTRIconResourceID() const;
+ // Forces the LocationBarContainer to the top of the native window stacking
+ // order. This is needed for the Instant extended API when the location bar
+ // can be placed over web contents.
+ // Used by |InstantPreviewControllerViews| which manages the instant preview.
+ void RestackLocationBarContainer();
+
protected:
// Appends to |toolbars| a pointer to each AccessiblePaneView that
// can be traversed using F6, in the order they should be traversed.
@@ -566,11 +569,6 @@ class BrowserView : public BrowserWindow,
// Create an icon for this window in the launcher (currently only for Ash).
void CreateLauncherIcon();
- // Forces the LocationBarContainer to the top of the native window stacking
- // order. This is needed for the Instant extended API when the location bar
- // can be placed over web contents.
- void RestackLocationBarContainer();
-
// Calls |method| which is either RenderWidgetHost::Cut, ::Copy, or ::Paste
// and returns true if the focus is currently on a WebContent.
bool DoCutCopyPaste(void (content::RenderWidgetHost::*method)());
@@ -602,7 +600,7 @@ class BrowserView : public BrowserWindow,
// |Page content (contents_) ||
// |-------------------------------------------------------------||
// || contents_container_ and/or |||
- // || preview_container_ |||
+ // || preview_controller_->preview_container_ |||
// || |||
// || |||
// || |||
@@ -625,7 +623,8 @@ class BrowserView : public BrowserWindow,
// * - The bookmark bar and info bar are swapped when on the new tab page.
// Additionally contents_ is positioned on top of the bookmark bar when
// the bookmark bar is detached. This is done to allow the
- // preview_container_ to appear over the bookmark bar.
+ // preview_controller_->preview_container_ to appear over the bookmark
+ // bar.
// Tool/Info bars that we are currently showing. Used for layout.
// active_bookmark_bar_ is either NULL, if the bookmark bar isn't showing,
@@ -658,10 +657,8 @@ class BrowserView : public BrowserWindow,
// The view that contains devtools window for the selected WebContents.
views::WebView* devtools_container_;
- // The view that contains instant's WebContents.
- views::WebView* preview_container_;
-
- // The view managing both the contents_container_ and preview_container_.
+ // The view managing both the contents_container_ and
+ // preview_controller_->preview_container_.
ContentsContainer* contents_;
// Split view containing the contents container and devtools container.
@@ -732,6 +729,8 @@ class BrowserView : public BrowserWindow,
scoped_ptr<SearchViewController> search_view_controller_;
#endif
+ scoped_ptr<InstantPreviewControllerViews> preview_controller_;
+
mutable base::WeakPtrFactory<BrowserView> activate_modal_dialog_factory_;
DISALLOW_COPY_AND_ASSIGN(BrowserView);
diff --git a/chrome/browser/ui/views/frame/instant_preview_controller_views.cc b/chrome/browser/ui/views/frame/instant_preview_controller_views.cc
new file mode 100644
index 0000000..6825cf4
--- /dev/null
+++ b/chrome/browser/ui/views/frame/instant_preview_controller_views.cc
@@ -0,0 +1,61 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/views/frame/instant_preview_controller_views.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/tab_contents/tab_contents.h"
+#include "chrome/browser/ui/view_ids.h"
+#include "chrome/browser/ui/views/frame/browser_view.h"
+#include "chrome/browser/ui/views/frame/contents_container.h"
+#include "chrome/browser/instant/instant_model.h"
+#include "ui/views/controls/webview/webview.h"
+
+InstantPreviewControllerViews::InstantPreviewControllerViews(
+ Browser* browser,
+ BrowserView* browser_view,
+ ContentsContainer* contents)
+ : InstantPreviewController(browser),
+ browser_view_(browser_view),
+ contents_(contents),
+ preview_container_(NULL) {
+}
+
+InstantPreviewControllerViews::~InstantPreviewControllerViews() {
+}
+
+void InstantPreviewControllerViews::DisplayStateChanged(
+ const InstantModel& model) {
+ if (model.is_ready()) {
+ ShowInstant(model.GetPreviewContents(),
+ model.height(), model.height_units());
+ } else {
+ HideInstant();
+ }
+}
+
+void InstantPreviewControllerViews::ShowInstant(TabContents* preview,
+ int height,
+ InstantSizeUnits units) {
+ if (!preview_container_) {
+ preview_container_ = new views::WebView(browser_->profile());
+ preview_container_->set_id(VIEW_ID_TAB_CONTAINER);
+ }
+ contents_->SetPreview(preview_container_,
+ preview->web_contents(),
+ height, units);
+ preview_container_->SetWebContents(preview->web_contents());
+ browser_view_->RestackLocationBarContainer();
+}
+
+void InstantPreviewControllerViews::HideInstant() {
+ if (!preview_container_)
+ return;
+
+ // The contents must be changed before SetPreview is invoked.
+ preview_container_->SetWebContents(NULL);
+ contents_->SetPreview(NULL, NULL, 100, INSTANT_SIZE_PERCENT);
+ delete preview_container_;
+ preview_container_ = NULL;
+}
diff --git a/chrome/browser/ui/views/frame/instant_preview_controller_views.h b/chrome/browser/ui/views/frame/instant_preview_controller_views.h
new file mode 100644
index 0000000..f414ea9
--- /dev/null
+++ b/chrome/browser/ui/views/frame/instant_preview_controller_views.h
@@ -0,0 +1,59 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_INSTANT_PREVIEW_CONTROLLER_VIEWS_H_
+#define CHROME_BROWSER_UI_VIEWS_FRAME_INSTANT_PREVIEW_CONTROLLER_VIEWS_H_
+
+#include "base/compiler_specific.h"
+#include "chrome/browser/instant/instant_model_observer.h"
+#include "chrome/browser/instant/instant_preview_controller.h"
+
+class Browser;
+class BrowserView;
+class ContentsContainer;
+class InstantModel;
+class TabContents;
+
+namespace views {
+class WebView;
+}
+
+// A controller that manages the Views-specific Instant preview. Its primary
+// role is to respond to display-state changes from the Instant model and
+// reflect this in the visibility and layout of the preview.
+class InstantPreviewControllerViews : public InstantPreviewController {
+ public:
+ InstantPreviewControllerViews(Browser* browser,
+ BrowserView* browser_view,
+ ContentsContainer* contents);
+ virtual ~InstantPreviewControllerViews();
+
+ // InstantModelObserver overrides:
+ virtual void DisplayStateChanged(const InstantModel& model) OVERRIDE;
+
+ views::WebView* preview_container() { return preview_container_; }
+ views::WebView* release_preview_container() {
+ views::WebView* tmp = preview_container_;
+ preview_container_ = NULL;
+ return tmp;
+ }
+
+ private:
+ void ShowInstant(TabContents* preview, int height, InstantSizeUnits units);
+ void HideInstant();
+
+ // Weak.
+ BrowserView* browser_view_;
+
+ // Weak.
+ ContentsContainer* contents_;
+
+ // The view that contains the Instant preview web contents.
+ // Lazily created in ShowInstant() with ownership passed to |contents_|.
+ views::WebView* preview_container_;
+
+ DISALLOW_COPY_AND_ASSIGN(InstantPreviewControllerViews);
+};
+
+#endif // CHROME_BROWSER_UI_VIEWS_FRAME_INSTANT_PREVIEW_CONTROLLER_VIEWS_H_
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 4bece04..cf389ec 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -923,6 +923,11 @@
'browser/instant/instant_loader.cc',
'browser/instant/instant_loader.h',
'browser/instant/instant_loader_delegate.h',
+ 'browser/instant/instant_model.cc',
+ 'browser/instant/instant_model.h',
+ 'browser/instant/instant_model_observer.h',
+ 'browser/instant/instant_preview_controller.cc',
+ 'browser/instant/instant_preview_controller.h',
'browser/instant/instant_unload_handler.cc',
'browser/instant/instant_unload_handler.h',
'browser/intents/cws_intents_registry.cc',
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index b58629e..35169da 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -697,6 +697,8 @@
'browser/ui/cocoa/tab_contents/render_view_context_menu_mac.mm',
'browser/ui/cocoa/tab_contents/favicon_util_mac.h',
'browser/ui/cocoa/tab_contents/favicon_util_mac.mm',
+ 'browser/ui/cocoa/tab_contents/instant_preview_controller_mac.h',
+ 'browser/ui/cocoa/tab_contents/instant_preview_controller_mac.mm',
'browser/ui/cocoa/tab_contents/previewable_contents_controller.h',
'browser/ui/cocoa/tab_contents/previewable_contents_controller.mm',
'browser/ui/cocoa/tab_contents/sad_tab_controller.h',
@@ -990,6 +992,8 @@
'browser/ui/gtk/infobars/translate_infobar_base_gtk.h',
'browser/ui/gtk/infobars/translate_message_infobar_gtk.cc',
'browser/ui/gtk/infobars/translate_message_infobar_gtk.h',
+ 'browser/ui/gtk/instant_preview_controller_gtk.cc',
+ 'browser/ui/gtk/instant_preview_controller_gtk.h',
'browser/ui/gtk/javascript_app_modal_dialog_gtk.cc',
'browser/ui/gtk/javascript_app_modal_dialog_gtk.h',
'browser/ui/gtk/location_bar_view_gtk.cc',
@@ -1473,6 +1477,8 @@
'browser/ui/views/frame/browser_desktop_root_window_host_win.h',
'browser/ui/views/frame/glass_browser_frame_view.cc',
'browser/ui/views/frame/glass_browser_frame_view.h',
+ 'browser/ui/views/frame/instant_preview_controller_views.cc',
+ 'browser/ui/views/frame/instant_preview_controller_views.h',
'browser/ui/views/frame/minimize_button_metrics_win.cc',
'browser/ui/views/frame/minimize_button_metrics_win.h',
'browser/ui/views/frame/native_browser_frame.h',
diff --git a/chrome/common/chrome_notification_types.h b/chrome/common/chrome_notification_types.h
index 8ce716d..82afbcb 100644
--- a/chrome/common/chrome_notification_types.h
+++ b/chrome/common/chrome_notification_types.h
@@ -1121,12 +1121,6 @@ enum NotificationType {
// Sent each time the InstantController is updated.
NOTIFICATION_INSTANT_CONTROLLER_UPDATED,
- // Sent each time the InstantController shows the InstantLoader.
- NOTIFICATION_INSTANT_CONTROLLER_SHOWN,
-
- // Sent each time the InstantController hides the InstantLoader.
- NOTIFICATION_INSTANT_CONTROLLER_HIDDEN,
-
// Sent when an Instant preview is committed. The Source is the WebContents
// containing the committed preview.
NOTIFICATION_INSTANT_COMMITTED,
@@ -1135,6 +1129,10 @@ enum NotificationType {
// Instant API or not.
NOTIFICATION_INSTANT_SUPPORT_DETERMINED,
+ // Sent when the Browser Instant controller resets, this may result from
+ // a preference change.
+ NOTIFICATION_BROWSER_INSTANT_RESET,
+
// Sent when the CaptivePortalService checks if we're behind a captive portal.
// The Source is the Profile the CaptivePortalService belongs to, and the
// Details are a Details<CaptivePortalService::CheckResults>.
diff --git a/chrome/test/base/test_browser_window.h b/chrome/test/base/test_browser_window.h
index 9b564dc..567550f 100644
--- a/chrome/test/base/test_browser_window.h
+++ b/chrome/test/base/test_browser_window.h
@@ -130,10 +130,6 @@ class TestBrowserWindow : public BrowserWindow {
virtual bool InPresentationMode() OVERRIDE;
#endif
- virtual void ShowInstant(TabContents* preview_contents,
- int height,
- InstantSizeUnits units) OVERRIDE {}
- virtual void HideInstant() OVERRIDE {}
virtual gfx::Rect GetInstantBounds() OVERRIDE;
virtual bool IsInstantTabShowing() OVERRIDE;
virtual WindowOpenDisposition GetDispositionForPopupBounds(