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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 verbatim_(false), | 83 verbatim_(false), |
84 query_is_restricted_(false), | 84 query_is_restricted_(false), |
85 selection_start_(0), | 85 selection_start_(0), |
86 selection_end_(0), | 86 selection_end_(0), |
87 start_margin_(0), | 87 start_margin_(0), |
88 is_focused_(false), | 88 is_focused_(false), |
89 is_key_capture_enabled_(false), | 89 is_key_capture_enabled_(false), |
90 is_input_in_progress_(false), | 90 is_input_in_progress_(false), |
91 display_instant_results_(false), | 91 display_instant_results_(false), |
92 omnibox_font_size_(0), | 92 omnibox_font_size_(0), |
| 93 app_launcher_enabled_(false), |
93 autocomplete_results_cache_(kMaxInstantAutocompleteResultItemCacheSize), | 94 autocomplete_results_cache_(kMaxInstantAutocompleteResultItemCacheSize), |
94 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize) { | 95 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize) { |
95 } | 96 } |
96 | 97 |
97 SearchBox::~SearchBox() { | 98 SearchBox::~SearchBox() { |
98 } | 99 } |
99 | 100 |
100 void SearchBox::SetSuggestions( | 101 void SearchBox::SetSuggestions( |
101 const std::vector<InstantSuggestion>& suggestions) { | 102 const std::vector<InstantSuggestion>& suggestions) { |
102 if (!suggestions.empty() && | 103 if (!suggestions.empty() && |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 OnCancelSelection) | 265 OnCancelSelection) |
265 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults, | 266 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults, |
266 OnSetDisplayInstantResults) | 267 OnSetDisplayInstantResults) |
267 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFocusChanged, OnFocusChanged) | 268 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFocusChanged, OnFocusChanged) |
268 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetInputInProgress, | 269 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetInputInProgress, |
269 OnSetInputInProgress) | 270 OnSetInputInProgress) |
270 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged, | 271 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged, |
271 OnThemeChanged) | 272 OnThemeChanged) |
272 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFontInformation, | 273 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFontInformation, |
273 OnFontInformationReceived) | 274 OnFontInformationReceived) |
| 275 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxPromoInformation, |
| 276 OnPromoInformationReceived) |
274 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMostVisitedItemsChanged, | 277 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMostVisitedItemsChanged, |
275 OnMostVisitedChanged) | 278 OnMostVisitedChanged) |
276 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxToggleVoiceSearch, | 279 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxToggleVoiceSearch, |
277 OnToggleVoiceSearch) | 280 OnToggleVoiceSearch) |
278 IPC_MESSAGE_UNHANDLED(handled = false) | 281 IPC_MESSAGE_UNHANDLED(handled = false) |
279 IPC_END_MESSAGE_MAP() | 282 IPC_END_MESSAGE_MAP() |
280 return handled; | 283 return handled; |
281 } | 284 } |
282 | 285 |
283 void SearchBox::OnChange(const string16& query, | 286 void SearchBox::OnChange(const string16& query, |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 render_view()->GetWebView()->mainFrame()); | 483 render_view()->GetWebView()->mainFrame()); |
481 } | 484 } |
482 } | 485 } |
483 | 486 |
484 void SearchBox::OnFontInformationReceived(const string16& omnibox_font, | 487 void SearchBox::OnFontInformationReceived(const string16& omnibox_font, |
485 size_t omnibox_font_size) { | 488 size_t omnibox_font_size) { |
486 omnibox_font_ = omnibox_font; | 489 omnibox_font_ = omnibox_font; |
487 omnibox_font_size_ = omnibox_font_size; | 490 omnibox_font_size_ = omnibox_font_size; |
488 } | 491 } |
489 | 492 |
| 493 void SearchBox::OnPromoInformationReceived(bool is_app_launcher_enabled) { |
| 494 app_launcher_enabled_ = is_app_launcher_enabled; |
| 495 } |
| 496 |
490 double SearchBox::GetZoom() const { | 497 double SearchBox::GetZoom() const { |
491 WebKit::WebView* web_view = render_view()->GetWebView(); | 498 WebKit::WebView* web_view = render_view()->GetWebView(); |
492 if (web_view) { | 499 if (web_view) { |
493 double zoom = WebKit::WebView::zoomLevelToZoomFactor(web_view->zoomLevel()); | 500 double zoom = WebKit::WebView::zoomLevelToZoomFactor(web_view->zoomLevel()); |
494 if (zoom != 0) | 501 if (zoom != 0) |
495 return zoom; | 502 return zoom; |
496 } | 503 } |
497 return 1.0; | 504 return 1.0; |
498 } | 505 } |
499 | 506 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
552 InstantMostVisitedItem item; | 559 InstantMostVisitedItem item; |
553 return GetMostVisitedItemWithID(item_id, &item) ? item.url : GURL(); | 560 return GetMostVisitedItemWithID(item_id, &item) ? item.url : GURL(); |
554 } | 561 } |
555 | 562 |
556 void SearchBox::OnToggleVoiceSearch() { | 563 void SearchBox::OnToggleVoiceSearch() { |
557 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 564 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
558 extensions_v8::SearchBoxExtension::DispatchToggleVoiceSearch( | 565 extensions_v8::SearchBoxExtension::DispatchToggleVoiceSearch( |
559 render_view()->GetWebView()->mainFrame()); | 566 render_view()->GetWebView()->mainFrame()); |
560 } | 567 } |
561 } | 568 } |
OLD | NEW |