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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 Profile* profile, | 109 Profile* profile, |
110 CommandUpdater* command_updater, | 110 CommandUpdater* command_updater, |
111 bool popup_window_mode, | 111 bool popup_window_mode, |
112 LocationBarView* location_bar, | 112 LocationBarView* location_bar, |
113 const gfx::FontList& font_list) | 113 const gfx::FontList& font_list) |
114 : OmniboxView( | 114 : OmniboxView( |
115 controller, | 115 controller, |
116 base::WrapUnique(new ChromeOmniboxClient(controller, profile))), | 116 base::WrapUnique(new ChromeOmniboxClient(controller, profile))), |
117 profile_(profile), | 117 profile_(profile), |
118 popup_window_mode_(popup_window_mode), | 118 popup_window_mode_(popup_window_mode), |
119 security_level_(security_state::SecurityStateModel::NONE), | 119 security_level_(security_state::NONE), |
120 saved_selection_for_focus_change_(gfx::Range::InvalidRange()), | 120 saved_selection_for_focus_change_(gfx::Range::InvalidRange()), |
121 ime_composing_before_change_(false), | 121 ime_composing_before_change_(false), |
122 delete_at_end_pressed_(false), | 122 delete_at_end_pressed_(false), |
123 location_bar_view_(location_bar), | 123 location_bar_view_(location_bar), |
124 ime_candidate_window_open_(false), | 124 ime_candidate_window_open_(false), |
125 select_all_on_mouse_release_(false), | 125 select_all_on_mouse_release_(false), |
126 select_all_on_gesture_tap_(false), | 126 select_all_on_gesture_tap_(false), |
127 weak_ptr_factory_(this) { | 127 weak_ptr_factory_(this) { |
128 set_id(VIEW_ID_OMNIBOX); | 128 set_id(VIEW_ID_OMNIBOX); |
129 SetFontList(font_list); | 129 SetFontList(font_list); |
(...skipping 63 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 gfx::Range(host.begin, host.end())); | 616 gfx::Range(host.begin, host.end())); |
618 } | 617 } |
619 | 618 |
620 // Emphasize the scheme for security UI display purposes (if necessary). | 619 // Emphasize the scheme for security UI display purposes (if necessary). |
621 // Note that we check CurrentTextIsURL() because if we're replacing search | 620 // Note that we check CurrentTextIsURL() because if we're replacing search |
622 // URLs with search terms, we may have a non-URL even when the user is not | 621 // URLs with search terms, we may have a non-URL even when the user is not |
623 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser | 622 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser |
624 // may have incorrectly identified a qualifier as a scheme. | 623 // may have incorrectly identified a qualifier as a scheme. |
625 SetStyle(gfx::DIAGONAL_STRIKE, false); | 624 SetStyle(gfx::DIAGONAL_STRIKE, false); |
626 if (!model()->user_input_in_progress() && text_is_url && | 625 if (!model()->user_input_in_progress() && text_is_url && |
627 scheme.is_nonempty() && | 626 scheme.is_nonempty() && (security_level_ != security_state::NONE)) { |
628 (security_level_ != security_state::SecurityStateModel::NONE)) { | |
629 SkColor security_color = | 627 SkColor security_color = |
630 location_bar_view_->GetSecureTextColor(security_level_); | 628 location_bar_view_->GetSecureTextColor(security_level_); |
631 const bool strike = | 629 const bool strike = (security_level_ == security_state::DANGEROUS); |
632 (security_level_ == security_state::SecurityStateModel::DANGEROUS); | |
633 const gfx::Range scheme_range(scheme.begin, scheme.end()); | 630 const gfx::Range scheme_range(scheme.begin, scheme.end()); |
634 ApplyColor(security_color, scheme_range); | 631 ApplyColor(security_color, scheme_range); |
635 ApplyStyle(gfx::DIAGONAL_STRIKE, strike, scheme_range); | 632 ApplyStyle(gfx::DIAGONAL_STRIKE, strike, scheme_range); |
636 } | 633 } |
637 } | 634 } |
638 | 635 |
639 bool OmniboxViewViews::IsItemForCommandIdDynamic(int command_id) const { | 636 bool OmniboxViewViews::IsItemForCommandIdDynamic(int command_id) const { |
640 return command_id == IDS_PASTE_AND_GO; | 637 return command_id == IDS_PASTE_AND_GO; |
641 } | 638 } |
642 | 639 |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1084 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1081 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
1085 | 1082 |
1086 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1083 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
1087 | 1084 |
1088 // Minor note: We use IDC_ for command id here while the underlying textfield | 1085 // Minor note: We use IDC_ for command id here while the underlying textfield |
1089 // is using IDS_ for all its command ids. This is because views cannot depend | 1086 // is using IDS_ for all its command ids. This is because views cannot depend |
1090 // on IDC_ for now. | 1087 // on IDC_ for now. |
1091 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1088 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
1092 IDS_EDIT_SEARCH_ENGINES); | 1089 IDS_EDIT_SEARCH_ENGINES); |
1093 } | 1090 } |
OLD | NEW |