| 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/ui/views/omnibox/omnibox_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 Profile* profile, | 135 Profile* profile, |
| 136 CommandUpdater* command_updater, | 136 CommandUpdater* command_updater, |
| 137 bool popup_window_mode, | 137 bool popup_window_mode, |
| 138 LocationBarView* location_bar, | 138 LocationBarView* location_bar, |
| 139 const gfx::FontList& font_list) | 139 const gfx::FontList& font_list) |
| 140 : OmniboxView( | 140 : OmniboxView( |
| 141 controller, | 141 controller, |
| 142 make_scoped_ptr(new ChromeOmniboxClient(controller, profile))), | 142 make_scoped_ptr(new ChromeOmniboxClient(controller, profile))), |
| 143 profile_(profile), | 143 profile_(profile), |
| 144 popup_window_mode_(popup_window_mode), | 144 popup_window_mode_(popup_window_mode), |
| 145 security_level_(SecurityStateModel::NONE), | 145 security_level_(security_state::SecurityStateModel::NONE), |
| 146 saved_selection_for_focus_change_(gfx::Range::InvalidRange()), | 146 saved_selection_for_focus_change_(gfx::Range::InvalidRange()), |
| 147 ime_composing_before_change_(false), | 147 ime_composing_before_change_(false), |
| 148 delete_at_end_pressed_(false), | 148 delete_at_end_pressed_(false), |
| 149 location_bar_view_(location_bar), | 149 location_bar_view_(location_bar), |
| 150 ime_candidate_window_open_(false), | 150 ime_candidate_window_open_(false), |
| 151 select_all_on_mouse_release_(false), | 151 select_all_on_mouse_release_(false), |
| 152 select_all_on_gesture_tap_(false), | 152 select_all_on_gesture_tap_(false), |
| 153 weak_ptr_factory_(this) { | 153 weak_ptr_factory_(this) { |
| 154 SetBorder(views::Border::NullBorder()); | 154 SetBorder(views::Border::NullBorder()); |
| 155 set_id(VIEW_ID_OMNIBOX); | 155 set_id(VIEW_ID_OMNIBOX); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 | 220 |
| 221 // TODO(msw|oshima): Consider saving/restoring edit history. | 221 // TODO(msw|oshima): Consider saving/restoring edit history. |
| 222 ClearEditHistory(); | 222 ClearEditHistory(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 void OmniboxViewViews::ResetTabState(content::WebContents* web_contents) { | 225 void OmniboxViewViews::ResetTabState(content::WebContents* web_contents) { |
| 226 web_contents->SetUserData(OmniboxState::kKey, nullptr); | 226 web_contents->SetUserData(OmniboxState::kKey, nullptr); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void OmniboxViewViews::Update() { | 229 void OmniboxViewViews::Update() { |
| 230 const SecurityStateModel::SecurityLevel old_security_level = security_level_; | 230 const security_state::SecurityStateModel::SecurityLevel old_security_level = |
| 231 security_level_; |
| 231 UpdateSecurityLevel(); | 232 UpdateSecurityLevel(); |
| 232 if (model()->UpdatePermanentText()) { | 233 if (model()->UpdatePermanentText()) { |
| 233 // Something visibly changed. Re-enable URL replacement. | 234 // Something visibly changed. Re-enable URL replacement. |
| 234 controller()->GetToolbarModel()->set_url_replacement_enabled(true); | 235 controller()->GetToolbarModel()->set_url_replacement_enabled(true); |
| 235 model()->UpdatePermanentText(); | 236 model()->UpdatePermanentText(); |
| 236 | 237 |
| 237 // Select all the new text if the user had all the old text selected, or if | 238 // Select all the new text if the user had all the old text selected, or if |
| 238 // there was no previous text (for new tab page URL replacement extensions). | 239 // there was no previous text (for new tab page URL replacement extensions). |
| 239 // This makes one particular case better: the user clicks in the box to | 240 // This makes one particular case better: the user clicks in the box to |
| 240 // change it right before the permanent URL is changed. Since the new URL | 241 // change it right before the permanent URL is changed. Since the new URL |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 gfx::Range(host.begin, host.end())); | 641 gfx::Range(host.begin, host.end())); |
| 641 } | 642 } |
| 642 | 643 |
| 643 // Emphasize the scheme for security UI display purposes (if necessary). | 644 // Emphasize the scheme for security UI display purposes (if necessary). |
| 644 // Note that we check CurrentTextIsURL() because if we're replacing search | 645 // Note that we check CurrentTextIsURL() because if we're replacing search |
| 645 // URLs with search terms, we may have a non-URL even when the user is not | 646 // URLs with search terms, we may have a non-URL even when the user is not |
| 646 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser | 647 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser |
| 647 // may have incorrectly identified a qualifier as a scheme. | 648 // may have incorrectly identified a qualifier as a scheme. |
| 648 SetStyle(gfx::DIAGONAL_STRIKE, false); | 649 SetStyle(gfx::DIAGONAL_STRIKE, false); |
| 649 if (!model()->user_input_in_progress() && text_is_url && | 650 if (!model()->user_input_in_progress() && text_is_url && |
| 650 scheme.is_nonempty() && (security_level_ != SecurityStateModel::NONE)) { | 651 scheme.is_nonempty() && |
| 652 (security_level_ != security_state::SecurityStateModel::NONE)) { |
| 651 SkColor security_color = | 653 SkColor security_color = |
| 652 location_bar_view_->GetSecureTextColor(security_level_); | 654 location_bar_view_->GetSecureTextColor(security_level_); |
| 653 const bool strike = (security_level_ == SecurityStateModel::SECURITY_ERROR); | 655 const bool strike = |
| 656 (security_level_ == security_state::SecurityStateModel::SECURITY_ERROR); |
| 654 const gfx::Range scheme_range(scheme.begin, scheme.end()); | 657 const gfx::Range scheme_range(scheme.begin, scheme.end()); |
| 655 ApplyColor(security_color, scheme_range); | 658 ApplyColor(security_color, scheme_range); |
| 656 ApplyStyle(gfx::DIAGONAL_STRIKE, strike, scheme_range); | 659 ApplyStyle(gfx::DIAGONAL_STRIKE, strike, scheme_range); |
| 657 } | 660 } |
| 658 } | 661 } |
| 659 | 662 |
| 660 bool OmniboxViewViews::OnKeyReleased(const ui::KeyEvent& event) { | 663 bool OmniboxViewViews::OnKeyReleased(const ui::KeyEvent& event) { |
| 661 // The omnibox contents may change while the control key is pressed. | 664 // The omnibox contents may change while the control key is pressed. |
| 662 if (event.key_code() == ui::VKEY_CONTROL) | 665 if (event.key_code() == ui::VKEY_CONTROL) |
| 663 model()->OnControlKeyChanged(false); | 666 model()->OnControlKeyChanged(false); |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 menu_contents->InsertItemWithStringIdAt( | 1073 menu_contents->InsertItemWithStringIdAt( |
| 1071 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); | 1074 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); |
| 1072 } | 1075 } |
| 1073 | 1076 |
| 1074 // Minor note: We use IDC_ for command id here while the underlying textfield | 1077 // Minor note: We use IDC_ for command id here while the underlying textfield |
| 1075 // is using IDS_ for all its command ids. This is because views cannot depend | 1078 // is using IDS_ for all its command ids. This is because views cannot depend |
| 1076 // on IDC_ for now. | 1079 // on IDC_ for now. |
| 1077 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1080 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
| 1078 IDS_EDIT_SEARCH_ENGINES); | 1081 IDS_EDIT_SEARCH_ENGINES); |
| 1079 } | 1082 } |
| OLD | NEW |