Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: chrome/browser/ui/browser_instant_controller.cc

Issue 11421079: Persist the Instant API to committed search result pages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Kittens live! Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/browser_instant_controller.h" 5 #include "chrome/browser/ui/browser_instant_controller.h"
6 6
7 #include "chrome/browser/browser_shutdown.h"
8 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/prefs/pref_service.h" 8 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/themes/theme_service.h" 10 #include "chrome/browser/themes/theme_service.h"
12 #include "chrome/browser/themes/theme_service_factory.h" 11 #include "chrome/browser/themes/theme_service_factory.h"
13 #include "chrome/browser/ui/browser.h" 12 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_tabstrip.h"
15 #include "chrome/browser/ui/browser_window.h" 13 #include "chrome/browser/ui/browser_window.h"
16 #include "chrome/browser/ui/omnibox/location_bar.h" 14 #include "chrome/browser/ui/omnibox/location_bar.h"
17 #include "chrome/browser/ui/search/search.h" 15 #include "chrome/browser/ui/search/search.h"
18 #include "chrome/browser/ui/search/search_model.h"
19 #include "chrome/browser/ui/search/search_tab_helper.h" 16 #include "chrome/browser/ui/search/search_tab_helper.h"
20 #include "chrome/browser/ui/tab_contents/tab_contents.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" 19 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
23 #include "chrome/common/chrome_notification_types.h" 20 #include "chrome/common/chrome_notification_types.h"
24 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
25 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/web_contents.h"
27 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
28 #include "ui/gfx/color_utils.h" 24 #include "ui/gfx/color_utils.h"
29 #include "ui/gfx/sys_color_change_listener.h" 25 #include "ui/gfx/sys_color_change_listener.h"
30 26
31 27
32 namespace chrome { 28 namespace chrome {
33 29
34 //////////////////////////////////////////////////////////////////////////////// 30 ////////////////////////////////////////////////////////////////////////////////
35 // BrowserInstantController, public: 31 // BrowserInstantController, public:
36 32
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // The omnibox currently doesn't use other dispositions, so we don't attempt 77 // The omnibox currently doesn't use other dispositions, so we don't attempt
82 // to handle them. If you hit this DCHECK file a bug and I'll (sky) add 78 // to handle them. If you hit this DCHECK file a bug and I'll (sky) add
83 // support for the new disposition. 79 // support for the new disposition.
84 DCHECK(disposition == CURRENT_TAB || 80 DCHECK(disposition == CURRENT_TAB ||
85 disposition == NEW_FOREGROUND_TAB) << disposition; 81 disposition == NEW_FOREGROUND_TAB) << disposition;
86 82
87 return instant_.CommitIfCurrent(disposition == CURRENT_TAB ? 83 return instant_.CommitIfCurrent(disposition == CURRENT_TAB ?
88 INSTANT_COMMIT_PRESSED_ENTER : INSTANT_COMMIT_PRESSED_ALT_ENTER); 84 INSTANT_COMMIT_PRESSED_ENTER : INSTANT_COMMIT_PRESSED_ALT_ENTER);
89 } 85 }
90 86
91 void BrowserInstantController::CommitInstant(TabContents* preview, 87 void BrowserInstantController::CommitInstant(content::WebContents* preview,
92 bool in_new_tab) { 88 bool in_new_tab) {
93 if (in_new_tab) { 89 if (in_new_tab) {
94 // TabStripModel takes ownership of |preview|. 90 // TabStripModel takes ownership of |preview|.
95 browser_->tab_strip_model()->AddTabContents(preview, -1, 91 browser_->tab_strip_model()->AddTabContents(
92 TabContents::FromWebContents(preview), -1,
96 instant_.last_transition_type(), TabStripModel::ADD_ACTIVE); 93 instant_.last_transition_type(), TabStripModel::ADD_ACTIVE);
97 } else { 94 } else {
98 TabContents* active_tab = 95 content::WebContents* active_tab =
99 browser_->tab_strip_model()->GetActiveTabContents(); 96 browser_->tab_strip_model()->GetActiveWebContents();
100 int index = browser_->tab_strip_model()->GetIndexOfTabContents(active_tab); 97 int index = browser_->tab_strip_model()->GetIndexOfWebContents(active_tab);
101 DCHECK_NE(TabStripModel::kNoTab, index); 98 DCHECK_NE(TabStripModel::kNoTab, index);
102 // TabStripModel takes ownership of |preview|. 99 // TabStripModel takes ownership of |preview|.
103 browser_->tab_strip_model()->ReplaceTabContentsAt(index, preview); 100 browser_->tab_strip_model()->ReplaceTabContentsAt(index,
101 TabContents::FromWebContents(preview));
104 // InstantUnloadHandler takes ownership of |active_tab|. 102 // InstantUnloadHandler takes ownership of |active_tab|.
105 instant_unload_handler_.RunUnloadListenersOrDestroy(active_tab, index); 103 instant_unload_handler_.RunUnloadListenersOrDestroy(active_tab, index);
106 104
107 GURL url = preview->web_contents()->GetURL(); 105 GURL url = preview->GetURL();
108 DCHECK(browser_->profile()->GetExtensionService()); 106 DCHECK(browser_->profile()->GetExtensionService());
109 if (browser_->profile()->GetExtensionService()->IsInstalledApp(url)) { 107 if (browser_->profile()->GetExtensionService()->IsInstalledApp(url)) {
110 AppLauncherHandler::RecordAppLaunchType( 108 AppLauncherHandler::RecordAppLaunchType(
111 extension_misc::APP_LAUNCH_OMNIBOX_INSTANT); 109 extension_misc::APP_LAUNCH_OMNIBOX_INSTANT);
112 } 110 }
113 } 111 }
114 } 112 }
115 113
116 void BrowserInstantController::SetInstantSuggestion( 114 void BrowserInstantController::SetInstantSuggestion(
117 const InstantSuggestion& suggestion) { 115 const InstantSuggestion& suggestion) {
118 if (browser_->window()->GetLocationBar()) 116 if (browser_->window()->GetLocationBar())
119 browser_->window()->GetLocationBar()->SetInstantSuggestion(suggestion); 117 browser_->window()->GetLocationBar()->SetInstantSuggestion(suggestion);
120 } 118 }
121 119
122 gfx::Rect BrowserInstantController::GetInstantBounds() { 120 gfx::Rect BrowserInstantController::GetInstantBounds() {
123 return browser_->window()->GetInstantBounds(); 121 return browser_->window()->GetInstantBounds();
124 } 122 }
125 123
126 void BrowserInstantController::InstantPreviewFocused() { 124 void BrowserInstantController::InstantPreviewFocused() {
127 // NOTE: This is only invoked on aura. 125 // NOTE: This is only invoked on aura.
128 browser_->window()->WebContentsFocused( 126 browser_->window()->WebContentsFocused(instant_.GetPreviewContents());
129 instant_.GetPreviewContents()->web_contents());
130 } 127 }
131 128
132 TabContents* BrowserInstantController::GetActiveTabContents() const { 129 content::WebContents* BrowserInstantController::GetActiveWebContents() const {
133 return browser_->tab_strip_model()->GetActiveTabContents(); 130 return browser_->tab_strip_model()->GetActiveWebContents();
134 } 131 }
135 132
136 void BrowserInstantController::ActiveTabChanged() { 133 void BrowserInstantController::ActiveTabChanged() {
137 instant_.ActiveTabChanged(); 134 instant_.ActiveTabChanged();
138 } 135 }
139 136
140 void BrowserInstantController::SetContentHeight(int height) { 137 void BrowserInstantController::SetContentHeight(int height) {
141 OnThemeAreaHeightChanged(height); 138 OnThemeAreaHeightChanged(height);
142 } 139 }
143 140
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // part of the image overlay should draw, 'cos the origin is top-left. 265 // part of the image overlay should draw, 'cos the origin is top-left.
269 if (!browser_->search_model()->mode().is_ntp() || 266 if (!browser_->search_model()->mode().is_ntp() ||
270 theme_info_.theme_id.empty() || 267 theme_info_.theme_id.empty() ||
271 theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) { 268 theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) {
272 return; 269 return;
273 } 270 }
274 instant_.ThemeAreaHeightChanged(theme_area_height_); 271 instant_.ThemeAreaHeightChanged(theme_area_height_);
275 } 272 }
276 273
277 } // namespace chrome 274 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698