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/search/search_tab_helper.h" | 5 #include "chrome/browser/ui/search/search_tab_helper.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 void SearchTabHelper::OnInstantSupportDetermined(bool supports_instant) { | 378 void SearchTabHelper::OnInstantSupportDetermined(bool supports_instant) { |
379 InstantSupportChanged(supports_instant); | 379 InstantSupportChanged(supports_instant); |
380 } | 380 } |
381 | 381 |
382 void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { | 382 void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { |
383 ipc_router_.SendThemeBackgroundInfo(theme_info); | 383 ipc_router_.SendThemeBackgroundInfo(theme_info); |
384 } | 384 } |
385 | 385 |
386 void SearchTabHelper::MostVisitedItemsChanged( | 386 void SearchTabHelper::MostVisitedItemsChanged( |
387 const std::vector<InstantMostVisitedItem>& items) { | 387 const std::vector<InstantMostVisitedItem>& items) { |
388 // When most visited change, the NTP usually reloads the tiles. This means | |
389 // our metrics get inconsistent. So we'd rather emit stats now. | |
390 InstantTab::MostVisitedItemsChanged(web_contents_); | |
391 ipc_router_.SendMostVisitedItems(items); | 388 ipc_router_.SendMostVisitedItems(items); |
392 LogMostVisitedItemsSource(items); | |
393 } | |
394 | |
395 void SearchTabHelper::LogMostVisitedItemsSource( | |
396 const std::vector<InstantMostVisitedItem>& items) { | |
397 for (auto item : items) { | |
398 NTPLoggingEventType event; | |
399 if (item.is_server_side_suggestion) { | |
400 event = NTP_SERVER_SIDE_SUGGESTION; | |
401 } else { | |
402 event = NTP_CLIENT_SIDE_SUGGESTION; | |
403 } | |
404 // The metrics are emitted for each suggestion as the design requirement | |
405 // even the ntp_user_data_logger.cc now only supports the scenario: | |
406 // all suggestions are provided by server OR | |
407 // all suggestions are provided by client. | |
408 this->OnLogEvent(event, base::TimeDelta()); | |
409 } | |
410 } | 389 } |
411 | 390 |
412 void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) { | 391 void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) { |
413 // TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef. | 392 // TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef. |
414 #if !defined(OS_ANDROID) | 393 #if !defined(OS_ANDROID) |
415 OmniboxView* omnibox = GetOmniboxView(); | 394 OmniboxView* omnibox = GetOmniboxView(); |
416 if (!omnibox) | 395 if (!omnibox) |
417 return; | 396 return; |
418 | 397 |
419 // Do not add a default case in the switch block for the following reasons: | 398 // Do not add a default case in the switch block for the following reasons: |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 | 560 |
582 bool SearchTabHelper::IsInputInProgress() const { | 561 bool SearchTabHelper::IsInputInProgress() const { |
583 OmniboxView* omnibox = GetOmniboxView(); | 562 OmniboxView* omnibox = GetOmniboxView(); |
584 return !model_.mode().is_ntp() && omnibox && | 563 return !model_.mode().is_ntp() && omnibox && |
585 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 564 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
586 } | 565 } |
587 | 566 |
588 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 567 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
589 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 568 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
590 } | 569 } |
OLD | NEW |