| 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/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 500 |
| 501 void InstantController::CommitInstantLoader(InstantLoader* loader) { | 501 void InstantController::CommitInstantLoader(InstantLoader* loader) { |
| 502 DCHECK_EQ(loader_.get(), loader); | 502 DCHECK_EQ(loader_.get(), loader); |
| 503 DCHECK(is_showing_ && !IsOutOfDate()) << is_showing_; | 503 DCHECK(is_showing_ && !IsOutOfDate()) << is_showing_; |
| 504 if (loader_ != loader || !is_showing_ || IsOutOfDate()) | 504 if (loader_ != loader || !is_showing_ || IsOutOfDate()) |
| 505 return; | 505 return; |
| 506 | 506 |
| 507 CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST); | 507 CommitCurrentPreview(INSTANT_COMMIT_FOCUS_LOST); |
| 508 } | 508 } |
| 509 | 509 |
| 510 void InstantController::SetInstantPreviewHeight(InstantLoader* loader, |
| 511 int height, |
| 512 InstantSizeUnits units) { |
| 513 DCHECK_EQ(loader_.get(), loader); |
| 514 if (loader_ != loader || mode_ != EXTENDED) |
| 515 return; |
| 516 |
| 517 delegate_->SetInstantPreviewHeight(height, units); |
| 518 } |
| 519 |
| 510 void InstantController::InstantLoaderPreviewLoaded(InstantLoader* loader) { | 520 void InstantController::InstantLoaderPreviewLoaded(InstantLoader* loader) { |
| 511 DCHECK_EQ(loader_.get(), loader); | 521 DCHECK_EQ(loader_.get(), loader); |
| 512 AddPreviewUsageForHistogram(mode_, PREVIEW_LOADED); | 522 AddPreviewUsageForHistogram(mode_, PREVIEW_LOADED); |
| 513 } | 523 } |
| 514 | 524 |
| 515 void InstantController::InstantSupportDetermined(InstantLoader* loader, | 525 void InstantController::InstantSupportDetermined(InstantLoader* loader, |
| 516 bool supports_instant) { | 526 bool supports_instant) { |
| 517 DCHECK_EQ(loader_.get(), loader); | 527 DCHECK_EQ(loader_.get(), loader); |
| 518 if (supports_instant) { | 528 if (supports_instant) { |
| 519 blacklisted_urls_.erase(loader->instant_url()); | 529 blacklisted_urls_.erase(loader->instant_url()); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 717 iter->second > kMaxInstantSupportFailures) | 727 iter->second > kMaxInstantSupportFailures) |
| 718 return false; | 728 return false; |
| 719 | 729 |
| 720 return true; | 730 return true; |
| 721 } | 731 } |
| 722 | 732 |
| 723 bool InstantController::IsOutOfDate() const { | 733 bool InstantController::IsOutOfDate() const { |
| 724 return !last_active_tab_ || | 734 return !last_active_tab_ || |
| 725 last_active_tab_ != delegate_->GetActiveTabContents(); | 735 last_active_tab_ != delegate_->GetActiveTabContents(); |
| 726 } | 736 } |
| OLD | NEW |