| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 SearchBox::IconURLHelper::~IconURLHelper() { | 231 SearchBox::IconURLHelper::~IconURLHelper() { |
| 232 } | 232 } |
| 233 | 233 |
| 234 SearchBox::SearchBox(content::RenderView* render_view) | 234 SearchBox::SearchBox(content::RenderView* render_view) |
| 235 : content::RenderViewObserver(render_view), | 235 : content::RenderViewObserver(render_view), |
| 236 content::RenderViewObserverTracker<SearchBox>(render_view), | 236 content::RenderViewObserverTracker<SearchBox>(render_view), |
| 237 page_seq_no_(0), | 237 page_seq_no_(0), |
| 238 is_focused_(false), | 238 is_focused_(false), |
| 239 is_input_in_progress_(false), | 239 is_input_in_progress_(false), |
| 240 is_key_capture_enabled_(false), | 240 is_key_capture_enabled_(false), |
| 241 display_instant_results_(false), | |
| 242 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize), | 241 most_visited_items_cache_(kMaxInstantMostVisitedItemCacheSize), |
| 243 query_() { | 242 query_() { |
| 244 } | 243 } |
| 245 | 244 |
| 246 SearchBox::~SearchBox() { | 245 SearchBox::~SearchBox() { |
| 247 } | 246 } |
| 248 | 247 |
| 249 void SearchBox::LogEvent(NTPLoggingEventType event) { | 248 void SearchBox::LogEvent(NTPLoggingEventType event) { |
| 250 // The main frame for the current RenderView may be out-of-process, in which | 249 // The main frame for the current RenderView may be out-of-process, in which |
| 251 // case it won't have performance(). Use the default delta of 0 in this | 250 // case it won't have performance(). Use the default delta of 0 in this |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 OnSetPageSequenceNumber) | 363 OnSetPageSequenceNumber) |
| 365 IPC_MESSAGE_HANDLER(ChromeViewMsg_ChromeIdentityCheckResult, | 364 IPC_MESSAGE_HANDLER(ChromeViewMsg_ChromeIdentityCheckResult, |
| 366 OnChromeIdentityCheckResult) | 365 OnChromeIdentityCheckResult) |
| 367 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant, | 366 IPC_MESSAGE_HANDLER(ChromeViewMsg_DetermineIfPageSupportsInstant, |
| 368 OnDetermineIfPageSupportsInstant) | 367 OnDetermineIfPageSupportsInstant) |
| 369 IPC_MESSAGE_HANDLER(ChromeViewMsg_HistorySyncCheckResult, | 368 IPC_MESSAGE_HANDLER(ChromeViewMsg_HistorySyncCheckResult, |
| 370 OnHistorySyncCheckResult) | 369 OnHistorySyncCheckResult) |
| 371 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFocusChanged, OnFocusChanged) | 370 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxFocusChanged, OnFocusChanged) |
| 372 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMostVisitedItemsChanged, | 371 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxMostVisitedItemsChanged, |
| 373 OnMostVisitedChanged) | 372 OnMostVisitedChanged) |
| 374 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetDisplayInstantResults, | |
| 375 OnSetDisplayInstantResults) | |
| 376 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetInputInProgress, | 373 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetInputInProgress, |
| 377 OnSetInputInProgress) | 374 OnSetInputInProgress) |
| 378 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetSuggestionToPrefetch, | 375 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSetSuggestionToPrefetch, |
| 379 OnSetSuggestionToPrefetch) | 376 OnSetSuggestionToPrefetch) |
| 380 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSubmit, OnSubmit) | 377 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxSubmit, OnSubmit) |
| 381 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged, | 378 IPC_MESSAGE_HANDLER(ChromeViewMsg_SearchBoxThemeChanged, |
| 382 OnThemeChanged) | 379 OnThemeChanged) |
| 383 IPC_MESSAGE_UNHANDLED(handled = false) | 380 IPC_MESSAGE_UNHANDLED(handled = false) |
| 384 IPC_END_MESSAGE_MAP() | 381 IPC_END_MESSAGE_MAP() |
| 385 return handled; | 382 return handled; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 if (AreMostVisitedItemsEqual(last_known_items, items)) | 452 if (AreMostVisitedItemsEqual(last_known_items, items)) |
| 456 return; // Do not send duplicate onmostvisitedchange events. | 453 return; // Do not send duplicate onmostvisitedchange events. |
| 457 | 454 |
| 458 most_visited_items_cache_.AddItems(items); | 455 most_visited_items_cache_.AddItems(items); |
| 459 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { | 456 if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { |
| 460 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( | 457 extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( |
| 461 render_view()->GetWebView()->mainFrame()); | 458 render_view()->GetWebView()->mainFrame()); |
| 462 } | 459 } |
| 463 } | 460 } |
| 464 | 461 |
| 465 void SearchBox::OnSetDisplayInstantResults(bool display_instant_results) { | |
| 466 display_instant_results_ = display_instant_results; | |
| 467 } | |
| 468 | |
| 469 void SearchBox::OnSetInputInProgress(bool is_input_in_progress) { | 462 void SearchBox::OnSetInputInProgress(bool is_input_in_progress) { |
| 470 if (is_input_in_progress_ != is_input_in_progress) { | 463 if (is_input_in_progress_ != is_input_in_progress) { |
| 471 is_input_in_progress_ = is_input_in_progress; | 464 is_input_in_progress_ = is_input_in_progress; |
| 472 DVLOG(1) << render_view() << " OnSetInputInProgress"; | 465 DVLOG(1) << render_view() << " OnSetInputInProgress"; |
| 473 if (render_view()->GetWebView() && | 466 if (render_view()->GetWebView() && |
| 474 render_view()->GetWebView()->mainFrame()) { | 467 render_view()->GetWebView()->mainFrame()) { |
| 475 if (is_input_in_progress_) { | 468 if (is_input_in_progress_) { |
| 476 extensions_v8::SearchBoxExtension::DispatchInputStart( | 469 extensions_v8::SearchBoxExtension::DispatchInputStart( |
| 477 render_view()->GetWebView()->mainFrame()); | 470 render_view()->GetWebView()->mainFrame()); |
| 478 } else { | 471 } else { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 embedded_search_request_params_ = EmbeddedSearchRequestParams(); | 520 embedded_search_request_params_ = EmbeddedSearchRequestParams(); |
| 528 suggestion_ = InstantSuggestion(); | 521 suggestion_ = InstantSuggestion(); |
| 529 is_focused_ = false; | 522 is_focused_ = false; |
| 530 is_key_capture_enabled_ = false; | 523 is_key_capture_enabled_ = false; |
| 531 theme_info_ = ThemeBackgroundInfo(); | 524 theme_info_ = ThemeBackgroundInfo(); |
| 532 } | 525 } |
| 533 | 526 |
| 534 void SearchBox::OnDestruct() { | 527 void SearchBox::OnDestruct() { |
| 535 delete this; | 528 delete this; |
| 536 } | 529 } |
| OLD | NEW |