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

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: Rebase. 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 if (search_terms.empty()) 136 if (search_terms.empty())
138 return false; 137 return false;
139 138
140 return instant_.SubmitQuery(search_terms); 139 return instant_.SubmitQuery(search_terms);
141 } 140 }
142 141
143 Profile* BrowserInstantController::profile() const { 142 Profile* BrowserInstantController::profile() const {
144 return browser_->profile(); 143 return browser_->profile();
145 } 144 }
146 145
147 void BrowserInstantController::CommitInstant(
148 scoped_ptr<content::WebContents> overlay,
149 bool in_new_tab) {
150 const extensions::Extension* extension =
151 profile()->GetExtensionService()->GetInstalledApp(overlay->GetURL());
152 if (extension) {
153 AppLauncherHandler::RecordAppLaunchType(
154 extension_misc::APP_LAUNCH_OMNIBOX_INSTANT,
155 extension->GetType());
156 }
157 if (in_new_tab) {
158 // TabStripModel takes ownership of |overlay|.
159 browser_->tab_strip_model()->AddWebContents(overlay.release(), -1,
160 instant_.last_transition_type(), TabStripModel::ADD_ACTIVE);
161 } else {
162 content::WebContents* contents = overlay.get();
163 ReplaceWebContentsAt(
164 browser_->tab_strip_model()->active_index(),
165 overlay.Pass());
166 browser_->window()->GetLocationBar()->SaveStateToContents(contents);
167 }
168 }
169
170 void BrowserInstantController::ReplaceWebContentsAt( 146 void BrowserInstantController::ReplaceWebContentsAt(
171 int index, 147 int index,
172 scoped_ptr<content::WebContents> new_contents) { 148 scoped_ptr<content::WebContents> new_contents) {
173 DCHECK_NE(TabStripModel::kNoTab, index); 149 DCHECK_NE(TabStripModel::kNoTab, index);
174 scoped_ptr<content::WebContents> old_contents(browser_->tab_strip_model()-> 150 scoped_ptr<content::WebContents> old_contents(browser_->tab_strip_model()->
175 ReplaceWebContentsAt(index, new_contents.release())); 151 ReplaceWebContentsAt(index, new_contents.release()));
176 instant_unload_handler_.RunUnloadListenersOrDestroy(old_contents.Pass(), 152 instant_unload_handler_.RunUnloadListenersOrDestroy(old_contents.Pass(),
177 index); 153 index);
178 } 154 }
179 155
180 void BrowserInstantController::SetInstantSuggestion(
181 const InstantSuggestion& suggestion) {
182 browser_->window()->GetLocationBar()->SetInstantSuggestion(suggestion);
183 }
184
185 gfx::Rect BrowserInstantController::GetInstantBounds() {
186 return browser_->window()->GetInstantBounds();
187 }
188
189 void BrowserInstantController::InstantOverlayFocused() {
190 // NOTE: This is only invoked on aura.
191 browser_->window()->WebContentsFocused(instant_.GetOverlayContents());
192 }
193
194 void BrowserInstantController::FocusOmnibox(bool caret_visibility) { 156 void BrowserInstantController::FocusOmnibox(bool caret_visibility) {
195 OmniboxView* omnibox_view = browser_->window()->GetLocationBar()-> 157 OmniboxView* omnibox_view = browser_->window()->GetLocationBar()->
196 GetLocationEntry(); 158 GetLocationEntry();
197 omnibox_view->SetFocus(); 159 omnibox_view->SetFocus();
198 omnibox_view->model()->SetCaretVisibility(caret_visibility); 160 omnibox_view->model()->SetCaretVisibility(caret_visibility);
199 if (!caret_visibility) { 161 if (!caret_visibility) {
200 // If the user clicked on the fakebox, any text already in the omnibox 162 // If the user clicked on the fakebox, any text already in the omnibox
201 // should get cleared when they start typing. Selecting all the existing 163 // should get cleared when they start typing. Selecting all the existing
202 // text is a convenient way to accomplish this. It also gives a slight 164 // text is a convenient way to accomplish this. It also gives a slight
203 // visual cue to users who really understand selection state about what will 165 // visual cue to users who really understand selection state about what will
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 197
236 void BrowserInstantController::UpdateLocationBar() { 198 void BrowserInstantController::UpdateLocationBar() {
237 browser_->window()->UpdateToolbar(GetActiveWebContents(), false); 199 browser_->window()->UpdateToolbar(GetActiveWebContents(), false);
238 } 200 }
239 201
240 void BrowserInstantController::ToggleVoiceSearch() { 202 void BrowserInstantController::ToggleVoiceSearch() {
241 instant_.ToggleVoiceSearch(); 203 instant_.ToggleVoiceSearch();
242 } 204 }
243 205
244 void BrowserInstantController::ResetInstant(const std::string& pref_name) { 206 void BrowserInstantController::ResetInstant(const std::string& pref_name) {
245 bool instant_checkbox_checked = chrome::IsInstantCheckboxChecked(profile()); 207 instant_.ReloadStaleNTP();
246 bool use_local_overlay_only = !chrome::IsInstantCheckboxEnabled(profile());
247 instant_.SetInstantEnabled(instant_checkbox_checked, use_local_overlay_only);
248 } 208 }
249 209
250 //////////////////////////////////////////////////////////////////////////////// 210 ////////////////////////////////////////////////////////////////////////////////
251 // BrowserInstantController, SearchModelObserver implementation: 211 // BrowserInstantController, SearchModelObserver implementation:
252 212
253 void BrowserInstantController::ModelChanged( 213 void BrowserInstantController::ModelChanged(
254 const SearchModel::State& old_state, 214 const SearchModel::State& old_state,
255 const SearchModel::State& new_state) { 215 const SearchModel::State& new_state) {
256 if (old_state.mode != new_state.mode) { 216 if (old_state.mode != new_state.mode) {
257 const SearchMode& new_mode = new_state.mode; 217 const SearchMode& new_mode = new_state.mode;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 if (!instant_service->IsInstantProcess( 274 if (!instant_service->IsInstantProcess(
315 contents->GetRenderProcessHost()->GetID())) 275 contents->GetRenderProcessHost()->GetID()))
316 continue; 276 continue;
317 277
318 // Reload the contents to ensure that it gets assigned to a non-priviledged 278 // Reload the contents to ensure that it gets assigned to a non-priviledged
319 // renderer. 279 // renderer.
320 contents->GetController().Reload(false); 280 contents->GetController().Reload(false);
321 } 281 }
322 instant_.OnDefaultSearchProviderChanged(); 282 instant_.OnDefaultSearchProviderChanged();
323 } 283 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698