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/search/search_tab_helper.h" | 5 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 390 void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { | 390 void SearchTabHelper::ThemeInfoChanged(const ThemeBackgroundInfo& theme_info) { |
| 391 ipc_router_.SendThemeBackgroundInfo(theme_info); | 391 ipc_router_.SendThemeBackgroundInfo(theme_info); |
| 392 } | 392 } |
| 393 | 393 |
| 394 void SearchTabHelper::MostVisitedItemsChanged( | 394 void SearchTabHelper::MostVisitedItemsChanged( |
| 395 const std::vector<InstantMostVisitedItem>& items) { | 395 const std::vector<InstantMostVisitedItem>& items) { |
| 396 // When most visited change, the NTP usually reloads the tiles. This means | 396 // When most visited change, the NTP usually reloads the tiles. This means |
| 397 // our metrics get inconsistent. So we'd rather emit stats now. | 397 // our metrics get inconsistent. So we'd rather emit stats now. |
| 398 InstantTab::EmitNtpStatistics(web_contents_); | 398 InstantTab::EmitNtpStatistics(web_contents_); |
| 399 ipc_router_.SendMostVisitedItems(items); | 399 ipc_router_.SendMostVisitedItems(items); |
| 400 this->LogMostVisitedItemsSource(items); | |
|
fserb
2015/10/13 14:34:40
no need for "this->" here.
zmin
2015/10/13 15:08:38
Done.
| |
| 401 } | |
| 402 | |
| 403 void SearchTabHelper::LogMostVisitedItemsSource( | |
| 404 const std::vector<InstantMostVisitedItem>& items) { | |
| 405 NTPLoggingEventType event; | |
|
fserb
2015/10/13 14:34:40
you can move it inside the for().
zmin
2015/10/13 15:08:38
Talk with @fserb. Moving event and time into the f
| |
| 406 base::TimeDelta time = base::TimeDelta(); | |
|
fserb
2015/10/13 14:34:40
you can just pass 0 as time. I'm not even sure thi
zmin
2015/10/13 15:08:38
Talk with @fserb, 0 is the default value of TimeDe
| |
| 407 for (auto item : items) { | |
| 408 if (item.is_server_side_suggestion) { | |
| 409 event = NTP_SERVER_SIDE_SUGGESTION; | |
| 410 } else { | |
| 411 event = NTP_CLIENT_SIDE_SUGGESTION; | |
| 412 } | |
| 413 // Note that the ntp_user_data_logger.cc now only supports the scenario: | |
| 414 // all suggestions are provided by server OR | |
| 415 // all suggestions are provided by client | |
|
fserb
2015/10/13 14:34:40
nit: "." at the end of the comment.
zmin
2015/10/13 15:08:38
Done.
| |
| 416 this->OnLogEvent(event, time); | |
| 417 } | |
| 400 } | 418 } |
| 401 | 419 |
| 402 void SearchTabHelper::OmniboxStartMarginChanged(int omnibox_start_margin) { | 420 void SearchTabHelper::OmniboxStartMarginChanged(int omnibox_start_margin) { |
| 403 ipc_router_.SetOmniboxStartMargin(omnibox_start_margin); | 421 ipc_router_.SetOmniboxStartMargin(omnibox_start_margin); |
| 404 } | 422 } |
| 405 | 423 |
| 406 void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) { | 424 void SearchTabHelper::FocusOmnibox(OmniboxFocusState state) { |
| 407 // TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef. | 425 // TODO(kmadhusu): Move platform specific code from here and get rid of #ifdef. |
| 408 #if !defined(OS_ANDROID) | 426 #if !defined(OS_ANDROID) |
| 409 OmniboxView* omnibox = GetOmniboxView(); | 427 OmniboxView* omnibox = GetOmniboxView(); |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 | 605 |
| 588 bool SearchTabHelper::IsInputInProgress() const { | 606 bool SearchTabHelper::IsInputInProgress() const { |
| 589 OmniboxView* omnibox = GetOmniboxView(); | 607 OmniboxView* omnibox = GetOmniboxView(); |
| 590 return !model_.mode().is_ntp() && omnibox && | 608 return !model_.mode().is_ntp() && omnibox && |
| 591 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; | 609 omnibox->model()->focus_state() == OMNIBOX_FOCUS_VISIBLE; |
| 592 } | 610 } |
| 593 | 611 |
| 594 OmniboxView* SearchTabHelper::GetOmniboxView() const { | 612 OmniboxView* SearchTabHelper::GetOmniboxView() const { |
| 595 return delegate_ ? delegate_->GetOmniboxView() : NULL; | 613 return delegate_ ? delegate_->GetOmniboxView() : NULL; |
| 596 } | 614 } |
| OLD | NEW |