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

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

Issue 1123943002: Move SecurityLevel into a class of its own (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: register in chrome_jni_registrar 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_(ToolbarModel::NONE), 140 security_level_(ConnectionSecurityHelper::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 ToolbarModel::SecurityLevel old_security_level = security_level_; 226 const ConnectionSecurityHelper::SecurityLevel old_security_level =
227 security_level_;
227 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false); 228 security_level_ = controller()->GetToolbarModel()->GetSecurityLevel(false);
228 if (model()->UpdatePermanentText()) { 229 if (model()->UpdatePermanentText()) {
229 // Something visibly changed. Re-enable URL replacement. 230 // Something visibly changed. Re-enable URL replacement.
230 controller()->GetToolbarModel()->set_url_replacement_enabled(true); 231 controller()->GetToolbarModel()->set_url_replacement_enabled(true);
231 model()->UpdatePermanentText(); 232 model()->UpdatePermanentText();
232 233
233 // Select all the new text if the user had all the old text selected, or if 234 // 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). 235 // 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 236 // 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 237 // 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; 319 const int kMinCharacters = 10;
319 return gfx::Size( 320 return gfx::Size(
320 GetFontList().GetExpectedTextWidth(kMinCharacters) + GetInsets().width(), 321 GetFontList().GetExpectedTextWidth(kMinCharacters) + GetInsets().width(),
321 GetPreferredSize().height()); 322 GetPreferredSize().height());
322 } 323 }
323 324
324 void OmniboxViewViews::OnNativeThemeChanged(const ui::NativeTheme* theme) { 325 void OmniboxViewViews::OnNativeThemeChanged(const ui::NativeTheme* theme) {
325 views::Textfield::OnNativeThemeChanged(theme); 326 views::Textfield::OnNativeThemeChanged(theme);
326 if (location_bar_view_) { 327 if (location_bar_view_) {
327 SetBackgroundColor(location_bar_view_->GetColor( 328 SetBackgroundColor(location_bar_view_->GetColor(
328 ToolbarModel::NONE, LocationBarView::BACKGROUND)); 329 ConnectionSecurityHelper::NONE, LocationBarView::BACKGROUND));
329 } 330 }
330 EmphasizeURLComponents(); 331 EmphasizeURLComponents();
331 } 332 }
332 333
333 void OmniboxViewViews::OnPaint(gfx::Canvas* canvas) { 334 void OmniboxViewViews::OnPaint(gfx::Canvas* canvas) {
334 Textfield::OnPaint(canvas); 335 Textfield::OnPaint(canvas);
335 if (!insert_char_time_.is_null()) { 336 if (!insert_char_time_.is_null()) {
336 UMA_HISTOGRAM_TIMES("Omnibox.CharTypedToRepaintLatency", 337 UMA_HISTOGRAM_TIMES("Omnibox.CharTypedToRepaintLatency",
337 base::TimeTicks::Now() - insert_char_time_); 338 base::TimeTicks::Now() - insert_char_time_);
338 insert_char_time_ = base::TimeTicks(); 339 insert_char_time_ = base::TimeTicks();
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 gfx::Range(host.begin, host.end())); 625 gfx::Range(host.begin, host.end()));
625 } 626 }
626 627
627 // Emphasize the scheme for security UI display purposes (if necessary). 628 // Emphasize the scheme for security UI display purposes (if necessary).
628 // Note that we check CurrentTextIsURL() because if we're replacing search 629 // 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 630 // 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 631 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser
631 // may have incorrectly identified a qualifier as a scheme. 632 // may have incorrectly identified a qualifier as a scheme.
632 SetStyle(gfx::DIAGONAL_STRIKE, false); 633 SetStyle(gfx::DIAGONAL_STRIKE, false);
633 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && 634 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&
634 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) { 635 scheme.is_nonempty() &&
636 (security_level_ != ConnectionSecurityHelper::NONE)) {
635 SkColor security_color = location_bar_view_->GetColor( 637 SkColor security_color = location_bar_view_->GetColor(
636 security_level_, LocationBarView::SECURITY_TEXT); 638 security_level_, LocationBarView::SECURITY_TEXT);
637 const bool strike = (security_level_ == ToolbarModel::SECURITY_ERROR); 639 const bool strike =
640 (security_level_ == ConnectionSecurityHelper::SECURITY_ERROR);
638 const gfx::Range scheme_range(scheme.begin, scheme.end()); 641 const gfx::Range scheme_range(scheme.begin, scheme.end());
639 ApplyColor(security_color, scheme_range); 642 ApplyColor(security_color, scheme_range);
640 ApplyStyle(gfx::DIAGONAL_STRIKE, strike, scheme_range); 643 ApplyStyle(gfx::DIAGONAL_STRIKE, strike, scheme_range);
641 } 644 }
642 } 645 }
643 646
644 bool OmniboxViewViews::OnKeyReleased(const ui::KeyEvent& event) { 647 bool OmniboxViewViews::OnKeyReleased(const ui::KeyEvent& event) {
645 // The omnibox contents may change while the control key is pressed. 648 // The omnibox contents may change while the control key is pressed.
646 if (event.key_code() == ui::VKEY_CONTROL) 649 if (event.key_code() == ui::VKEY_CONTROL)
647 model()->OnControlKeyChanged(false); 650 model()->OnControlKeyChanged(false);
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 menu_contents->InsertItemWithStringIdAt( 1056 menu_contents->InsertItemWithStringIdAt(
1054 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL); 1057 select_all_position + 1, IDS_SHOW_URL, IDS_SHOW_URL);
1055 } 1058 }
1056 1059
1057 // Minor note: We use IDC_ for command id here while the underlying textfield 1060 // Minor note: We use IDC_ for command id here while the underlying textfield
1058 // is using IDS_ for all its command ids. This is because views cannot depend 1061 // is using IDS_ for all its command ids. This is because views cannot depend
1059 // on IDC_ for now. 1062 // on IDC_ for now.
1060 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, 1063 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES,
1061 IDS_EDIT_SEARCH_ENGINES); 1064 IDS_EDIT_SEARCH_ENGINES);
1062 } 1065 }
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