OLD | NEW |
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/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/themes/theme_service.h" | 10 #include "chrome/browser/themes/theme_service.h" |
11 #include "chrome/browser/themes/theme_service_factory.h" | 11 #include "chrome/browser/themes/theme_service_factory.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
14 #include "chrome/browser/ui/omnibox/location_bar.h" | 14 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 15 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
15 #include "chrome/browser/ui/search/search.h" | 16 #include "chrome/browser/ui/search/search.h" |
16 #include "chrome/browser/ui/search/search_tab_helper.h" | 17 #include "chrome/browser/ui/search/search_tab_helper.h" |
17 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
19 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 20 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
20 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
23 #include "grit/theme_resources.h" | 24 #include "grit/theme_resources.h" |
24 #include "ui/gfx/color_utils.h" | 25 #include "ui/gfx/color_utils.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 DCHECK(browser_->profile()->GetExtensionService()); | 106 DCHECK(browser_->profile()->GetExtensionService()); |
106 if (browser_->profile()->GetExtensionService()->IsInstalledApp(url)) { | 107 if (browser_->profile()->GetExtensionService()->IsInstalledApp(url)) { |
107 AppLauncherHandler::RecordAppLaunchType( | 108 AppLauncherHandler::RecordAppLaunchType( |
108 extension_misc::APP_LAUNCH_OMNIBOX_INSTANT); | 109 extension_misc::APP_LAUNCH_OMNIBOX_INSTANT); |
109 } | 110 } |
110 } | 111 } |
111 } | 112 } |
112 | 113 |
113 void BrowserInstantController::SetInstantSuggestion( | 114 void BrowserInstantController::SetInstantSuggestion( |
114 const InstantSuggestion& suggestion) { | 115 const InstantSuggestion& suggestion) { |
115 if (browser_->window()->GetLocationBar()) | 116 browser_->window()->GetLocationBar()->SetInstantSuggestion(suggestion); |
116 browser_->window()->GetLocationBar()->SetInstantSuggestion(suggestion); | |
117 } | 117 } |
118 | 118 |
119 gfx::Rect BrowserInstantController::GetInstantBounds() { | 119 gfx::Rect BrowserInstantController::GetInstantBounds() { |
120 return browser_->window()->GetInstantBounds(); | 120 return browser_->window()->GetInstantBounds(); |
121 } | 121 } |
122 | 122 |
123 void BrowserInstantController::InstantPreviewFocused() { | 123 void BrowserInstantController::InstantPreviewFocused() { |
124 // NOTE: This is only invoked on aura. | 124 // NOTE: This is only invoked on aura. |
125 browser_->window()->WebContentsFocused(instant_.GetPreviewContents()); | 125 browser_->window()->WebContentsFocused(instant_.GetPreviewContents()); |
126 } | 126 } |
127 | 127 |
| 128 void BrowserInstantController::FocusOmniboxInvisibly() { |
| 129 OmniboxView* omnibox_view = browser_->window()->GetLocationBar()-> |
| 130 GetLocationEntry(); |
| 131 omnibox_view->SetFocus(); |
| 132 omnibox_view->model()->SetCaretVisibility(false); |
| 133 } |
| 134 |
128 content::WebContents* BrowserInstantController::GetActiveWebContents() const { | 135 content::WebContents* BrowserInstantController::GetActiveWebContents() const { |
129 return browser_->tab_strip_model()->GetActiveWebContents(); | 136 return browser_->tab_strip_model()->GetActiveWebContents(); |
130 } | 137 } |
131 | 138 |
132 void BrowserInstantController::ActiveTabChanged() { | 139 void BrowserInstantController::ActiveTabChanged() { |
133 instant_.ActiveTabChanged(); | 140 instant_.ActiveTabChanged(); |
134 } | 141 } |
135 | 142 |
136 void BrowserInstantController::SetContentHeight(int height) { | 143 void BrowserInstantController::SetContentHeight(int height) { |
137 OnThemeAreaHeightChanged(height); | 144 OnThemeAreaHeightChanged(height); |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 // part of the image overlay should draw, 'cos the origin is top-left. | 271 // part of the image overlay should draw, 'cos the origin is top-left. |
265 if (!browser_->search_model()->mode().is_ntp() || | 272 if (!browser_->search_model()->mode().is_ntp() || |
266 theme_info_.theme_id.empty() || | 273 theme_info_.theme_id.empty() || |
267 theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) { | 274 theme_info_.image_vertical_alignment == THEME_BKGRND_IMAGE_ALIGN_TOP) { |
268 return; | 275 return; |
269 } | 276 } |
270 instant_.ThemeAreaHeightChanged(theme_area_height_); | 277 instant_.ThemeAreaHeightChanged(theme_area_height_); |
271 } | 278 } |
272 | 279 |
273 } // namespace chrome | 280 } // namespace chrome |
OLD | NEW |