summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/browser_instant_controller.cc
diff options
context:
space:
mode:
authorsreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-04 19:14:59 +0000
committersreeram@chromium.org <sreeram@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-12-04 19:14:59 +0000
commitcd533bfe78bbc2aaed9cbb899797978e166cd306 (patch)
tree817e4c646aa9492b9431680d8b51ff749ea60231 /chrome/browser/ui/browser_instant_controller.cc
parentd758e637ec2746870ca221d501d4726242f06c3e (diff)
downloadchromium_src-cd533bfe78bbc2aaed9cbb899797978e166cd306.zip
chromium_src-cd533bfe78bbc2aaed9cbb899797978e166cd306.tar.gz
chromium_src-cd533bfe78bbc2aaed9cbb899797978e166cd306.tar.bz2
Persist the Instant API to committed search result pages.
Whenever the active tab is an Instant search results page, |instant_tab_| is used to talk the Instant API with it. Also: + Replace uses of TabContents with WebContents as much as possible (in service of @avi's goal, http://crbug.com/107201). + Aggressively create the InstantLoader in many situations; update browser tests accordingly. + Don't send an initial resize on page load. This was only relevant for the erstwhile hidden Instant modes. + Delay delete the loader only when strictly necessary, such as when an InstantLoader method is on the call stack. At other times, prefer the much simpler loader_.reset(). + Don't bother resetting state. Resetting state has no practical benefit, since we already only use state variables when they are valid. Instead, this avoids tricky situations where we should NOT reset state just because the |loader_| is deleted (since the |instant_tab_| may still be in use). + Given the above two, remove DeleteLoader() entirely. + Separate out the magic in Hide() into three pieces: Hide(), HideInternal() and a couple of places where we want to preserve |last_full_text_|. I think this makes things slightly clearer. BUG=158942 R=jered@chromium.org,samarth@chromium.org,sky@chromium.org TEST=Commit a query. Change mode to News. Type another query. You should see results in News mode. Review URL: https://chromiumcodereview.appspot.com/11421079 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171018 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/browser_instant_controller.cc')
-rw-r--r--chrome/browser/ui/browser_instant_controller.cc26
1 files changed, 11 insertions, 15 deletions
diff --git a/chrome/browser/ui/browser_instant_controller.cc b/chrome/browser/ui/browser_instant_controller.cc
index 3cab847..b9ae096 100644
--- a/chrome/browser/ui/browser_instant_controller.cc
+++ b/chrome/browser/ui/browser_instant_controller.cc
@@ -4,18 +4,15 @@
#include "chrome/browser/ui/browser_instant_controller.h"
-#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/prefs/pref_service.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/browser.h"
-#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/omnibox/location_bar.h"
#include "chrome/browser/ui/search/search.h"
-#include "chrome/browser/ui/search/search_model.h"
#include "chrome/browser/ui/search/search_tab_helper.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
@@ -23,7 +20,6 @@
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/notification_service.h"
-#include "content/public/browser/web_contents.h"
#include "grit/theme_resources.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/sys_color_change_listener.h"
@@ -88,23 +84,24 @@ bool BrowserInstantController::OpenInstant(WindowOpenDisposition disposition) {
INSTANT_COMMIT_PRESSED_ENTER : INSTANT_COMMIT_PRESSED_ALT_ENTER);
}
-void BrowserInstantController::CommitInstant(TabContents* preview,
+void BrowserInstantController::CommitInstant(content::WebContents* preview,
bool in_new_tab) {
if (in_new_tab) {
// TabStripModel takes ownership of |preview|.
- browser_->tab_strip_model()->AddWebContents(preview->web_contents(), -1,
+ browser_->tab_strip_model()->AddWebContents(preview, -1,
instant_.last_transition_type(), TabStripModel::ADD_ACTIVE);
} else {
- TabContents* active_tab =
- browser_->tab_strip_model()->GetActiveTabContents();
- int index = browser_->tab_strip_model()->GetIndexOfTabContents(active_tab);
+ content::WebContents* active_tab =
+ browser_->tab_strip_model()->GetActiveWebContents();
+ int index = browser_->tab_strip_model()->GetIndexOfWebContents(active_tab);
DCHECK_NE(TabStripModel::kNoTab, index);
// TabStripModel takes ownership of |preview|.
- browser_->tab_strip_model()->ReplaceTabContentsAt(index, preview);
+ browser_->tab_strip_model()->ReplaceTabContentsAt(index,
+ TabContents::FromWebContents(preview));
// InstantUnloadHandler takes ownership of |active_tab|.
instant_unload_handler_.RunUnloadListenersOrDestroy(active_tab, index);
- GURL url = preview->web_contents()->GetURL();
+ GURL url = preview->GetURL();
DCHECK(browser_->profile()->GetExtensionService());
if (browser_->profile()->GetExtensionService()->IsInstalledApp(url)) {
AppLauncherHandler::RecordAppLaunchType(
@@ -125,12 +122,11 @@ gfx::Rect BrowserInstantController::GetInstantBounds() {
void BrowserInstantController::InstantPreviewFocused() {
// NOTE: This is only invoked on aura.
- browser_->window()->WebContentsFocused(
- instant_.GetPreviewContents()->web_contents());
+ browser_->window()->WebContentsFocused(instant_.GetPreviewContents());
}
-TabContents* BrowserInstantController::GetActiveTabContents() const {
- return browser_->tab_strip_model()->GetActiveTabContents();
+content::WebContents* BrowserInstantController::GetActiveWebContents() const {
+ return browser_->tab_strip_model()->GetActiveWebContents();
}
void BrowserInstantController::ActiveTabChanged() {