| 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; |
| 159 render_view()->Send(new ChromeViewHostMsg_LogEvent( | 170 render_view()->Send(new ChromeViewHostMsg_LogEvent( |
| 160 render_view()->GetRoutingID(), page_seq_no_, event)); | 171 render_view()->GetRoutingID(), page_seq_no_, event, delta)); |
| 161 } | 172 } |
| 162 | 173 |
| 163 void SearchBox::LogMostVisitedImpression(int position, | 174 void SearchBox::LogMostVisitedImpression(int position, |
| 164 const base::string16& provider) { | 175 const base::string16& provider) { |
| 165 render_view()->Send(new ChromeViewHostMsg_LogMostVisitedImpression( | 176 render_view()->Send(new ChromeViewHostMsg_LogMostVisitedImpression( |
| 166 render_view()->GetRoutingID(), page_seq_no_, position, provider)); | 177 render_view()->GetRoutingID(), page_seq_no_, position, provider)); |
| 167 } | 178 } |
| 168 | 179 |
| 169 void SearchBox::LogMostVisitedNavigation(int position, | 180 void SearchBox::LogMostVisitedNavigation(int position, |
| 170 const base::string16& provider) { | 181 const base::string16& provider) { |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 | 494 |
| 484 void SearchBox::Reset() { | 495 void SearchBox::Reset() { |
| 485 query_.clear(); | 496 query_.clear(); |
| 486 embedded_search_request_params_ = EmbeddedSearchRequestParams(); | 497 embedded_search_request_params_ = EmbeddedSearchRequestParams(); |
| 487 suggestion_ = InstantSuggestion(); | 498 suggestion_ = InstantSuggestion(); |
| 488 start_margin_ = 0; | 499 start_margin_ = 0; |
| 489 is_focused_ = false; | 500 is_focused_ = false; |
| 490 is_key_capture_enabled_ = false; | 501 is_key_capture_enabled_ = false; |
| 491 theme_info_ = ThemeBackgroundInfo(); | 502 theme_info_ = ThemeBackgroundInfo(); |
| 492 } | 503 } |
| OLD | NEW |