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 int64 start = 1000 * | |
165 render_view() | |
166 ->GetMainRenderFrame() | |
167 ->GetWebFrame() | |
168 ->performance() | |
169 .navigationStart(); | |
170 int64 now = | |
171 (base::TimeTicks::Now() - base::TimeTicks::UnixEpoch()).InMilliseconds(); | |
172 int64 delta = now - start; | |
Will Harris
2015/03/16 17:39:03
add DCHECK that now > start
fserb
2015/03/16 17:49:38
Done.
| |
159 render_view()->Send(new ChromeViewHostMsg_LogEvent( | 173 render_view()->Send(new ChromeViewHostMsg_LogEvent( |
160 render_view()->GetRoutingID(), page_seq_no_, event)); | 174 render_view()->GetRoutingID(), page_seq_no_, event, delta)); |
161 } | 175 } |
162 | 176 |
163 void SearchBox::LogMostVisitedImpression(int position, | 177 void SearchBox::LogMostVisitedImpression(int position, |
164 const base::string16& provider) { | 178 const base::string16& provider) { |
165 render_view()->Send(new ChromeViewHostMsg_LogMostVisitedImpression( | 179 render_view()->Send(new ChromeViewHostMsg_LogMostVisitedImpression( |
166 render_view()->GetRoutingID(), page_seq_no_, position, provider)); | 180 render_view()->GetRoutingID(), page_seq_no_, position, provider)); |
167 } | 181 } |
168 | 182 |
169 void SearchBox::LogMostVisitedNavigation(int position, | 183 void SearchBox::LogMostVisitedNavigation(int position, |
170 const base::string16& provider) { | 184 const base::string16& provider) { |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
483 | 497 |
484 void SearchBox::Reset() { | 498 void SearchBox::Reset() { |
485 query_.clear(); | 499 query_.clear(); |
486 embedded_search_request_params_ = EmbeddedSearchRequestParams(); | 500 embedded_search_request_params_ = EmbeddedSearchRequestParams(); |
487 suggestion_ = InstantSuggestion(); | 501 suggestion_ = InstantSuggestion(); |
488 start_margin_ = 0; | 502 start_margin_ = 0; |
489 is_focused_ = false; | 503 is_focused_ = false; |
490 is_key_capture_enabled_ = false; | 504 is_key_capture_enabled_ = false; |
491 theme_info_ = ThemeBackgroundInfo(); | 505 theme_info_ = ThemeBackgroundInfo(); |
492 } | 506 } |
OLD | NEW |