OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/browser/instant/instant_controller.h" | 5 #include "chrome/browser/instant/instant_controller.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/i18n/case_conversion.h" | 8 #include "base/i18n/case_conversion.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 history::RedirectList(), last_transition_type_, | 379 history::RedirectList(), last_transition_type_, |
380 history::SOURCE_BROWSED, false); | 380 history::SOURCE_BROWSED, false); |
381 } | 381 } |
382 | 382 |
383 AddPreviewUsageForHistogram(mode_, PREVIEW_COMMITTED); | 383 AddPreviewUsageForHistogram(mode_, PREVIEW_COMMITTED); |
384 | 384 |
385 // We may have gotten here from CommitInstant(), which means the loader may | 385 // We may have gotten here from CommitInstant(), which means the loader may |
386 // still be on the stack. So, schedule a destruction for later. | 386 // still be on the stack. So, schedule a destruction for later. |
387 MessageLoop::current()->DeleteSoon(FROM_HERE, loader_.release()); | 387 MessageLoop::current()->DeleteSoon(FROM_HERE, loader_.release()); |
388 | 388 |
389 // This call is here to hide the preview and reset view state. It won't | 389 // This call is here to reset view state. It won't actually delete |loader_| |
390 // actually delete |loader_| because it was just released to DeleteSoon(). | 390 // because it was just released to DeleteSoon(). |
391 DeleteLoader(); | 391 DeleteLoader(); |
392 | 392 |
393 return preview; | 393 return preview; |
394 } | 394 } |
395 | 395 |
396 void InstantController::OnAutocompleteLostFocus( | 396 void InstantController::OnAutocompleteLostFocus( |
397 gfx::NativeView view_gaining_focus) { | 397 gfx::NativeView view_gaining_focus) { |
398 DCHECK(!is_showing_ || GetPreviewContents()); | 398 DCHECK(!is_showing_ || GetPreviewContents()); |
399 | 399 |
400 // If there is no preview, nothing to do. | 400 // If there is no preview, nothing to do. |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 DeleteLoader(); | 651 DeleteLoader(); |
652 CreateDefaultLoader(); | 652 CreateDefaultLoader(); |
653 } | 653 } |
654 | 654 |
655 void InstantController::MaybeOnStaleLoader() { | 655 void InstantController::MaybeOnStaleLoader() { |
656 if (!stale_loader_timer_.IsRunning()) | 656 if (!stale_loader_timer_.IsRunning()) |
657 OnStaleLoader(); | 657 OnStaleLoader(); |
658 } | 658 } |
659 | 659 |
660 void InstantController::DeleteLoader() { | 660 void InstantController::DeleteLoader() { |
| 661 last_active_tab_ = NULL; |
661 last_full_text_.clear(); | 662 last_full_text_.clear(); |
662 last_user_text_.clear(); | 663 last_user_text_.clear(); |
663 last_verbatim_ = false; | 664 last_verbatim_ = false; |
664 last_suggestion_ = InstantSuggestion(); | 665 last_suggestion_ = InstantSuggestion(); |
665 last_transition_type_ = content::PAGE_TRANSITION_LINK; | 666 last_transition_type_ = content::PAGE_TRANSITION_LINK; |
666 last_match_was_search_ = false; | 667 last_match_was_search_ = false; |
| 668 is_showing_ = false; |
| 669 loader_processed_last_update_ = false; |
667 last_omnibox_bounds_ = gfx::Rect(); | 670 last_omnibox_bounds_ = gfx::Rect(); |
668 url_for_history_ = GURL(); | 671 url_for_history_ = GURL(); |
669 Hide(); | |
670 if (GetPreviewContents()) | 672 if (GetPreviewContents()) |
671 AddPreviewUsageForHistogram(mode_, PREVIEW_DELETED); | 673 AddPreviewUsageForHistogram(mode_, PREVIEW_DELETED); |
672 loader_.reset(); | 674 loader_.reset(); |
673 } | 675 } |
674 | 676 |
675 void InstantController::Show(int height, InstantSizeUnits units) { | 677 void InstantController::Show(int height, InstantSizeUnits units) { |
676 // Call even if showing in case height changed. | 678 // Call even if showing in case height changed. |
677 delegate_->ShowInstant(height, units); | 679 delegate_->ShowInstant(height, units); |
678 if (!is_showing_) { | 680 if (!is_showing_) { |
679 is_showing_ = true; | 681 is_showing_ = true; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 DCHECK(url_obj.is_valid()); | 788 DCHECK(url_obj.is_valid()); |
787 *instant_url = url_obj.spec(); | 789 *instant_url = url_obj.spec(); |
788 } | 790 } |
789 } | 791 } |
790 } | 792 } |
791 | 793 |
792 bool InstantController::IsOutOfDate() const { | 794 bool InstantController::IsOutOfDate() const { |
793 return !last_active_tab_ || | 795 return !last_active_tab_ || |
794 last_active_tab_ != delegate_->GetActiveTabContents(); | 796 last_active_tab_ != delegate_->GetActiveTabContents(); |
795 } | 797 } |
OLD | NEW |