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

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

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