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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 model_.SetDisplayState(InstantModel::QUERY_RESULTS, height, units); | 731 model_.SetDisplayState(InstantModel::QUERY_RESULTS, height, units); |
732 } | 732 } |
733 | 733 |
734 void InstantController::SendBoundsToPage() { | 734 void InstantController::SendBoundsToPage() { |
735 if (last_omnibox_bounds_ == omnibox_bounds_ || IsOutOfDate() || | 735 if (last_omnibox_bounds_ == omnibox_bounds_ || IsOutOfDate() || |
736 !GetPreviewContents() || loader_->IsPointerDownFromActivate()) | 736 !GetPreviewContents() || loader_->IsPointerDownFromActivate()) |
737 return; | 737 return; |
738 | 738 |
739 last_omnibox_bounds_ = omnibox_bounds_; | 739 last_omnibox_bounds_ = omnibox_bounds_; |
740 gfx::Rect preview_bounds = browser_->GetInstantBounds(); | 740 gfx::Rect preview_bounds = browser_->GetInstantBounds(); |
741 gfx::Rect intersection = omnibox_bounds_; | 741 gfx::Rect intersection = gfx::Intersection(omnibox_bounds_, preview_bounds); |
742 intersection.Intersect(preview_bounds); | |
743 | 742 |
744 // Translate into window coordinates. | 743 // Translate into window coordinates. |
745 if (!intersection.IsEmpty()) { | 744 if (!intersection.IsEmpty()) { |
746 intersection.Offset(-preview_bounds.origin().x(), | 745 intersection.Offset(-preview_bounds.origin().x(), |
747 -preview_bounds.origin().y()); | 746 -preview_bounds.origin().y()); |
748 } | 747 } |
749 | 748 |
750 // In the current Chrome UI, these must always be true so they sanity check | 749 // In the current Chrome UI, these must always be true so they sanity check |
751 // the above operations. In a future UI, these may be removed or adjusted. | 750 // the above operations. In a future UI, these may be removed or adjusted. |
752 // There is no point in sanity-checking |intersection.y()| because the omnibox | 751 // 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... |
809 iter->second > kMaxInstantSupportFailures) | 808 iter->second > kMaxInstantSupportFailures) |
810 return false; | 809 return false; |
811 | 810 |
812 return true; | 811 return true; |
813 } | 812 } |
814 | 813 |
815 bool InstantController::IsOutOfDate() const { | 814 bool InstantController::IsOutOfDate() const { |
816 return !last_active_tab_ || | 815 return !last_active_tab_ || |
817 last_active_tab_ != browser_->GetActiveTabContents(); | 816 last_active_tab_ != browser_->GetActiveTabContents(); |
818 } | 817 } |
OLD | NEW |