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 "base/metrics/histogram.h" | 7 #include "base/metrics/histogram.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1179 ShowOverlay(100, INSTANT_SIZE_PERCENT); | 1179 ShowOverlay(100, INSTANT_SIZE_PERCENT); |
1180 } | 1180 } |
1181 | 1181 |
1182 void InstantController::ShowInstantOverlay(const content::WebContents* contents, | 1182 void InstantController::ShowInstantOverlay(const content::WebContents* contents, |
1183 int height, | 1183 int height, |
1184 InstantSizeUnits units) { | 1184 InstantSizeUnits units) { |
1185 if (extended_enabled_ && IsContentsFrom(overlay(), contents)) | 1185 if (extended_enabled_ && IsContentsFrom(overlay(), contents)) |
1186 ShowOverlay(height, units); | 1186 ShowOverlay(height, units); |
1187 } | 1187 } |
1188 | 1188 |
1189 void InstantController::FocusOmnibox(const content::WebContents* contents) { | 1189 void InstantController::FocusOmnibox(const content::WebContents* contents, |
1190 if (!extended_enabled_) | 1190 OmniboxFocusState state) { |
1191 if (!extended_enabled_ || | |
1192 !instant_tab_ || | |
1193 !IsContentsFrom(instant_tab(), contents)) | |
1191 return; | 1194 return; |
1192 | 1195 |
1193 DCHECK(IsContentsFrom(instant_tab(), contents)); | 1196 switch (state) { |
1194 browser_->FocusOmnibox(true); | 1197 case OMNIBOX_FOCUS_VISIBLE: |
1195 } | 1198 if (instant_tab_->ShouldProcessFocusOmnibox()) |
sreeram
2013/04/01 16:04:38
These Should*() checks are not needed here. So, th
kmadhusu
2013/04/02 02:06:50
Done.
| |
1196 | 1199 browser_->FocusOmnibox(true); |
1197 void InstantController::StartCapturingKeyStrokes( | 1200 break; |
1198 const content::WebContents* contents) { | 1201 case OMNIBOX_FOCUS_INVISIBLE: |
1199 if (!extended_enabled_) | 1202 if (instant_tab_->ShouldProcessStartCapturingKeyStrokes()) |
1200 return; | 1203 browser_->FocusOmnibox(false); |
1201 | 1204 break; |
1202 DCHECK(IsContentsFrom(instant_tab(), contents)); | 1205 case OMNIBOX_FOCUS_NONE: |
1203 browser_->FocusOmnibox(false); | 1206 if (instant_tab_->ShouldProcessStopCapturingKeyStrokes() && |
1204 } | 1207 omnibox_focus_state_ != OMNIBOX_FOCUS_INVISIBLE) |
1205 | 1208 contents->GetView()->Focus(); |
1206 void InstantController::StopCapturingKeyStrokes( | 1209 break; |
1207 content::WebContents* contents) { | 1210 default: |
1208 // Nothing to do if omnibox doesn't have invisible focus. | 1211 NOTREACHED(); |
1209 if (!extended_enabled_ || omnibox_focus_state_ != OMNIBOX_FOCUS_INVISIBLE) | 1212 } |
1210 return; | |
1211 | |
1212 DCHECK(IsContentsFrom(instant_tab(), contents)); | |
1213 contents->GetView()->Focus(); | |
1214 } | 1213 } |
1215 | 1214 |
1216 void InstantController::NavigateToURL(const content::WebContents* contents, | 1215 void InstantController::NavigateToURL(const content::WebContents* contents, |
1217 const GURL& url, | 1216 const GURL& url, |
1218 content::PageTransition transition, | 1217 content::PageTransition transition, |
1219 WindowOpenDisposition disposition) { | 1218 WindowOpenDisposition disposition) { |
1220 LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf( | 1219 LOG_INSTANT_DEBUG_EVENT(this, base::StringPrintf( |
1221 "NavigateToURL: url='%s'", url.spec().c_str())); | 1220 "NavigateToURL: url='%s'", url.spec().c_str())); |
1222 | 1221 |
1223 // TODO(samarth): handle case where contents are no longer "active" (e.g. user | 1222 // TODO(samarth): handle case where contents are no longer "active" (e.g. user |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1623 // for instance, if the user types 'i' and the suggestion is 'INSTANT', | 1622 // for instance, if the user types 'i' and the suggestion is 'INSTANT', |
1624 // suggest 'nstant'. Otherwise, the user text really isn't a prefix, so | 1623 // suggest 'nstant'. Otherwise, the user text really isn't a prefix, so |
1625 // suggest nothing. | 1624 // suggest nothing. |
1626 // TODO(samarth|jered): revisit this logic. http://crbug.com/196572. | 1625 // TODO(samarth|jered): revisit this logic. http://crbug.com/196572. |
1627 return true; | 1626 return true; |
1628 } | 1627 } |
1629 } | 1628 } |
1630 | 1629 |
1631 return false; | 1630 return false; |
1632 } | 1631 } |
OLD | NEW |