| 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/metrics/user_metrics.h" |
| 8 #include "chrome/browser/infobars/infobar_service.h" | 9 #include "chrome/browser/infobars/infobar_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/instant_service.h" | 11 #include "chrome/browser/search/instant_service.h" |
| 11 #include "chrome/browser/search/instant_service_factory.h" | 12 #include "chrome/browser/search/instant_service_factory.h" |
| 12 #include "chrome/browser/search/search.h" | 13 #include "chrome/browser/search/search.h" |
| 13 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 15 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/location_bar/location_bar.h" | 16 #include "chrome/browser/ui/location_bar/location_bar.h" |
| 16 #include "chrome/browser/ui/search/instant_search_prerenderer.h" | 17 #include "chrome/browser/ui/search/instant_search_prerenderer.h" |
| 17 #include "chrome/browser/ui/search/search_model.h" | 18 #include "chrome/browser/ui/search/search_model.h" |
| 18 #include "chrome/browser/ui/search/search_tab_helper.h" | 19 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 20 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/common/search/instant_types.h" | 21 #include "chrome/common/search/instant_types.h" |
| 21 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 22 #include "components/omnibox/browser/omnibox_popup_model.h" | 23 #include "components/omnibox/browser/omnibox_popup_model.h" |
| 23 #include "components/omnibox/browser/omnibox_view.h" | 24 #include "components/omnibox/browser/omnibox_view.h" |
| 24 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/navigation_controller.h" | 26 #include "content/public/browser/navigation_controller.h" |
| 26 #include "content/public/browser/render_process_host.h" | 27 #include "content/public/browser/render_process_host.h" |
| 27 #include "content/public/browser/user_metrics.h" | |
| 28 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
| 29 #include "content/public/browser/web_contents_user_data.h" | 29 #include "content/public/browser/web_contents_user_data.h" |
| 30 #include "content/public/common/referrer.h" | 30 #include "content/public/common/referrer.h" |
| 31 #include "ui/base/page_transition_types.h" | 31 #include "ui/base/page_transition_types.h" |
| 32 | 32 |
| 33 // Helpers -------------------------------------------------------------------- | 33 // Helpers -------------------------------------------------------------------- |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 // Helper class for posting a task to reload a tab, to avoid doing a re-entrant | 37 // Helper class for posting a task to reload a tab, to avoid doing a re-entrant |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 void BrowserInstantController::ModelChanged( | 152 void BrowserInstantController::ModelChanged( |
| 153 const SearchModel::State& old_state, | 153 const SearchModel::State& old_state, |
| 154 const SearchModel::State& new_state) { | 154 const SearchModel::State& new_state) { |
| 155 if (old_state.mode != new_state.mode) { | 155 if (old_state.mode != new_state.mode) { |
| 156 const SearchMode& new_mode = new_state.mode; | 156 const SearchMode& new_mode = new_state.mode; |
| 157 | 157 |
| 158 // Record some actions corresponding to the mode change. Note that to get | 158 // Record some actions corresponding to the mode change. Note that to get |
| 159 // the full story, it's necessary to look at other UMA actions as well, | 159 // the full story, it's necessary to look at other UMA actions as well, |
| 160 // such as tab switches. | 160 // such as tab switches. |
| 161 if (new_mode.is_ntp()) | 161 if (new_mode.is_ntp()) |
| 162 content::RecordAction(base::UserMetricsAction("InstantExtended.ShowNTP")); | 162 base::RecordAction(base::UserMetricsAction("InstantExtended.ShowNTP")); |
| 163 | 163 |
| 164 instant_.SearchModeChanged(old_state.mode, new_mode); | 164 instant_.SearchModeChanged(old_state.mode, new_mode); |
| 165 } | 165 } |
| 166 | 166 |
| 167 if (old_state.instant_support != new_state.instant_support) | 167 if (old_state.instant_support != new_state.instant_support) |
| 168 instant_.InstantSupportChanged(new_state.instant_support); | 168 instant_.InstantSupportChanged(new_state.instant_support); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void BrowserInstantController::DefaultSearchProviderChanged( | 171 void BrowserInstantController::DefaultSearchProviderChanged( |
| 172 bool google_base_url_domain_changed) { | 172 bool google_base_url_domain_changed) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 198 params.referrer = content::Referrer(); | 198 params.referrer = content::Referrer(); |
| 199 params.transition_type = ui::PAGE_TRANSITION_RELOAD; | 199 params.transition_type = ui::PAGE_TRANSITION_RELOAD; |
| 200 contents->GetController().LoadURLWithParams(params); | 200 contents->GetController().LoadURLWithParams(params); |
| 201 } else { | 201 } else { |
| 202 // Reload the contents to ensure that it gets assigned to a | 202 // Reload the contents to ensure that it gets assigned to a |
| 203 // non-privileged renderer. | 203 // non-privileged renderer. |
| 204 TabReloader::Reload(contents); | 204 TabReloader::Reload(contents); |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 } | 207 } |
| OLD | NEW |