OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/autocomplete/autocomplete_edit_view_win.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" |
6 | 6 |
7 #include <locale> | 7 #include <locale> |
8 | 8 |
9 #include "app/gfx/canvas.h" | 9 #include "app/gfx/canvas.h" |
10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1999 // be treated as a search or a navigation, and is the same method the Paste | 1999 // be treated as a search or a navigation, and is the same method the Paste |
2000 // And Go system uses. | 2000 // And Go system uses. |
2001 url_parse::Component scheme, host; | 2001 url_parse::Component scheme, host; |
2002 AutocompleteInput::ParseForEmphasizeComponents( | 2002 AutocompleteInput::ParseForEmphasizeComponents( |
2003 GetText(), model_->GetDesiredTLD(), &scheme, &host); | 2003 GetText(), model_->GetDesiredTLD(), &scheme, &host); |
2004 const bool emphasize = model_->CurrentTextIsURL() && (host.len > 0); | 2004 const bool emphasize = model_->CurrentTextIsURL() && (host.len > 0); |
2005 | 2005 |
2006 // Set the baseline emphasis. | 2006 // Set the baseline emphasis. |
2007 CHARFORMAT cf = {0}; | 2007 CHARFORMAT cf = {0}; |
2008 cf.dwMask = CFM_COLOR; | 2008 cf.dwMask = CFM_COLOR; |
2009 cf.dwEffects = 0; | |
2010 const bool is_secure = (scheme_security_level_ == ToolbarModel::SECURE); | 2009 const bool is_secure = (scheme_security_level_ == ToolbarModel::SECURE); |
2011 // If we're going to emphasize parts of the text, then the baseline state | 2010 // If we're going to emphasize parts of the text, then the baseline state |
2012 // should be "de-emphasized". If not, then everything should be rendered in | 2011 // should be "de-emphasized". If not, then everything should be rendered in |
2013 // the standard text color. | 2012 // the standard text color. |
2014 cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor(is_secure, | 2013 cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor(is_secure, |
2015 emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT)); | 2014 emphasize ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT)); |
2016 SelectAll(false); | 2015 SetDefaultCharFormat(cf); |
2017 SetSelectionCharFormat(cf); | |
2018 | 2016 |
2019 if (emphasize) { | 2017 if (emphasize) { |
2020 // We've found a host name, give it more emphasis. | 2018 // We've found a host name, give it more emphasis. |
2021 cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor( | 2019 cf.crTextColor = skia::SkColorToCOLORREF(LocationBarView::GetColor( |
2022 is_secure, LocationBarView::TEXT)); | 2020 is_secure, LocationBarView::TEXT)); |
2023 SetSelection(host.begin, host.end()); | 2021 SetSelection(host.begin, host.end()); |
2024 SetSelectionCharFormat(cf); | 2022 SetSelectionCharFormat(cf); |
2025 } | 2023 } |
2026 | 2024 |
2027 // Emphasize the scheme for security UI display purposes (if necessary). | 2025 // Emphasize the scheme for security UI display purposes (if necessary). |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2375 context_menu_contents_->AddItemWithStringId(IDS_PASTE_AND_GO, | 2373 context_menu_contents_->AddItemWithStringId(IDS_PASTE_AND_GO, |
2376 IDS_PASTE_AND_GO); | 2374 IDS_PASTE_AND_GO); |
2377 context_menu_contents_->AddSeparator(); | 2375 context_menu_contents_->AddSeparator(); |
2378 context_menu_contents_->AddItemWithStringId(IDS_SELECT_ALL, IDS_SELECT_ALL); | 2376 context_menu_contents_->AddItemWithStringId(IDS_SELECT_ALL, IDS_SELECT_ALL); |
2379 context_menu_contents_->AddSeparator(); | 2377 context_menu_contents_->AddSeparator(); |
2380 context_menu_contents_->AddItemWithStringId(IDS_EDIT_SEARCH_ENGINES, | 2378 context_menu_contents_->AddItemWithStringId(IDS_EDIT_SEARCH_ENGINES, |
2381 IDS_EDIT_SEARCH_ENGINES); | 2379 IDS_EDIT_SEARCH_ENGINES); |
2382 } | 2380 } |
2383 context_menu_.reset(new views::Menu2(context_menu_contents_.get())); | 2381 context_menu_.reset(new views::Menu2(context_menu_contents_.get())); |
2384 } | 2382 } |
OLD | NEW |