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

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

Issue 12463042: Shows chrome-extension urls and greys out the whole url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Not hacky anymore Created 7 years, 9 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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_win.h" 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <locale> 8 #include <locale>
9 #include <string> 9 #include <string>
10 10
(...skipping 2445 matching lines...) Expand 10 before | Expand all | Expand 10 after
2456 // Save the selection. 2456 // Save the selection.
2457 CHARRANGE saved_sel; 2457 CHARRANGE saved_sel;
2458 GetSelection(saved_sel); 2458 GetSelection(saved_sel);
2459 2459
2460 // See whether the contents are a URL with a non-empty host portion, which we 2460 // See whether the contents are a URL with a non-empty host portion, which we
2461 // should emphasize. To check for a URL, rather than using the type returned 2461 // should emphasize. To check for a URL, rather than using the type returned
2462 // by Parse(), ask the model, which will check the desired page transition for 2462 // by Parse(), ask the model, which will check the desired page transition for
2463 // this input. This can tell us whether an UNKNOWN input string is going to 2463 // this input. This can tell us whether an UNKNOWN input string is going to
2464 // be treated as a search or a navigation, and is the same method the Paste 2464 // be treated as a search or a navigation, and is the same method the Paste
2465 // And Go system uses. 2465 // And Go system uses.
2466 url_parse::Component scheme, host; 2466 url_parse::Component scheme, host;
Devlin 2013/03/27 15:59:52 Each declaration on its own line.
Patrick Riordan 2013/03/27 19:43:28 Done.
2467 AutocompleteInput::ParseForEmphasizeComponents(GetText(), &scheme, &host); 2467 AutocompleteInput::ParseForEmphasizeComponents(GetText(), &scheme, &host);
2468 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0); 2468 const bool emphasize = model()->CurrentTextIsURL() && (host.len > 0);
2469 2469
2470 // Set the baseline emphasis. 2470 // Set the baseline emphasis.
2471 CHARFORMAT cf = {0}; 2471 CHARFORMAT cf = {0};
2472 cf.dwMask = CFM_COLOR; 2472 cf.dwMask = CFM_COLOR;
2473 // If we're going to emphasize parts of the text, then the baseline state 2473 // If we're going to emphasize parts of the text, then the baseline state
2474 // should be "de-emphasized". If not, then everything should be rendered in 2474 // should be "de-emphasized". If not, then everything should be rendered in
2475 // the standard text color. 2475 // the standard text color.
2476 cf.crTextColor = skia::SkColorToCOLORREF(parent_view_->GetColor( 2476 cf.crTextColor = skia::SkColorToCOLORREF(parent_view_->GetColor(
2477 security_level_, 2477 security_level_,
2478 emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT)); 2478 emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT));
2479 // NOTE: Don't use SetDefaultCharFormat() instead of the below; that sets the 2479 // NOTE: Don't use SetDefaultCharFormat() instead of the below; that sets the
2480 // format that will get applied to text added in the future, not to text 2480 // format that will get applied to text added in the future, not to text
2481 // already in the edit. 2481 // already in the edit.
2482 SelectAll(false); 2482 SelectAll(false);
2483 SetSelectionCharFormat(cf); 2483 SetSelectionCharFormat(cf);
2484 2484
2485 if (emphasize) { 2485 if (emphasize && !toolbar_model()->ShouldNotEmphasizeHost()) {
2486 // We've found a host name, give it more emphasis. 2486 // We've found a host name, give it more emphasis.
Devlin 2013/03/27 15:59:52 Update comment to mention that it's a host to whic
Patrick Riordan 2013/03/27 19:43:28 Done.
2487 cf.crTextColor = skia::SkColorToCOLORREF(parent_view_->GetColor( 2487 cf.crTextColor = skia::SkColorToCOLORREF(parent_view_->GetColor(
2488 security_level_, LocationBarView::TEXT)); 2488 security_level_, LocationBarView::TEXT));
2489 SetSelection(host.begin, host.end()); 2489 SetSelection(host.begin, host.end());
2490 SetSelectionCharFormat(cf); 2490 SetSelectionCharFormat(cf);
2491 } 2491 }
2492 2492
2493 // Emphasize the scheme for security UI display purposes (if necessary). 2493 // Emphasize the scheme for security UI display purposes (if necessary).
2494 insecure_scheme_component_.reset(); 2494 insecure_scheme_component_.reset();
2495 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() && 2495 if (!model()->user_input_in_progress() && model()->CurrentTextIsURL() &&
2496 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) { 2496 scheme.is_nonempty() && (security_level_ != ToolbarModel::NONE)) {
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2846 return (rect.left - client_rect.left) + (client_rect.right - rect.right); 2846 return (rect.left - client_rect.left) + (client_rect.right - rect.right);
2847 } 2847 }
2848 2848
2849 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const { 2849 int OmniboxViewWin::WidthNeededToDisplay(const string16& text) const {
2850 // Use font_.GetStringWidth() instead of 2850 // Use font_.GetStringWidth() instead of
2851 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is 2851 // PosFromChar(location_entry_->GetTextLength()) because PosFromChar() is
2852 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout, 2852 // apparently buggy. In both LTR UI and RTL UI with left-to-right layout,
2853 // PosFromChar(i) might return 0 when i is greater than 1. 2853 // PosFromChar(i) might return 0 when i is greater than 1.
2854 return font_.GetStringWidth(text) + GetHorizontalMargin(); 2854 return font_.GetStringWidth(text) + GetHorizontalMargin();
2855 } 2855 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698