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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/time/time.h" | |
12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/common/favicon/favicon_url_parser.h" | 14 #include "chrome/common/favicon/favicon_url_parser.h" |
14 #include "chrome/common/omnibox_focus_state.h" | 15 #include "chrome/common/omnibox_focus_state.h" |
15 #include "chrome/common/render_messages.h" | 16 #include "chrome/common/render_messages.h" |
16 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
17 #include "chrome/renderer/searchbox/searchbox_extension.h" | 18 #include "chrome/renderer/searchbox/searchbox_extension.h" |
18 #include "components/favicon_base/favicon_types.h" | 19 #include "components/favicon_base/favicon_types.h" |
20 #include "content/public/renderer/render_frame.h" | |
19 #include "content/public/renderer/render_view.h" | 21 #include "content/public/renderer/render_view.h" |
20 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
21 #include "third_party/WebKit/public/web/WebDocument.h" | 23 #include "third_party/WebKit/public/web/WebDocument.h" |
22 #include "third_party/WebKit/public/web/WebFrame.h" | 24 #include "third_party/WebKit/public/web/WebFrame.h" |
25 #include "third_party/WebKit/public/web/WebLocalFrame.h" | |
26 #include "third_party/WebKit/public/web/WebPerformance.h" | |
23 #include "third_party/WebKit/public/web/WebView.h" | 27 #include "third_party/WebKit/public/web/WebView.h" |
24 #include "url/gurl.h" | 28 #include "url/gurl.h" |
25 | 29 |
26 namespace { | 30 namespace { |
27 | 31 |
28 // The size of the InstantMostVisitedItem cache. | 32 // The size of the InstantMostVisitedItem cache. |
29 const size_t kMaxInstantMostVisitedItemCacheSize = 100; | 33 const size_t kMaxInstantMostVisitedItemCacheSize = 100; |
30 | 34 |
31 // Returns true if items stored in |old_item_id_pairs| and |new_items| are | 35 // Returns true if items stored in |old_item_id_pairs| and |new_items| are |
32 // equal. | 36 // equal. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 display_instant_results_(false), | 153 display_instant_results_(false), |
150 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize), | 154 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize), |
151 query_(), | 155 query_(), |
152 start_margin_(0) { | 156 start_margin_(0) { |
153 } | 157 } |
154 | 158 |
155 SearchBox::~SearchBox() { | 159 SearchBox::~SearchBox() { |
156 } | 160 } |
157 | 161 |
158 void SearchBox::LogEvent(NTPLoggingEventType event) { | 162 void SearchBox::LogEvent(NTPLoggingEventType event) { |
163 // navigation_start in ms. | |
164 uint64 start = 1000 * (render_view()->GetMainRenderFrame()->GetWebFrame()-> | |
165 performance().navigationStart()); | |
166 uint64 now = | |
167 (base::TimeTicks::Now() - base::TimeTicks::UnixEpoch()).InMilliseconds(); | |
168 DCHECK(now >= start); | |
169 uint64 delta = now - start; | |
Dan Beam
2015/03/17 17:17:19
i'm really confused as to what everything here is
fserb
2015/03/17 17:41:32
I've tried my best to do it this way before, which
| |
170 DVLOG(1) << now << " - " << start << " = " << delta; | |
Dan Beam
2015/03/17 17:17:19
remove debug logging... unless there's some purpos
fserb
2015/03/17 17:41:32
Done.
| |
159 render_view()->Send(new ChromeViewHostMsg_LogEvent( | 171 render_view()->Send(new ChromeViewHostMsg_LogEvent( |
160 render_view()->GetRoutingID(), page_seq_no_, event)); | 172 render_view()->GetRoutingID(), page_seq_no_, event, delta)); |
161 } | 173 } |
162 | 174 |
163 void SearchBox::LogMostVisitedImpression(int position, | 175 void SearchBox::LogMostVisitedImpression(int position, |
164 const base::string16& provider) { | 176 const base::string16& provider) { |
165 render_view()->Send(new ChromeViewHostMsg_LogMostVisitedImpression( | 177 render_view()->Send(new ChromeViewHostMsg_LogMostVisitedImpression( |
166 render_view()->GetRoutingID(), page_seq_no_, position, provider)); | 178 render_view()->GetRoutingID(), page_seq_no_, position, provider)); |
167 } | 179 } |
168 | 180 |
169 void SearchBox::LogMostVisitedNavigation(int position, | 181 void SearchBox::LogMostVisitedNavigation(int position, |
170 const base::string16& provider) { | 182 const base::string16& provider) { |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 | 495 |
484 void SearchBox::Reset() { | 496 void SearchBox::Reset() { |
485 query_.clear(); | 497 query_.clear(); |
486 embedded_search_request_params_ = EmbeddedSearchRequestParams(); | 498 embedded_search_request_params_ = EmbeddedSearchRequestParams(); |
487 suggestion_ = InstantSuggestion(); | 499 suggestion_ = InstantSuggestion(); |
488 start_margin_ = 0; | 500 start_margin_ = 0; |
489 is_focused_ = false; | 501 is_focused_ = false; |
490 is_key_capture_enabled_ = false; | 502 is_key_capture_enabled_ = false; |
491 theme_info_ = ThemeBackgroundInfo(); | 503 theme_info_ = ThemeBackgroundInfo(); |
492 } | 504 } |
OLD | NEW |