| 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/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 model_.SetDisplayState(InstantModel::QUERY_RESULTS, height, units); | 744 model_.SetDisplayState(InstantModel::QUERY_RESULTS, height, units); |
| 745 } | 745 } |
| 746 | 746 |
| 747 void InstantController::SendBoundsToPage() { | 747 void InstantController::SendBoundsToPage() { |
| 748 if (last_omnibox_bounds_ == omnibox_bounds_ || IsOutOfDate() || | 748 if (last_omnibox_bounds_ == omnibox_bounds_ || IsOutOfDate() || |
| 749 !GetPreviewContents() || loader_->IsPointerDownFromActivate()) | 749 !GetPreviewContents() || loader_->IsPointerDownFromActivate()) |
| 750 return; | 750 return; |
| 751 | 751 |
| 752 last_omnibox_bounds_ = omnibox_bounds_; | 752 last_omnibox_bounds_ = omnibox_bounds_; |
| 753 gfx::Rect preview_bounds = delegate_->GetInstantBounds(); | 753 gfx::Rect preview_bounds = delegate_->GetInstantBounds(); |
| 754 gfx::Rect intersection = omnibox_bounds_.Intersect(preview_bounds); | 754 gfx::Rect intersection = omnibox_bounds_; |
| 755 intersection.Intersect(preview_bounds); |
| 755 | 756 |
| 756 // Translate into window coordinates. | 757 // Translate into window coordinates. |
| 757 if (!intersection.IsEmpty()) { | 758 if (!intersection.IsEmpty()) { |
| 758 intersection.Offset(-preview_bounds.origin().x(), | 759 intersection.Offset(-preview_bounds.origin().x(), |
| 759 -preview_bounds.origin().y()); | 760 -preview_bounds.origin().y()); |
| 760 } | 761 } |
| 761 | 762 |
| 762 // In the current Chrome UI, these must always be true so they sanity check | 763 // In the current Chrome UI, these must always be true so they sanity check |
| 763 // the above operations. In a future UI, these may be removed or adjusted. | 764 // the above operations. In a future UI, these may be removed or adjusted. |
| 764 // There is no point in sanity-checking |intersection.y()| because the omnibox | 765 // There is no point in sanity-checking |intersection.y()| because the omnibox |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 iter->second > kMaxInstantSupportFailures) | 822 iter->second > kMaxInstantSupportFailures) |
| 822 return false; | 823 return false; |
| 823 | 824 |
| 824 return true; | 825 return true; |
| 825 } | 826 } |
| 826 | 827 |
| 827 bool InstantController::IsOutOfDate() const { | 828 bool InstantController::IsOutOfDate() const { |
| 828 return !last_active_tab_ || | 829 return !last_active_tab_ || |
| 829 last_active_tab_ != delegate_->GetActiveTabContents(); | 830 last_active_tab_ != delegate_->GetActiveTabContents(); |
| 830 } | 831 } |
| OLD | NEW |