| 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/renderer/searchbox/searchbox.h" | 5 #include "chrome/renderer/searchbox/searchbox.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 display_instant_results_(false), | 153 display_instant_results_(false), |
| 154 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize), | 154 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize), |
| 155 query_(), | 155 query_(), |
| 156 start_margin_(0) { | 156 start_margin_(0) { |
| 157 } | 157 } |
| 158 | 158 |
| 159 SearchBox::~SearchBox() { | 159 SearchBox::~SearchBox() { |
| 160 } | 160 } |
| 161 | 161 |
| 162 void SearchBox::LogEvent(NTPLoggingEventType event) { | 162 void SearchBox::LogEvent(NTPLoggingEventType event) { |
| 163 // navigation_start in ms. | 163 // The main frame for the current RenderView may be out-of-process, in which |
| 164 uint64 start = 1000 * (render_view()->GetMainRenderFrame()->GetWebFrame()-> | 164 // case it won't have performance(). Use the default delta of 0 in this |
| 165 performance().navigationStart()); | 165 // case. |
| 166 uint64 now = | 166 base::TimeDelta delta; |
| 167 (base::TimeTicks::Now() - base::TimeTicks::UnixEpoch()).InMilliseconds(); | 167 if (render_view()->GetWebView()->mainFrame()->isWebLocalFrame()) { |
| 168 DCHECK(now >= start); | 168 // navigation_start in ms. |
| 169 base::TimeDelta delta = base::TimeDelta::FromMilliseconds(now - start); | 169 uint64 start = 1000 * (render_view()->GetMainRenderFrame()->GetWebFrame()-> |
| 170 performance().navigationStart()); |
| 171 uint64 now = (base::TimeTicks::Now() - base::TimeTicks::UnixEpoch()) |
| 172 .InMilliseconds(); |
| 173 DCHECK(now >= start); |
| 174 delta = base::TimeDelta::FromMilliseconds(now - start); |
| 175 } |
| 170 render_view()->Send(new ChromeViewHostMsg_LogEvent( | 176 render_view()->Send(new ChromeViewHostMsg_LogEvent( |
| 171 render_view()->GetRoutingID(), page_seq_no_, event, delta)); | 177 render_view()->GetRoutingID(), page_seq_no_, event, delta)); |
| 172 } | 178 } |
| 173 | 179 |
| 174 void SearchBox::LogMostVisitedImpression(int position, | 180 void SearchBox::LogMostVisitedImpression(int position, |
| 175 const base::string16& provider) { | 181 const base::string16& provider) { |
| 176 render_view()->Send(new ChromeViewHostMsg_LogMostVisitedImpression( | 182 render_view()->Send(new ChromeViewHostMsg_LogMostVisitedImpression( |
| 177 render_view()->GetRoutingID(), page_seq_no_, position, provider)); | 183 render_view()->GetRoutingID(), page_seq_no_, position, provider)); |
| 178 } | 184 } |
| 179 | 185 |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 | 500 |
| 495 void SearchBox::Reset() { | 501 void SearchBox::Reset() { |
| 496 query_.clear(); | 502 query_.clear(); |
| 497 embedded_search_request_params_ = EmbeddedSearchRequestParams(); | 503 embedded_search_request_params_ = EmbeddedSearchRequestParams(); |
| 498 suggestion_ = InstantSuggestion(); | 504 suggestion_ = InstantSuggestion(); |
| 499 start_margin_ = 0; | 505 start_margin_ = 0; |
| 500 is_focused_ = false; | 506 is_focused_ = false; |
| 501 is_key_capture_enabled_ = false; | 507 is_key_capture_enabled_ = false; |
| 502 theme_info_ = ThemeBackgroundInfo(); | 508 theme_info_ = ThemeBackgroundInfo(); |
| 503 } | 509 } |
| OLD | NEW |