Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: chrome/browser/ui/views/omnibox/omnibox_view_views.cc

Issue 1138473003: Revert of Move SecurityLevel into a class of its own (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 const char OmniboxViewViews::kViewClassName[] = "OmniboxViewViews"; 130 const char OmniboxViewViews::kViewClassName[] = "OmniboxViewViews";
131 131
132 OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller, 132 OmniboxViewViews::OmniboxViewViews(OmniboxEditController* controller,
133 Profile* profile, 133 Profile* profile,
134 CommandUpdater* command_updater, 134 CommandUpdater* command_updater,
135 bool popup_window_mode, 135 bool popup_window_mode,
136 LocationBarView* location_bar, 136 LocationBarView* location_bar,
137 const gfx::FontList& font_list) 137 const gfx::FontList& font_list)
138 : OmniboxView(profile, controller, command_updater), 138 : OmniboxView(profile, controller, command_updater),
139 popup_window_mode_(popup_window_mode), 139 popup_window_mode_(popup_window_mode),
140 security_level_(ConnectionSecurityHelper::NONE), 140 security_level_(ToolbarModel::NONE),
141 saved_selection_for_focus_change_(gfx::Range::InvalidRange()), 141 saved_selection_for_focus_change_(gfx::Range::InvalidRange()),
142 ime_composing_before_change_(false), 142 ime_composing_before_change_(false),
143 delete_at_end_pressed_(false), 143 delete_at_end_pressed_(false),
144 location_bar_view_(location_bar), 144 location_bar_view_(location_bar),
145 ime_candidate_window_open_(false), 145 ime_candidate_window_open_(false),
146 select_all_on_mouse_release_(false), 146 select_all_on_mouse_release_(false),
147 select_all_on_gesture_tap_(false), 147 select_all_on_gesture_tap_(false),
148 weak_ptr_factory_(this) { 148 weak_ptr_factory_(this) {
149 SetBorder(views::Border::NullBorder()); 149 SetBorder(views::Border::NullBorder());
150 set_id(VIEW_ID_OMNIBOX); 150 set_id(VIEW_ID_OMNIBOX);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 216
217 // TODO(msw|oshima): Consider saving/restoring edit history. 217 // TODO(msw|oshima): Consider saving/restoring edit history.
218 ClearEditHistory(); 218 ClearEditHistory();
219 } 219 }
220 220
221 void OmniboxViewViews::ResetTabState(content::WebContents* web_contents) { 221 void OmniboxViewViews::ResetTabState(content::WebContents* web_contents) {
222 web_contents->SetUserData(OmniboxState::kKey, nullptr); 222 web_contents->SetUserData(OmniboxState::kKey, nullptr);
223 } 223 }
224 224
225 void OmniboxViewViews::Update() { 225 void OmniboxViewViews::Update() {
226 const ConnectionSecurityHelper::SecurityLevel old_security_level = 226 const ToolbarModel::SecurityLevel old_security_level = security_level_;
227 security_level_;
228 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); 227 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false);
229 if (model()->UpdatePermanentText()) { 228 if (model()->UpdatePermanentText()) {
230 // Something visibly changed. Re-enable URL replacement. 229 // Something visibly changed. Re-enable URL replacement.
231 controller()->GetToolbarModel()->set_url_replacement_enabled(true); 230 controller()->GetToolbarModel()->set_url_replacement_enabled(true);
232 model()->UpdatePermanentText(); 231 model()->UpdatePermanentText();
233 232
234 // Select all the new text if the user had all the old text selected, or if 233 // Select all the new text if the user had all the old text selected, or if
235 // there was no previous text (for new tab page URL replacement extensions). 234 // there was no previous text (for new tab page URL replacement extensions).
236 // This makes one particular case better: the user clicks in the box to 235 // This makes one particular case better: the user clicks in the box to
237 // change it right before the permanent URL is changed. Since the new URL 236 // change it right before the permanent URL is changed. Since the new URL
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 const int kMinCharacters = 10; 318 const int kMinCharacters = 10;
320 return gfx::Size( 319 return gfx::Size(
321 GetFontList().GetExpectedTextWidth(kMinCharacters) + GetInsets().width(), 320 GetFontList().GetExpectedTextWidth(kMinCharacters) + GetInsets().width(),
322 GetPreferredSize().height()); 321 GetPreferredSize().height());
323 } 322 }
324 323
325 void OmniboxViewViews::OnNativeThemeChanged(const ui::NativeTheme* theme) { 324 void OmniboxViewViews::OnNativeThemeChanged(const ui::NativeTheme* theme) {
326 views::Textfield::OnNativeThemeChanged(theme); 325 views::Textfield::OnNativeThemeChanged(theme);
327 if (location_bar_view_) { 326 if (location_bar_view_) {
328 SetBackgroundColor(location_bar_view_->GetColor( 327 SetBackgroundColor(location_bar_view_->GetColor(
329 ConnectionSecurityHelper::NONE, LocationBarView::BACKGROUND)); 328 ToolbarModel::NONE, LocationBarView::BACKGROUND));
330 } 329 }
331 EmphasizeURLComponents(); 330 EmphasizeURLComponents();
332 } 331 }
333 332
334 void OmniboxViewViews::OnPaint(gfx::Canvas* canvas) { 333 void OmniboxViewViews::OnPaint(gfx::Canvas* canvas) {
335 Textfield::OnPaint(canvas); 334 Textfield::OnPaint(canvas);
336 if (!insert_char_time_.is_null()) { 335 if (!insert_char_time_.is_null()) {
337 UMA_HISTOGRAM_TIMES("Omnibox.CharTypedToRepaintLatency", 336 UMA_HISTOGRAM_TIMES("Omnibox.CharTypedToRepaintLatency",
338 base::TimeTicks::Now() - insert_char_time_); 337 base::TimeTicks::Now() - insert_char_time_);
339 insert_char_time_ = base::TimeTicks(); 338 insert_char_time_ = base::TimeTicks();
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 gfx::Range(host.begin, host.end())); 624 gfx::Range(host.begin, host.end()));
626 } 625 }
627 626
628 // Emphasize the scheme for security UI display purposes (if necessary). 627 // Emphasize the scheme for security UI display purposes (if necessary).
629 // Note that we check CurrentTextIsURL() because if we're replacing search 628 // Note that we check CurrentTextIsURL() because if we're replacing search
630 // URLs with search terms, we may have a non-URL even when the user is not 629 // URLs with search terms, we may have a non-URL even when the user is not
631 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser 630 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser
632 // may have incorrectly identified a qualifier as a scheme. 631 // may have incorrectly identified a qualifier as a scheme.
633 SetStyle(gfx::DIAGONAL_STRIKE, false); 632 SetStyle(gfx::DIAGONAL_STRIKE, false);
634 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && 633 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&
635 scheme.is_nonempty() && 634 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) {
636 (security_level_ != ConnectionSecurityHelper::NONE)) {
637 SkColor security_color = location_bar_view_->GetColor( 635 SkColor security_color = location_bar_view_->GetColor(
638 security_level_, LocationBarView::SECURITY_TEXT); 636 security_level_, LocationBarView::SECURITY_TEXT);
639 const bool strike = 637 const bool strike = (security_level_ == ToolbarModel::SECURITY_ERROR);
640 (security_level_ == ConnectionSecurityHelper::SECURITY_ERROR);
641 const gfx::Range scheme_range(scheme.begin, scheme.end()); 638 const gfx::Range scheme_range(scheme.begin, scheme.end());
642 ApplyColor(security_color, scheme_range); 639 ApplyColor(security_color, scheme_range);
643 ApplyStyle(gfx::DIAGONAL_STRIKE, strike, scheme_range); 640 ApplyStyle(gfx::DIAGONAL_STRIKE, strike, scheme_range);
644 } 641 }
645 } 642 }
646 643
647 bool OmniboxViewViews::OnKeyReleased(const ui::KeyEvent& event) { 644 bool OmniboxViewViews::OnKeyReleased(const ui::KeyEvent& event) {
648 // The omnibox contents may change while the control key is pressed. 645 // The omnibox contents may change while the control key is pressed.
649 if (event.key_code() == ui::VKEY_CONTROL) 646 if (event.key_code() == ui::VKEY_CONTROL)
650 model()->OnControlKeyChanged(false); 647 model()->OnControlKeyChanged(false);
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 menu_contents->InsertItemWithStringIdAt( 1053 menu_contents->InsertItemWithStringIdAt(
1057 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); 1054 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL);
1058 } 1055 }
1059 1056
1060 // Minor note: We use IDC_ for command id here while the underlying textfield 1057 // Minor note: We use IDC_ for command id here while the underlying textfield
1061 // is using IDS_ for all its command ids. This is because views cannot depend 1058 // is using IDS_ for all its command ids. This is because views cannot depend
1062 // on IDC_ for now. 1059 // on IDC_ for now.
1063 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1060 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1064 IDS_EDIT_SEARCH_ENGINES); 1061 IDS_EDIT_SEARCH_ENGINES);
1065 } 1062 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/omnibox/omnibox_view_views.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698