| OLD | NEW |
| 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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 DCHECK(range.IsValid()); | 578 DCHECK(range.IsValid()); |
| 579 // Only SECURE and DANGEROUS levels (pages served over HTTPS or flagged by | 579 // Only SECURE and DANGEROUS levels (pages served over HTTPS or flagged by |
| 580 // SafeBrowsing) get a special scheme color treatment. If the security level | 580 // SafeBrowsing) get a special scheme color treatment. If the security level |
| 581 // is NONE or HTTP_SHOW_WARNING, we do not override the text style previously | 581 // is NONE or HTTP_SHOW_WARNING, we do not override the text style previously |
| 582 // applied to the scheme text range by SetEmphasis(). | 582 // applied to the scheme text range by SetEmphasis(). |
| 583 if (security_level_ == security_state::NONE || | 583 if (security_level_ == security_state::NONE || |
| 584 security_level_ == security_state::HTTP_SHOW_WARNING) | 584 security_level_ == security_state::HTTP_SHOW_WARNING) |
| 585 return; | 585 return; |
| 586 ApplyColor(location_bar_view_->GetSecureTextColor(security_level_), range); | 586 ApplyColor(location_bar_view_->GetSecureTextColor(security_level_), range); |
| 587 if (security_level_ == security_state::DANGEROUS) | 587 if (security_level_ == security_state::DANGEROUS) |
| 588 ApplyStyle(gfx::DIAGONAL_STRIKE, true, range); | 588 ApplyStyle(gfx::STRIKE, true, range); |
| 589 } | 589 } |
| 590 | 590 |
| 591 void OmniboxViewViews::EmphasizeURLComponents() { | 591 void OmniboxViewViews::EmphasizeURLComponents() { |
| 592 if (!location_bar_view_) | 592 if (!location_bar_view_) |
| 593 return; | 593 return; |
| 594 | 594 |
| 595 // If the current contents is a URL, force left-to-right rendering at the | 595 // If the current contents is a URL, force left-to-right rendering at the |
| 596 // paragraph level. Right-to-left runs are still rendered RTL, but will not | 596 // paragraph level. Right-to-left runs are still rendered RTL, but will not |
| 597 // flip the whole URL around. For example (if "ABC" is Hebrew), this will | 597 // flip the whole URL around. For example (if "ABC" is Hebrew), this will |
| 598 // render "ABC.com" as "CBA.com", rather than "com.CBA". | 598 // render "ABC.com" as "CBA.com", rather than "com.CBA". |
| 599 bool text_is_url = model()->CurrentTextIsURL(); | 599 bool text_is_url = model()->CurrentTextIsURL(); |
| 600 GetRenderText()->SetDirectionalityMode(text_is_url | 600 GetRenderText()->SetDirectionalityMode(text_is_url |
| 601 ? gfx::DIRECTIONALITY_FORCE_LTR | 601 ? gfx::DIRECTIONALITY_FORCE_LTR |
| 602 : gfx::DIRECTIONALITY_FROM_TEXT); | 602 : gfx::DIRECTIONALITY_FROM_TEXT); |
| 603 SetStyle(gfx::DIAGONAL_STRIKE, false); | 603 SetStyle(gfx::STRIKE, false); |
| 604 UpdateTextStyle(text(), model()->client()->GetSchemeClassifier()); | 604 UpdateTextStyle(text(), model()->client()->GetSchemeClassifier()); |
| 605 } | 605 } |
| 606 | 606 |
| 607 bool OmniboxViewViews::IsItemForCommandIdDynamic(int command_id) const { | 607 bool OmniboxViewViews::IsItemForCommandIdDynamic(int command_id) const { |
| 608 return command_id == IDS_PASTE_AND_GO; | 608 return command_id == IDS_PASTE_AND_GO; |
| 609 } | 609 } |
| 610 | 610 |
| 611 base::string16 OmniboxViewViews::GetLabelForCommandId(int command_id) const { | 611 base::string16 OmniboxViewViews::GetLabelForCommandId(int command_id) const { |
| 612 DCHECK_EQ(IDS_PASTE_AND_GO, command_id); | 612 DCHECK_EQ(IDS_PASTE_AND_GO, command_id); |
| 613 return l10n_util::GetStringUTF16( | 613 return l10n_util::GetStringUTF16( |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1081 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1081 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
| 1082 | 1082 |
| 1083 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1083 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
| 1084 | 1084 |
| 1085 // Minor note: We use IDC_ for command id here while the underlying textfield | 1085 // Minor note: We use IDC_ for command id here while the underlying textfield |
| 1086 // is using IDS_ for all its command ids. This is because views cannot depend | 1086 // is using IDS_ for all its command ids. This is because views cannot depend |
| 1087 // on IDC_ for now. | 1087 // on IDC_ for now. |
| 1088 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1088 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
| 1089 IDS_EDIT_SEARCH_ENGINES); | 1089 IDS_EDIT_SEARCH_ENGINES); |
| 1090 } | 1090 } |
| OLD | NEW |