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/browser/ui/search/instant_controller.h" | 5 #include "chrome/browser/ui/search/instant_controller.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
927 return; | 927 return; |
928 | 928 |
929 // Tell the page if the key capture mode changed unless the focus state | 929 // Tell the page if the key capture mode changed unless the focus state |
930 // changed because of TYPING. This is because in that case, the browser hasn't | 930 // changed because of TYPING. This is because in that case, the browser hasn't |
931 // really stopped capturing key strokes. | 931 // really stopped capturing key strokes. |
932 // | 932 // |
933 // (More practically, if we don't do this check, the page would receive | 933 // (More practically, if we don't do this check, the page would receive |
934 // onkeycapturechange before the corresponding onchange, and the page would | 934 // onkeycapturechange before the corresponding onchange, and the page would |
935 // have no way of telling whether the keycapturechange happened because of | 935 // have no way of telling whether the keycapturechange happened because of |
936 // some actual user action or just because they started typing.) | 936 // some actual user action or just because they started typing.) |
937 if (extended_enabled_ && GetOverlayContents() && | 937 if (extended_enabled_ && GetOverlayContents() && |
samarth
2013/05/13 20:56:53
Just need to check extended_enabled_ here. The Get
Donn Denman
2013/05/13 23:44:50
Done.
| |
938 reason != OMNIBOX_FOCUS_CHANGE_TYPING) { | 938 reason != OMNIBOX_FOCUS_CHANGE_TYPING) { |
939 const bool is_key_capture_enabled = | |
940 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE; | |
941 if (overlay_) | 939 if (overlay_) |
942 overlay_->KeyCaptureChanged(is_key_capture_enabled); | 940 overlay_->KeyCaptureChanged(omnibox_focus_state_, reason); |
943 if (instant_tab_) | 941 if (instant_tab_) |
944 instant_tab_->KeyCaptureChanged(is_key_capture_enabled); | 942 instant_tab_->KeyCaptureChanged(omnibox_focus_state_, reason); |
945 } | 943 } |
946 | 944 |
947 if (state == OMNIBOX_FOCUS_VISIBLE && old_focus_state == OMNIBOX_FOCUS_NONE) { | 945 if (state == OMNIBOX_FOCUS_VISIBLE && old_focus_state == OMNIBOX_FOCUS_NONE) { |
948 // If the user explicitly focused the omnibox, then create the overlay if | 946 // If the user explicitly focused the omnibox, then create the overlay if |
949 // it doesn't exist. If we're using a fallback overlay, try loading the | 947 // it doesn't exist. If we're using a fallback overlay, try loading the |
950 // remote overlay again. | 948 // remote overlay again. |
951 if (!overlay_ || (overlay_->IsLocal() && !use_local_page_only_)) | 949 if (!overlay_ || (overlay_->IsLocal() && !use_local_page_only_)) |
952 ResetOverlay(GetInstantURL()); | 950 ResetOverlay(GetInstantURL()); |
953 } else if (state == OMNIBOX_FOCUS_NONE && | 951 } else if (state == OMNIBOX_FOCUS_NONE && |
954 old_focus_state != OMNIBOX_FOCUS_NONE) { | 952 old_focus_state != OMNIBOX_FOCUS_NONE) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1154 const content::WebContents* contents) { | 1152 const content::WebContents* contents) { |
1155 if (!extended_enabled_) | 1153 if (!extended_enabled_) |
1156 return; | 1154 return; |
1157 | 1155 |
1158 // Update theme info so that the page picks it up. | 1156 // Update theme info so that the page picks it up. |
1159 browser_->UpdateThemeInfo(); | 1157 browser_->UpdateThemeInfo(); |
1160 | 1158 |
1161 // Ensure the searchbox API has the correct initial state. | 1159 // Ensure the searchbox API has the correct initial state. |
1162 if (IsContentsFrom(overlay(), contents)) { | 1160 if (IsContentsFrom(overlay(), contents)) { |
1163 overlay_->SetDisplayInstantResults(instant_enabled_); | 1161 overlay_->SetDisplayInstantResults(instant_enabled_); |
1164 overlay_->KeyCaptureChanged( | 1162 overlay_->KeyCaptureChanged(omnibox_focus_state_, |
1165 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); | 1163 OMNIBOX_FOCUS_CHANGE_INIT); |
samarth
2013/05/13 20:56:53
Don't need a new INIT value. OMNIBOX_FOCUS_CHANGE
samarth
2013/05/13 21:01:10
Actually, we should be saving the reason inside In
Donn Denman
2013/05/13 23:44:50
Done.
Donn Denman
2013/05/13 23:44:50
Done.
| |
1166 overlay_->SetOmniboxBounds(omnibox_bounds_); | 1164 overlay_->SetOmniboxBounds(omnibox_bounds_); |
1167 overlay_->InitializeFonts(); | 1165 overlay_->InitializeFonts(); |
1168 } else if (IsContentsFrom(ntp(), contents)) { | 1166 } else if (IsContentsFrom(ntp(), contents)) { |
1169 ntp_->SetDisplayInstantResults(instant_enabled_); | 1167 ntp_->SetDisplayInstantResults(instant_enabled_); |
1170 ntp_->SetOmniboxBounds(omnibox_bounds_); | 1168 ntp_->SetOmniboxBounds(omnibox_bounds_); |
1171 ntp_->InitializeFonts(); | 1169 ntp_->InitializeFonts(); |
1172 } else { | 1170 } else { |
1173 NOTREACHED(); | 1171 NOTREACHED(); |
1174 } | 1172 } |
1175 StartListeningToMostVisitedChanges(); | 1173 StartListeningToMostVisitedChanges(); |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1534 } | 1532 } |
1535 } | 1533 } |
1536 | 1534 |
1537 void InstantController::UpdateInfoForInstantTab() { | 1535 void InstantController::UpdateInfoForInstantTab() { |
1538 if (instant_tab_) { | 1536 if (instant_tab_) { |
1539 browser_->UpdateThemeInfo(); | 1537 browser_->UpdateThemeInfo(); |
1540 instant_tab_->SetDisplayInstantResults(instant_enabled_); | 1538 instant_tab_->SetDisplayInstantResults(instant_enabled_); |
1541 instant_tab_->SetOmniboxBounds(omnibox_bounds_); | 1539 instant_tab_->SetOmniboxBounds(omnibox_bounds_); |
1542 instant_tab_->InitializeFonts(); | 1540 instant_tab_->InitializeFonts(); |
1543 StartListeningToMostVisitedChanges(); | 1541 StartListeningToMostVisitedChanges(); |
1544 instant_tab_->KeyCaptureChanged( | 1542 instant_tab_->KeyCaptureChanged(omnibox_focus_state_, |
1545 omnibox_focus_state_ == OMNIBOX_FOCUS_INVISIBLE); | 1543 OMNIBOX_FOCUS_CHANGE_INIT); // TODO(donnd): right reason? |
samarth
2013/05/13 21:01:10
Likewise, here.
Donn Denman
2013/05/13 23:44:50
Done.
| |
1546 } | 1544 } |
1547 } | 1545 } |
1548 | 1546 |
1549 void InstantController::HideOverlay() { | 1547 void InstantController::HideOverlay() { |
1550 HideInternal(); | 1548 HideInternal(); |
1551 ReloadOverlayIfStale(); | 1549 ReloadOverlayIfStale(); |
1552 } | 1550 } |
1553 | 1551 |
1554 void InstantController::HideInternal() { | 1552 void InstantController::HideInternal() { |
1555 LOG_INSTANT_DEBUG_EVENT(this, "Hide"); | 1553 LOG_INSTANT_DEBUG_EVENT(this, "Hide"); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1806 | 1804 |
1807 result->transition = match.transition; | 1805 result->transition = match.transition; |
1808 result->relevance = match.relevance; | 1806 result->relevance = match.relevance; |
1809 result->autocomplete_match_index = autocomplete_match_index; | 1807 result->autocomplete_match_index = autocomplete_match_index; |
1810 | 1808 |
1811 DVLOG(1) << " " << result->relevance << " " << result->type << " " | 1809 DVLOG(1) << " " << result->relevance << " " << result->type << " " |
1812 << result->provider << " " << result->destination_url << " '" | 1810 << result->provider << " " << result->destination_url << " '" |
1813 << result->description << "' '" << result->search_query << "' " | 1811 << result->description << "' '" << result->search_query << "' " |
1814 << result->transition << " " << result->autocomplete_match_index; | 1812 << result->transition << " " << result->autocomplete_match_index; |
1815 } | 1813 } |
OLD | NEW |