Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_edit_model.cc

Issue 14259008: Instant Extended: Add prominent search term support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/omnibox/omnibox_edit_model.h" 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/format_macros.h" 10 #include "base/format_macros.h"
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 // 2. If it's in IME composition mode. 384 // 2. If it's in IME composition mode.
385 // We send the caret position to Instant (so it can determine #1 itself), and 385 // We send the caret position to Instant (so it can determine #1 itself), and
386 // we use a separated widget for displaying the Instant suggest (so it doesn't 386 // we use a separated widget for displaying the Instant suggest (so it doesn't
387 // interfere with #2). So, we don't need to care about the value of 387 // interfere with #2). So, we don't need to care about the value of
388 // input.prevent_inline_autocomplete() here. 388 // input.prevent_inline_autocomplete() here.
389 return view_->DeleteAtEndPressed() || popup_->selected_line() != 0 || 389 return view_->DeleteAtEndPressed() || popup_->selected_line() != 0 ||
390 just_deleted_text_; 390 just_deleted_text_;
391 } 391 }
392 392
393 bool OmniboxEditModel::CurrentTextIsURL() const { 393 bool OmniboxEditModel::CurrentTextIsURL() const {
394 if (view_->toolbar_model()->WouldReplaceSearchURLWithSearchTerms()) 394 if (view_->toolbar_model()->GetSearchTermType() !=
395 ToolbarModel::SEARCH_TERM_NONE) {
395 return false; 396 return false;
397 }
sreeram 2013/04/23 22:56:45 Nit: no curlies. I believe the style is to put cur
sail 2013/04/24 00:22:23 Done.
396 398
397 // If current text is not composed of replaced search terms and 399 // If current text is not composed of replaced search terms and
398 // !user_input_in_progress_, then permanent text is showing and should be a 400 // !user_input_in_progress_, then permanent text is showing and should be a
399 // URL, so no further checking is needed. By avoiding checking in this case, 401 // URL, so no further checking is needed. By avoiding checking in this case,
400 // we avoid calling into the autocomplete providers, and thus initializing the 402 // we avoid calling into the autocomplete providers, and thus initializing the
401 // history system, as long as possible, which speeds startup. 403 // history system, as long as possible, which speeds startup.
402 if (!user_input_in_progress_) 404 if (!user_input_in_progress_)
403 return true; 405 return true;
404 406
405 AutocompleteMatch match; 407 AutocompleteMatch match;
406 GetInfoForCurrentText(&match, NULL); 408 GetInfoForCurrentText(&match, NULL);
407 return !AutocompleteMatch::IsSearchType(match.type); 409 return !AutocompleteMatch::IsSearchType(match.type);
408 } 410 }
409 411
410 AutocompleteMatch::Type OmniboxEditModel::CurrentTextType() const { 412 AutocompleteMatch::Type OmniboxEditModel::CurrentTextType() const {
411 AutocompleteMatch match; 413 AutocompleteMatch match;
412 GetInfoForCurrentText(&match, NULL); 414 GetInfoForCurrentText(&match, NULL);
413 return match.type; 415 return match.type;
414 } 416 }
415 417
416 void OmniboxEditModel::AdjustTextForCopy(int sel_min, 418 void OmniboxEditModel::AdjustTextForCopy(int sel_min,
417 bool is_all_selected, 419 bool is_all_selected,
418 string16* text, 420 string16* text,
419 GURL* url, 421 GURL* url,
420 bool* write_url) { 422 bool* write_url) {
421 *write_url = false; 423 *write_url = false;
422 424
423 // Do not adjust if selection did not start at the beginning of the field, or 425 // Do not adjust if selection did not start at the beginning of the field, or
424 // if the URL was replaced by search terms. 426 // if the URL was replaced by search terms.
425 if (sel_min != 0 || 427 if (sel_min != 0 || view_->toolbar_model()->GetSearchTermType() !=
426 view_->toolbar_model()->WouldReplaceSearchURLWithSearchTerms()) 428 ToolbarModel::SEARCH_TERM_NONE) {
sreeram 2013/04/23 22:56:45 Nit: No curlies. Maybe also indent line 428 four m
sail 2013/04/24 00:22:23 Done. (Kept the indentation so that I don't have t
427 return; 429 return;
430 }
428 431
429 if (!user_input_in_progress_ && is_all_selected) { 432 if (!user_input_in_progress_ && is_all_selected) {
430 // The user selected all the text and has not edited it. Use the url as the 433 // The user selected all the text and has not edited it. Use the url as the
431 // text so that if the scheme was stripped it's added back, and the url 434 // text so that if the scheme was stripped it's added back, and the url
432 // is unescaped (we escape parts of the url for display). 435 // is unescaped (we escape parts of the url for display).
433 *url = PermanentURL(); 436 *url = PermanentURL();
434 *text = UTF8ToUTF16(url->spec()); 437 *text = UTF8ToUTF16(url->spec());
435 *write_url = true; 438 *write_url = true;
436 return; 439 return;
437 } 440 }
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after
1456 instant->OmniboxFocusChanged(state, reason, NULL); 1459 instant->OmniboxFocusChanged(state, reason, NULL);
1457 1460
1458 // Update state and notify view if the omnibox has focus and the caret 1461 // Update state and notify view if the omnibox has focus and the caret
1459 // visibility changed. 1462 // visibility changed.
1460 const bool was_caret_visible = is_caret_visible(); 1463 const bool was_caret_visible = is_caret_visible();
1461 focus_state_ = state; 1464 focus_state_ = state;
1462 if (focus_state_ != OMNIBOX_FOCUS_NONE && 1465 if (focus_state_ != OMNIBOX_FOCUS_NONE &&
1463 is_caret_visible() != was_caret_visible) 1466 is_caret_visible() != was_caret_visible)
1464 view_->ApplyCaretVisibility(); 1467 view_->ApplyCaretVisibility();
1465 } 1468 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698