| 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/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 Loading... |
| 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()->GetSearchTermsType() != |
| 395 ToolbarModel::NO_SEARCH_TERMS) |
| 395 return false; | 396 return false; |
| 396 | 397 |
| 397 // If current text is not composed of replaced search terms and | 398 // 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 | 399 // !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, | 400 // 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 | 401 // we avoid calling into the autocomplete providers, and thus initializing the |
| 401 // history system, as long as possible, which speeds startup. | 402 // history system, as long as possible, which speeds startup. |
| 402 if (!user_input_in_progress_) | 403 if (!user_input_in_progress_) |
| 403 return true; | 404 return true; |
| 404 | 405 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 415 | 416 |
| 416 void OmniboxEditModel::AdjustTextForCopy(int sel_min, | 417 void OmniboxEditModel::AdjustTextForCopy(int sel_min, |
| 417 bool is_all_selected, | 418 bool is_all_selected, |
| 418 string16* text, | 419 string16* text, |
| 419 GURL* url, | 420 GURL* url, |
| 420 bool* write_url) { | 421 bool* write_url) { |
| 421 *write_url = false; | 422 *write_url = false; |
| 422 | 423 |
| 423 // Do not adjust if selection did not start at the beginning of the field, or | 424 // Do not adjust if selection did not start at the beginning of the field, or |
| 424 // if the URL was replaced by search terms. | 425 // if the URL was replaced by search terms. |
| 425 if (sel_min != 0 || | 426 if ((sel_min != 0) || |
| 426 view_->toolbar_model()->WouldReplaceSearchURLWithSearchTerms()) | 427 (view_->toolbar_model()->GetSearchTermsType() != |
| 428 ToolbarModel::NO_SEARCH_TERMS)) |
| 427 return; | 429 return; |
| 428 | 430 |
| 429 if (!user_input_in_progress_ && is_all_selected) { | 431 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 | 432 // 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 | 433 // 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). | 434 // is unescaped (we escape parts of the url for display). |
| 433 *url = PermanentURL(); | 435 *url = PermanentURL(); |
| 434 *text = UTF8ToUTF16(url->spec()); | 436 *text = UTF8ToUTF16(url->spec()); |
| 435 *write_url = true; | 437 *write_url = true; |
| 436 return; | 438 return; |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 instant->OmniboxFocusChanged(state, reason, NULL); | 1458 instant->OmniboxFocusChanged(state, reason, NULL); |
| 1457 | 1459 |
| 1458 // Update state and notify view if the omnibox has focus and the caret | 1460 // Update state and notify view if the omnibox has focus and the caret |
| 1459 // visibility changed. | 1461 // visibility changed. |
| 1460 const bool was_caret_visible = is_caret_visible(); | 1462 const bool was_caret_visible = is_caret_visible(); |
| 1461 focus_state_ = state; | 1463 focus_state_ = state; |
| 1462 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1464 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1463 is_caret_visible() != was_caret_visible) | 1465 is_caret_visible() != was_caret_visible) |
| 1464 view_->ApplyCaretVisibility(); | 1466 view_->ApplyCaretVisibility(); |
| 1465 } | 1467 } |
| OLD | NEW |