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