| 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 "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" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/browser/search/instant_service.h" | 12 #include "chrome/browser/search/instant_service.h" |
| 13 #include "chrome/browser/search/instant_service_factory.h" | 13 #include "chrome/browser/search/instant_service_factory.h" |
| 14 #include "chrome/browser/search/search.h" | 14 #include "chrome/browser/search/search.h" |
| 15 #include "chrome/browser/search_engines/template_url.h" | 15 #include "chrome/browser/search_engines/template_url.h" |
| 16 #include "chrome/browser/search_engines/template_url_service.h" | 16 #include "chrome/browser/search_engines/template_url_service.h" |
| 17 #include "chrome/browser/search_engines/template_url_service_factory.h" | 17 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 18 #include "chrome/browser/themes/theme_properties.h" | 18 #include "chrome/browser/themes/theme_properties.h" |
| 19 #include "chrome/browser/themes/theme_service.h" | 19 #include "chrome/browser/themes/theme_service.h" |
| 20 #include "chrome/browser/themes/theme_service_factory.h" | 20 #include "chrome/browser/themes/theme_service_factory.h" |
| 21 #include "chrome/browser/ui/browser.h" | 21 #include "chrome/browser/ui/browser.h" |
| 22 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
| 23 #include "chrome/browser/ui/omnibox/location_bar.h" | 23 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 24 #include "chrome/browser/ui/omnibox/omnibox_view.h" | 24 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
| 25 #include "chrome/browser/ui/search/search_model.h" |
| 25 #include "chrome/browser/ui/search/search_tab_helper.h" | 26 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 26 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 27 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 27 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 28 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
| 28 #include "chrome/common/chrome_notification_types.h" | 29 #include "chrome/common/chrome_notification_types.h" |
| 29 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 31 #include "components/user_prefs/pref_registry_syncable.h" | 32 #include "components/user_prefs/pref_registry_syncable.h" |
| 32 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
| 33 #include "content/public/browser/render_process_host.h" | 34 #include "content/public/browser/render_process_host.h" |
| 34 #include "content/public/browser/user_metrics.h" | 35 #include "content/public/browser/user_metrics.h" |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 !chrome::IsInstantCheckboxEnabled(profile()); | 269 !chrome::IsInstantCheckboxEnabled(profile()); |
| 269 instant_.SetInstantEnabled(instant_checkbox_checked, use_local_overlay_only); | 270 instant_.SetInstantEnabled(instant_checkbox_checked, use_local_overlay_only); |
| 270 } | 271 } |
| 271 | 272 |
| 272 //////////////////////////////////////////////////////////////////////////////// | 273 //////////////////////////////////////////////////////////////////////////////// |
| 273 // BrowserInstantController, SearchModelObserver implementation: | 274 // BrowserInstantController, SearchModelObserver implementation: |
| 274 | 275 |
| 275 void BrowserInstantController::ModelChanged( | 276 void BrowserInstantController::ModelChanged( |
| 276 const SearchModel::State& old_state, | 277 const SearchModel::State& old_state, |
| 277 const SearchModel::State& new_state) { | 278 const SearchModel::State& new_state) { |
| 278 if (old_state.mode == new_state.mode) | 279 if (old_state.mode != new_state.mode) { |
| 279 return; | 280 const SearchMode& new_mode = new_state.mode; |
| 280 | 281 |
| 281 const SearchMode& new_mode = new_state.mode; | 282 if (chrome::IsInstantExtendedAPIEnabled()) { |
| 283 // Record some actions corresponding to the mode change. Note that to get |
| 284 // the full story, it's necessary to look at other UMA actions as well, |
| 285 // such as tab switches. |
| 286 if (new_mode.is_search_results()) |
| 287 content::RecordAction(UserMetricsAction("InstantExtended.ShowSRP")); |
| 288 else if (new_mode.is_ntp()) |
| 289 content::RecordAction(UserMetricsAction("InstantExtended.ShowNTP")); |
| 290 } |
| 282 | 291 |
| 283 if (chrome::IsInstantExtendedAPIEnabled()) { | 292 // If mode is now |NTP|, send theme-related information to Instant. |
| 284 // Record some actions corresponding to the mode change. Note that to get | 293 if (new_mode.is_ntp()) |
| 285 // the full story, it's necessary to look at other UMA actions as well, | 294 UpdateThemeInfo(); |
| 286 // such as tab switches. | 295 |
| 287 if (new_mode.is_search_results()) | 296 instant_.SearchModeChanged(old_state.mode, new_mode); |
| 288 content::RecordAction(UserMetricsAction("InstantExtended.ShowSRP")); | |
| 289 else if (new_mode.is_ntp()) | |
| 290 content::RecordAction(UserMetricsAction("InstantExtended.ShowNTP")); | |
| 291 } | 297 } |
| 292 | 298 |
| 293 // If mode is now |NTP|, send theme-related information to Instant. | 299 if (old_state.instant_support != new_state.instant_support) |
| 294 if (new_mode.is_ntp()) | 300 instant_.InstantSupportChanged(new_state.instant_support); |
| 295 UpdateThemeInfo(); | |
| 296 | |
| 297 instant_.SearchModeChanged(old_state.mode, new_mode); | |
| 298 } | 301 } |
| 299 | 302 |
| 300 //////////////////////////////////////////////////////////////////////////////// | 303 //////////////////////////////////////////////////////////////////////////////// |
| 301 // BrowserInstantController, content::NotificationObserver implementation: | 304 // BrowserInstantController, content::NotificationObserver implementation: |
| 302 | 305 |
| 303 void BrowserInstantController::Observe( | 306 void BrowserInstantController::Observe( |
| 304 int type, | 307 int type, |
| 305 const content::NotificationSource& source, | 308 const content::NotificationSource& source, |
| 306 const content::NotificationDetails& details) { | 309 const content::NotificationDetails& details) { |
| 307 #if defined(ENABLE_THEMES) | 310 #if defined(ENABLE_THEMES) |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 if (!instant_service->IsInstantProcess( | 431 if (!instant_service->IsInstantProcess( |
| 429 contents->GetRenderProcessHost()->GetID())) | 432 contents->GetRenderProcessHost()->GetID())) |
| 430 continue; | 433 continue; |
| 431 | 434 |
| 432 // Reload the contents to ensure that it gets assigned to a non-priviledged | 435 // Reload the contents to ensure that it gets assigned to a non-priviledged |
| 433 // renderer. | 436 // renderer. |
| 434 contents->GetController().Reload(false); | 437 contents->GetController().Reload(false); |
| 435 } | 438 } |
| 436 instant_.OnDefaultSearchProviderChanged(); | 439 instant_.OnDefaultSearchProviderChanged(); |
| 437 } | 440 } |
| OLD | NEW |