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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 Profile* profile, | 110 Profile* profile, |
111 CommandUpdater* command_updater, | 111 CommandUpdater* command_updater, |
112 bool popup_window_mode, | 112 bool popup_window_mode, |
113 LocationBarView* location_bar, | 113 LocationBarView* location_bar, |
114 const gfx::FontList& font_list) | 114 const gfx::FontList& font_list) |
115 : OmniboxView( | 115 : OmniboxView( |
116 controller, | 116 controller, |
117 base::WrapUnique(new ChromeOmniboxClient(controller, profile))), | 117 base::WrapUnique(new ChromeOmniboxClient(controller, profile))), |
118 profile_(profile), | 118 profile_(profile), |
119 popup_window_mode_(popup_window_mode), | 119 popup_window_mode_(popup_window_mode), |
120 security_level_(security_state::SecurityStateModel::NONE), | 120 security_level_(security_state::NONE), |
121 saved_selection_for_focus_change_(gfx::Range::InvalidRange()), | 121 saved_selection_for_focus_change_(gfx::Range::InvalidRange()), |
122 ime_composing_before_change_(false), | 122 ime_composing_before_change_(false), |
123 delete_at_end_pressed_(false), | 123 delete_at_end_pressed_(false), |
124 location_bar_view_(location_bar), | 124 location_bar_view_(location_bar), |
125 ime_candidate_window_open_(false), | 125 ime_candidate_window_open_(false), |
126 select_all_on_mouse_release_(false), | 126 select_all_on_mouse_release_(false), |
127 select_all_on_gesture_tap_(false) { | 127 select_all_on_gesture_tap_(false) { |
128 set_id(VIEW_ID_OMNIBOX); | 128 set_id(VIEW_ID_OMNIBOX); |
129 SetFontList(font_list); | 129 SetFontList(font_list); |
130 } | 130 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 193 |
194 // TODO(msw|oshima): Consider saving/restoring edit history. | 194 // TODO(msw|oshima): Consider saving/restoring edit history. |
195 ClearEditHistory(); | 195 ClearEditHistory(); |
196 } | 196 } |
197 | 197 |
198 void OmniboxViewViews::ResetTabState(content::WebContents* web_contents) { | 198 void OmniboxViewViews::ResetTabState(content::WebContents* web_contents) { |
199 web_contents->SetUserData(OmniboxState::kKey, nullptr); | 199 web_contents->SetUserData(OmniboxState::kKey, nullptr); |
200 } | 200 } |
201 | 201 |
202 void OmniboxViewViews::Update() { | 202 void OmniboxViewViews::Update() { |
203 const security_state::SecurityStateModel::SecurityLevel old_security_level = | 203 const security_state::SecurityLevel old_security_level = security_level_; |
204 security_level_; | |
205 UpdateSecurityLevel(); | 204 UpdateSecurityLevel(); |
206 if (model()->UpdatePermanentText()) { | 205 if (model()->UpdatePermanentText()) { |
207 // Select all the new text if the user had all the old text selected, or if | 206 // Select all the new text if the user had all the old text selected, or if |
208 // there was no previous text (for new tab page URL replacement extensions). | 207 // there was no previous text (for new tab page URL replacement extensions). |
209 // This makes one particular case better: the user clicks in the box to | 208 // This makes one particular case better: the user clicks in the box to |
210 // change it right before the permanent URL is changed. Since the new URL | 209 // change it right before the permanent URL is changed. Since the new URL |
211 // is still fully selected, the user's typing will replace the edit contents | 210 // is still fully selected, the user's typing will replace the edit contents |
212 // as they'd intended. | 211 // as they'd intended. |
213 const bool was_select_all = IsSelectAll(); | 212 const bool was_select_all = IsSelectAll(); |
214 const bool was_reversed = GetSelectedRange().is_reversed(); | 213 const bool was_reversed = GetSelectedRange().is_reversed(); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 gfx::Range(host.begin, host.end())); | 602 gfx::Range(host.begin, host.end())); |
604 } | 603 } |
605 | 604 |
606 // Emphasize the scheme for security UI display purposes (if necessary). | 605 // Emphasize the scheme for security UI display purposes (if necessary). |
607 // Note that we check CurrentTextIsURL() because if we're replacing search | 606 // Note that we check CurrentTextIsURL() because if we're replacing search |
608 // URLs with search terms, we may have a non-URL even when the user is not | 607 // URLs with search terms, we may have a non-URL even when the user is not |
609 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser | 608 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser |
610 // may have incorrectly identified a qualifier as a scheme. | 609 // may have incorrectly identified a qualifier as a scheme. |
611 SetStyle(gfx::DIAGONAL_STRIKE, false); | 610 SetStyle(gfx::DIAGONAL_STRIKE, false); |
612 if (!model()->user_input_in_progress() && text_is_url && | 611 if (!model()->user_input_in_progress() && text_is_url && |
613 scheme.is_nonempty() && | 612 scheme.is_nonempty() && (security_level_ != security_state::NONE)) { |
614 (security_level_ != security_state::SecurityStateModel::NONE)) { | |
615 SkColor security_color = | 613 SkColor security_color = |
616 location_bar_view_->GetSecureTextColor(security_level_); | 614 location_bar_view_->GetSecureTextColor(security_level_); |
617 const bool strike = | 615 const bool strike = (security_level_ == security_state::DANGEROUS); |
618 (security_level_ == security_state::SecurityStateModel::DANGEROUS); | |
619 const gfx::Range scheme_range(scheme.begin, scheme.end()); | 616 const gfx::Range scheme_range(scheme.begin, scheme.end()); |
620 ApplyColor(security_color, scheme_range); | 617 ApplyColor(security_color, scheme_range); |
621 ApplyStyle(gfx::DIAGONAL_STRIKE, strike, scheme_range); | 618 ApplyStyle(gfx::DIAGONAL_STRIKE, strike, scheme_range); |
622 } | 619 } |
623 } | 620 } |
624 | 621 |
625 bool OmniboxViewViews::IsItemForCommandIdDynamic(int command_id) const { | 622 bool OmniboxViewViews::IsItemForCommandIdDynamic(int command_id) const { |
626 return command_id == IDS_PASTE_AND_GO; | 623 return command_id == IDS_PASTE_AND_GO; |
627 } | 624 } |
628 | 625 |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1086 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
1090 | 1087 |
1091 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1088 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
1092 | 1089 |
1093 // Minor note: We use IDC_ for command id here while the underlying textfield | 1090 // Minor note: We use IDC_ for command id here while the underlying textfield |
1094 // is using IDS_ for all its command ids. This is because views cannot depend | 1091 // is using IDS_ for all its command ids. This is because views cannot depend |
1095 // on IDC_ for now. | 1092 // on IDC_ for now. |
1096 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1093 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
1097 IDS_EDIT_SEARCH_ENGINES); | 1094 IDS_EDIT_SEARCH_ENGINES); |
1098 } | 1095 } |
OLD | NEW |