| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 SearchBox::SearchBox(content::RenderView* render_view) | 143 SearchBox::SearchBox(content::RenderView* render_view) |
| 144 : content::RenderViewObserver(render_view), | 144 : content::RenderViewObserver(render_view), |
| 145 content::RenderViewObserverTracker<SearchBox>(render_view), | 145 content::RenderViewObserverTracker<SearchBox>(render_view), |
| 146 app_launcher_enabled_(false), | 146 app_launcher_enabled_(false), |
| 147 is_focused_(false), | 147 is_focused_(false), |
| 148 is_input_in_progress_(false), | 148 is_input_in_progress_(false), |
| 149 is_key_capture_enabled_(false), | 149 is_key_capture_enabled_(false), |
| 150 display_instant_results_(false), | 150 display_instant_results_(false), |
| 151 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize), | 151 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize), |
| 152 query_(), | 152 query_(), |
| 153 start_margin_(0), | 153 start_margin_(0) { |
| 154 width_(0) { | |
| 155 } | 154 } |
| 156 | 155 |
| 157 SearchBox::~SearchBox() { | 156 SearchBox::~SearchBox() { |
| 158 } | 157 } |
| 159 | 158 |
| 160 void SearchBox::LogEvent(NTPLoggingEventType event) { | 159 void SearchBox::LogEvent(NTPLoggingEventType event) { |
| 161 render_view()->Send(new ChromeViewHostMsg_LogEvent( | 160 render_view()->Send(new ChromeViewHostMsg_LogEvent( |
| 162 render_view()->GetRoutingID(), render_view()->GetPageId(), event)); | 161 render_view()->GetRoutingID(), render_view()->GetPageId(), event)); |
| 163 } | 162 } |
| 164 | 163 |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 is_focused_ = is_focused; | 353 is_focused_ = is_focused; |
| 355 DVLOG(1) << render_view() << " OnFocusChange"; | 354 DVLOG(1) << render_view() << " OnFocusChange"; |
| 356 if (render_view()->GetWebView() && | 355 if (render_view()->GetWebView() && |
| 357 render_view()->GetWebView()->mainFrame()) { | 356 render_view()->GetWebView()->mainFrame()) { |
| 358 extensions_v8::SearchBoxExtension::DispatchFocusChange( | 357 extensions_v8::SearchBoxExtension::DispatchFocusChange( |
| 359 render_view()->GetWebView()->mainFrame()); | 358 render_view()->GetWebView()->mainFrame()); |
| 360 } | 359 } |
| 361 } | 360 } |
| 362 } | 361 } |
| 363 | 362 |
| 364 void SearchBox::OnMarginChange(int margin, int width) { | 363 void SearchBox::OnMarginChange(int margin) { |
| 365 start_margin_ = margin; | 364 start_margin_ = margin; |
| 366 width_ = width; | |
| 367 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 365 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
| 368 extensions_v8::SearchBoxExtension::DispatchMarginChange( | 366 extensions_v8::SearchBoxExtension::DispatchMarginChange( |
| 369 render_view()->GetWebView()->mainFrame()); | 367 render_view()->GetWebView()->mainFrame()); |
| 370 } | 368 } |
| 371 } | 369 } |
| 372 | 370 |
| 373 void SearchBox::OnMostVisitedChanged( | 371 void SearchBox::OnMostVisitedChanged( |
| 374 const std::vector<InstantMostVisitedItem>& items) { | 372 const std::vector<InstantMostVisitedItem>& items) { |
| 375 std::vector<InstantMostVisitedItemIDPair> last_known_items; | 373 std::vector<InstantMostVisitedItemIDPair> last_known_items; |
| 376 GetMostVisitedItems(&last_known_items); | 374 GetMostVisitedItems(&last_known_items); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 | 449 |
| 452 GURL SearchBox::GetURLForMostVisitedItem(InstantRestrictedID item_id) const { | 450 GURL SearchBox::GetURLForMostVisitedItem(InstantRestrictedID item_id) const { |
| 453 InstantMostVisitedItem item; | 451 InstantMostVisitedItem item; |
| 454 return GetMostVisitedItemWithID(item_id, &item) ? item.url : GURL(); | 452 return GetMostVisitedItemWithID(item_id, &item) ? item.url : GURL(); |
| 455 } | 453 } |
| 456 | 454 |
| 457 void SearchBox::Reset() { | 455 void SearchBox::Reset() { |
| 458 query_.clear(); | 456 query_.clear(); |
| 459 suggestion_ = InstantSuggestion(); | 457 suggestion_ = InstantSuggestion(); |
| 460 start_margin_ = 0; | 458 start_margin_ = 0; |
| 461 width_ = 0; | |
| 462 is_focused_ = false; | 459 is_focused_ = false; |
| 463 is_key_capture_enabled_ = false; | 460 is_key_capture_enabled_ = false; |
| 464 theme_info_ = ThemeBackgroundInfo(); | 461 theme_info_ = ThemeBackgroundInfo(); |
| 465 } | 462 } |
| OLD | NEW |