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

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

Issue 18223002: InstantExtended: Remove overlay control code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Call renamed method. Created 7 years, 5 months 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 "base/bind.h" 7 #include "base/bind.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_web_ui.h" 10 #include "chrome/browser/extensions/extension_web_ui.h"
(...skipping 19 matching lines...) Expand all
30 #include "content/public/browser/user_metrics.h" 30 #include "content/public/browser/user_metrics.h"
31 #include "content/public/browser/web_contents.h" 31 #include "content/public/browser/web_contents.h"
32 32
33 using content::UserMetricsAction; 33 using content::UserMetricsAction;
34 34
35 //////////////////////////////////////////////////////////////////////////////// 35 ////////////////////////////////////////////////////////////////////////////////
36 // BrowserInstantController, public: 36 // BrowserInstantController, public:
37 37
38 BrowserInstantController::BrowserInstantController(Browser* browser) 38 BrowserInstantController::BrowserInstantController(Browser* browser)
39 : browser_(browser), 39 : browser_(browser),
40 instant_(this, 40 instant_(this, chrome::IsInstantExtendedAPIEnabled()),
41 chrome::IsInstantExtendedAPIEnabled()),
42 instant_unload_handler_(browser) { 41 instant_unload_handler_(browser) {
43 42
44 // TODO(sreeram): Perhaps this can be removed, if field trial info is 43 // TODO(sreeram): Perhaps this can be removed, if field trial info is
45 // available before we need to register the pref. 44 // available before we need to register the pref.
46 chrome::SetInstantExtendedPrefDefault(profile()); 45 chrome::SetInstantExtendedPrefDefault(profile());
47 46
48 profile_pref_registrar_.Init(profile()->GetPrefs()); 47 profile_pref_registrar_.Init(profile()->GetPrefs());
49 profile_pref_registrar_.Add( 48 profile_pref_registrar_.Add(
50 prefs::kSearchInstantEnabled, 49 prefs::kSearchInstantEnabled,
51 base::Bind(&BrowserInstantController::ResetInstant, 50 base::Bind(&BrowserInstantController::ResetInstant,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 if (search_terms.empty()) 138 if (search_terms.empty())
140 return false; 139 return false;
141 140
142 return instant_.SubmitQuery(search_terms); 141 return instant_.SubmitQuery(search_terms);
143 } 142 }
144 143
145 Profile* BrowserInstantController::profile() const { 144 Profile* BrowserInstantController::profile() const {
146 return browser_->profile(); 145 return browser_->profile();
147 } 146 }
148 147
149 void BrowserInstantController::CommitInstant(
150 scoped_ptr<content::WebContents> overlay,
151 bool in_new_tab) {
152 const extensions::Extension* extension =
153 profile()->GetExtensionService()->GetInstalledApp(overlay->GetURL());
154 if (extension) {
155 AppLauncherHandler::RecordAppLaunchType(
156 extension_misc::APP_LAUNCH_OMNIBOX_INSTANT,
157 extension->GetType());
158 }
159 if (in_new_tab) {
160 // TabStripModel takes ownership of |overlay|.
161 browser_->tab_strip_model()->AddWebContents(overlay.release(), -1,
162 instant_.last_transition_type(), TabStripModel::ADD_ACTIVE);
163 } else {
164 content::WebContents* contents = overlay.get();
165 ReplaceWebContentsAt(
166 browser_->tab_strip_model()->active_index(),
167 overlay.Pass());
168 browser_->window()->GetLocationBar()->SaveStateToContents(contents);
169 }
170 }
171
172 void BrowserInstantController::ReplaceWebContentsAt( 148 void BrowserInstantController::ReplaceWebContentsAt(
173 int index, 149 int index,
174 scoped_ptr<content::WebContents> new_contents) { 150 scoped_ptr<content::WebContents> new_contents) {
175 DCHECK_NE(TabStripModel::kNoTab, index); 151 DCHECK_NE(TabStripModel::kNoTab, index);
176 scoped_ptr<content::WebContents> old_contents(browser_->tab_strip_model()-> 152 scoped_ptr<content::WebContents> old_contents(browser_->tab_strip_model()->
177 ReplaceWebContentsAt(index, new_contents.release())); 153 ReplaceWebContentsAt(index, new_contents.release()));
178 instant_unload_handler_.RunUnloadListenersOrDestroy(old_contents.Pass(), 154 instant_unload_handler_.RunUnloadListenersOrDestroy(old_contents.Pass(),
179 index); 155 index);
180 } 156 }
181 157
182 void BrowserInstantController::SetInstantSuggestion(
183 const InstantSuggestion& suggestion) {
184 browser_->window()->GetLocationBar()->SetInstantSuggestion(suggestion);
185 }
186
187 gfx::Rect BrowserInstantController::GetInstantBounds() {
188 return browser_->window()->GetInstantBounds();
189 }
190
191 void BrowserInstantController::InstantOverlayFocused() {
192 // NOTE: This is only invoked on aura.
193 browser_->window()->WebContentsFocused(instant_.GetOverlayContents());
194 }
195
196 void BrowserInstantController::FocusOmnibox(bool caret_visibility) { 158 void BrowserInstantController::FocusOmnibox(bool caret_visibility) {
197 OmniboxView* omnibox_view = browser_->window()->GetLocationBar()-> 159 OmniboxView* omnibox_view = browser_->window()->GetLocationBar()->
198 GetLocationEntry(); 160 GetLocationEntry();
199 omnibox_view->SetFocus(); 161 omnibox_view->SetFocus();
200 omnibox_view->model()->SetCaretVisibility(caret_visibility); 162 omnibox_view->model()->SetCaretVisibility(caret_visibility);
201 if (!caret_visibility) { 163 if (!caret_visibility) {
202 // If the user clicked on the fakebox, any text already in the omnibox 164 // If the user clicked on the fakebox, any text already in the omnibox
203 // should get cleared when they start typing. Selecting all the existing 165 // should get cleared when they start typing. Selecting all the existing
204 // text is a convenient way to accomplish this. It also gives a slight 166 // text is a convenient way to accomplish this. It also gives a slight
205 // visual cue to users who really understand selection state about what will 167 // visual cue to users who really understand selection state about what will
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 199
238 void BrowserInstantController::UpdateLocationBar() { 200 void BrowserInstantController::UpdateLocationBar() {
239 browser_->window()->UpdateToolbar(GetActiveWebContents(), false); 201 browser_->window()->UpdateToolbar(GetActiveWebContents(), false);
240 } 202 }
241 203
242 void BrowserInstantController::ToggleVoiceSearch() { 204 void BrowserInstantController::ToggleVoiceSearch() {
243 instant_.ToggleVoiceSearch(); 205 instant_.ToggleVoiceSearch();
244 } 206 }
245 207
246 void BrowserInstantController::ResetInstant(const std::string& pref_name) { 208 void BrowserInstantController::ResetInstant(const std::string& pref_name) {
247 bool instant_checkbox_checked = chrome::IsInstantCheckboxChecked(profile()); 209 instant_.ReloadStaleNTP();
248 bool use_local_overlay_only = !chrome::IsInstantCheckboxEnabled(profile());
249 instant_.SetInstantEnabled(instant_checkbox_checked, use_local_overlay_only);
250 } 210 }
251 211
252 //////////////////////////////////////////////////////////////////////////////// 212 ////////////////////////////////////////////////////////////////////////////////
253 // BrowserInstantController, SearchModelObserver implementation: 213 // BrowserInstantController, SearchModelObserver implementation:
254 214
255 void BrowserInstantController::ModelChanged( 215 void BrowserInstantController::ModelChanged(
256 const SearchModel::State& old_state, 216 const SearchModel::State& old_state,
257 const SearchModel::State& new_state) { 217 const SearchModel::State& new_state) {
258 if (old_state.mode != new_state.mode) { 218 if (old_state.mode != new_state.mode) {
259 const SearchMode& new_mode = new_state.mode; 219 const SearchMode& new_mode = new_state.mode;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 if (!instant_service->IsInstantProcess( 285 if (!instant_service->IsInstantProcess(
326 contents->GetRenderProcessHost()->GetID())) 286 contents->GetRenderProcessHost()->GetID()))
327 continue; 287 continue;
328 288
329 // Reload the contents to ensure that it gets assigned to a non-priviledged 289 // Reload the contents to ensure that it gets assigned to a non-priviledged
330 // renderer. 290 // renderer.
331 contents->GetController().Reload(false); 291 contents->GetController().Reload(false);
332 } 292 }
333 instant_.OnDefaultSearchProviderChanged(); 293 instant_.OnDefaultSearchProviderChanged();
334 } 294 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_instant_controller.h ('k') | chrome/browser/ui/cocoa/browser_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698