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/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 * | |
| 165 render_view() | |
| 166 ->GetMainRenderFrame() | |
| 167 ->GetWebFrame() | |
| 168 ->performance() | |
| 169 .navigationStart(); | |
|
kmadhusu
2015/03/16 21:35:30
style nit: Can you rewrite this line as follows:
u
fserb
2015/03/16 21:45:49
I can, but it doesn't fit in 80chars and the "git
kmadhusu
2015/03/16 21:58:48
You can break the line. I prefer to see 2 lines in
fserb
2015/03/16 22:05:32
I changed it a bit, but if I run "git cl format" i
kmadhusu
2015/03/17 00:10:40
I generally don't run "git cl format".
Try this a
| |
| 170 uint64 now = | |
| 171 (base::TimeTicks::Now() - base::TimeTicks::UnixEpoch()).InMilliseconds(); | |
|
kmadhusu
2015/03/16 21:35:30
Is there any specific reason to use base::TimeTick
fserb
2015/03/16 21:45:49
Done.
| |
| 172 DCHECK(now >= start); | |
| 173 uint64 delta = now - start; | |
| 159 render_view()->Send(new ChromeViewHostMsg_LogEvent( | 174 render_view()->Send(new ChromeViewHostMsg_LogEvent( |
| 160 render_view()->GetRoutingID(), page_seq_no_, event)); | 175 render_view()->GetRoutingID(), page_seq_no_, event, delta)); |
| 161 } | 176 } |
| 162 | 177 |
| 163 void SearchBox::LogMostVisitedImpression(int position, | 178 void SearchBox::LogMostVisitedImpression(int position, |
| 164 const base::string16& provider) { | 179 const base::string16& provider) { |
| 165 render_view()->Send(new ChromeViewHostMsg_LogMostVisitedImpression( | 180 render_view()->Send(new ChromeViewHostMsg_LogMostVisitedImpression( |
| 166 render_view()->GetRoutingID(), page_seq_no_, position, provider)); | 181 render_view()->GetRoutingID(), page_seq_no_, position, provider)); |
| 167 } | 182 } |
| 168 | 183 |
| 169 void SearchBox::LogMostVisitedNavigation(int position, | 184 void SearchBox::LogMostVisitedNavigation(int position, |
| 170 const base::string16& provider) { | 185 const base::string16& provider) { |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 483 | 498 |
| 484 void SearchBox::Reset() { | 499 void SearchBox::Reset() { |
| 485 query_.clear(); | 500 query_.clear(); |
| 486 embedded_search_request_params_ = EmbeddedSearchRequestParams(); | 501 embedded_search_request_params_ = EmbeddedSearchRequestParams(); |
| 487 suggestion_ = InstantSuggestion(); | 502 suggestion_ = InstantSuggestion(); |
| 488 start_margin_ = 0; | 503 start_margin_ = 0; |
| 489 is_focused_ = false; | 504 is_focused_ = false; |
| 490 is_key_capture_enabled_ = false; | 505 is_key_capture_enabled_ = false; |
| 491 theme_info_ = ThemeBackgroundInfo(); | 506 theme_info_ = ThemeBackgroundInfo(); |
| 492 } | 507 } |
| OLD | NEW |