Chromium Code Reviews| 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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
| 9 #include "chrome/browser/extensions/extension_web_ui.h" | 9 #include "chrome/browser/extensions/extension_web_ui.h" |
| 10 #include "chrome/browser/instant/search.h" | 10 #include "chrome/browser/instant/search.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 &source_contents->GetController()); | 100 &source_contents->GetController()); |
| 101 ReplaceWebContentsAt( | 101 ReplaceWebContentsAt( |
| 102 browser_->tab_strip_model()->GetIndexOfWebContents(source_contents), | 102 browser_->tab_strip_model()->GetIndexOfWebContents(source_contents), |
| 103 instant_ntp.Pass()); | 103 instant_ntp.Pass()); |
| 104 } else { | 104 } else { |
| 105 instant_ntp->GetController().PruneAllButActive(); | 105 instant_ntp->GetController().PruneAllButActive(); |
| 106 // If |source_contents| is NULL, then the caller is responsible for | 106 // If |source_contents| is NULL, then the caller is responsible for |
| 107 // inserting instant_ntp into the tabstrip and will take ownership. | 107 // inserting instant_ntp into the tabstrip and will take ownership. |
| 108 ignore_result(instant_ntp.release()); | 108 ignore_result(instant_ntp.release()); |
| 109 } | 109 } |
| 110 content::RecordAction(UserMetricsAction("InstantExtended.ShowNTP")); | |
| 111 return true; | 110 return true; |
| 112 } | 111 } |
| 113 | 112 |
| 114 bool BrowserInstantController::OpenInstant(WindowOpenDisposition disposition) { | 113 bool BrowserInstantController::OpenInstant(WindowOpenDisposition disposition) { |
| 115 // Unsupported dispositions. | 114 // Unsupported dispositions. |
| 116 if (disposition == NEW_BACKGROUND_TAB || disposition == NEW_WINDOW) | 115 if (disposition == NEW_BACKGROUND_TAB || disposition == NEW_WINDOW) |
| 117 return false; | 116 return false; |
| 118 | 117 |
| 119 // The omnibox currently doesn't use other dispositions, so we don't attempt | 118 // The omnibox currently doesn't use other dispositions, so we don't attempt |
| 120 // to handle them. If you hit this DCHECK file a bug and I'll (sky) add | 119 // to handle them. If you hit this DCHECK file a bug and I'll (sky) add |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 (!instant_pref_enabled && | 231 (!instant_pref_enabled && |
| 233 !profile()->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled)); | 232 !profile()->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled)); |
| 234 instant_.SetInstantEnabled(instant_pref_enabled, use_local_overlay_only); | 233 instant_.SetInstantEnabled(instant_pref_enabled, use_local_overlay_only); |
| 235 } | 234 } |
| 236 | 235 |
| 237 //////////////////////////////////////////////////////////////////////////////// | 236 //////////////////////////////////////////////////////////////////////////////// |
| 238 // BrowserInstantController, search::SearchModelObserver implementation: | 237 // BrowserInstantController, search::SearchModelObserver implementation: |
| 239 | 238 |
| 240 void BrowserInstantController::ModeChanged(const search::Mode& old_mode, | 239 void BrowserInstantController::ModeChanged(const search::Mode& old_mode, |
| 241 const search::Mode& new_mode) { | 240 const search::Mode& new_mode) { |
| 241 if (search::IsInstantExtendedAPIEnabled()) { | |
| 242 if (new_mode.is_search_results()) | |
| 243 content::RecordAction(UserMetricsAction("InstantExtended.ShowSRP")); | |
| 244 else if (new_mode.is_ntp()) | |
| 245 content::RecordAction(UserMetricsAction("InstantExtended.ShowNTP")); | |
|
samarth
2013/03/08 22:44:18
Sorry, I tried to follow Sreeram and your discussi
samarth
2013/03/08 22:48:11
OK, Sreeram pointed me to the internal thread that
Alexei Svitkine (slow)
2013/03/11 15:13:42
Comment added.
| |
| 246 } | |
| 247 | |
| 242 // If mode is now |NTP|, send theme-related information to Instant. | 248 // If mode is now |NTP|, send theme-related information to Instant. |
| 243 if (new_mode.is_ntp()) | 249 if (new_mode.is_ntp()) |
| 244 UpdateThemeInfo(); | 250 UpdateThemeInfo(); |
| 245 | 251 |
| 246 instant_.SearchModeChanged(old_mode, new_mode); | 252 instant_.SearchModeChanged(old_mode, new_mode); |
| 247 } | 253 } |
| 248 | 254 |
| 249 //////////////////////////////////////////////////////////////////////////////// | 255 //////////////////////////////////////////////////////////////////////////////// |
| 250 // BrowserInstantController, content::NotificationObserver implementation: | 256 // BrowserInstantController, content::NotificationObserver implementation: |
| 251 | 257 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 327 initialized_theme_info_ = true; | 333 initialized_theme_info_ = true; |
| 328 } | 334 } |
| 329 | 335 |
| 330 DCHECK(initialized_theme_info_); | 336 DCHECK(initialized_theme_info_); |
| 331 | 337 |
| 332 if (browser_->search_model()->mode().is_ntp()) | 338 if (browser_->search_model()->mode().is_ntp()) |
| 333 instant_.ThemeChanged(theme_info_); | 339 instant_.ThemeChanged(theme_info_); |
| 334 } | 340 } |
| 335 | 341 |
| 336 } // namespace chrome | 342 } // namespace chrome |
| OLD | NEW |