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 13 matching lines...) Expand all Loading... | |
24 #include "chrome/grit/generated_resources.h" | 24 #include "chrome/grit/generated_resources.h" |
25 #include "components/omnibox/browser/autocomplete_input.h" | 25 #include "components/omnibox/browser/autocomplete_input.h" |
26 #include "components/omnibox/browser/autocomplete_match.h" | 26 #include "components/omnibox/browser/autocomplete_match.h" |
27 #include "components/omnibox/browser/omnibox_edit_controller.h" | 27 #include "components/omnibox/browser/omnibox_edit_controller.h" |
28 #include "components/omnibox/browser/omnibox_edit_model.h" | 28 #include "components/omnibox/browser/omnibox_edit_model.h" |
29 #include "components/omnibox/browser/omnibox_field_trial.h" | 29 #include "components/omnibox/browser/omnibox_field_trial.h" |
30 #include "components/omnibox/browser/omnibox_popup_model.h" | 30 #include "components/omnibox/browser/omnibox_popup_model.h" |
31 #include "components/strings/grit/components_strings.h" | 31 #include "components/strings/grit/components_strings.h" |
32 #include "components/toolbar/toolbar_model.h" | 32 #include "components/toolbar/toolbar_model.h" |
33 #include "content/public/browser/web_contents.h" | 33 #include "content/public/browser/web_contents.h" |
34 #include "extensions/common/constants.h" | |
35 #include "net/base/escape.h" | 34 #include "net/base/escape.h" |
36 #include "third_party/skia/include/core/SkColor.h" | 35 #include "third_party/skia/include/core/SkColor.h" |
37 #include "ui/accessibility/ax_action_data.h" | 36 #include "ui/accessibility/ax_action_data.h" |
38 #include "ui/accessibility/ax_node_data.h" | 37 #include "ui/accessibility/ax_node_data.h" |
39 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 38 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
40 #include "ui/base/dragdrop/drag_drop_types.h" | 39 #include "ui/base/dragdrop/drag_drop_types.h" |
41 #include "ui/base/dragdrop/os_exchange_data.h" | 40 #include "ui/base/dragdrop/os_exchange_data.h" |
42 #include "ui/base/ime/input_method.h" | 41 #include "ui/base/ime/input_method.h" |
43 #include "ui/base/ime/text_edit_commands.h" | 42 #include "ui/base/ime/text_edit_commands.h" |
44 #include "ui/base/ime/text_input_client.h" | 43 #include "ui/base/ime/text_input_client.h" |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
578 : gfx::DIRECTIONALITY_FROM_TEXT); | 577 : gfx::DIRECTIONALITY_FROM_TEXT); |
579 | 578 |
580 // See whether the contents are a URL with a non-empty host portion, which we | 579 // See whether the contents are a URL with a non-empty host portion, which we |
581 // should emphasize. To check for a URL, rather than using the type returned | 580 // should emphasize. To check for a URL, rather than using the type returned |
582 // by Parse(), ask the model, which will check the desired page transition for | 581 // by Parse(), ask the model, which will check the desired page transition for |
583 // this input. This can tell us whether an UNKNOWN input string is going to | 582 // this input. This can tell us whether an UNKNOWN input string is going to |
584 // be treated as a search or a navigation, and is the same method the Paste | 583 // be treated as a search or a navigation, and is the same method the Paste |
585 // And Go system uses. | 584 // And Go system uses. |
586 url::Component scheme, host; | 585 url::Component scheme, host; |
587 AutocompleteInput::ParseForEmphasizeComponents( | 586 AutocompleteInput::ParseForEmphasizeComponents( |
588 text(), ChromeAutocompleteSchemeClassifier(profile_), &scheme, &host); | 587 text(), ChromeAutocompleteSchemeClassifier(profile_), &scheme, &host); |
Peter Kasting
2017/02/24 01:53:40
Can we hoist this block and |url_scheme| to GetDee
| |
589 bool grey_out_url = text().substr(scheme.begin, scheme.len) == | 588 |
590 base::UTF8ToUTF16(extensions::kExtensionScheme); | 589 const base::string16 url_scheme = text().substr(scheme.begin, scheme.len); |
591 bool grey_base = text_is_url && (host.is_nonempty() || grey_out_url); | 590 |
592 SetColor(location_bar_view_->GetColor( | 591 // Determine if any url components should be visually deemphasized. |
593 grey_base ? LocationBarView::DEEMPHASIZED_TEXT : LocationBarView::TEXT)); | 592 DEEMPHASIZE_COMPONENTS deemphasize = |
594 if (grey_base && !grey_out_url) { | 593 GetDeemphasis(url_scheme, host.is_nonempty()); |
595 ApplyColor(location_bar_view_->GetColor(LocationBarView::TEXT), | 594 |
596 gfx::Range(host.begin, host.end())); | 595 const SkColor emphasized_color = |
597 } | 596 location_bar_view_->GetColor(LocationBarView::TEXT); |
597 SetColor(deemphasize == NOTHING ? emphasized_color | |
598 : location_bar_view_->GetColor( | |
599 LocationBarView::DEEMPHASIZED_TEXT)); | |
600 if (deemphasize == ALL_BUT_SCHEME) | |
601 ApplyColor(emphasized_color, gfx::Range(scheme.begin, scheme.end())); | |
602 else if (deemphasize == ALL_BUT_HOST) | |
603 ApplyColor(emphasized_color, gfx::Range(host.begin, host.end())); | |
598 | 604 |
599 // Emphasize the scheme for security UI display purposes (if necessary). | 605 // Emphasize the scheme for security UI display purposes (if necessary). |
600 // Note that we check CurrentTextIsURL() because if we're replacing search | 606 // Note that we check CurrentTextIsURL() because if we're replacing search |
601 // URLs with search terms, we may have a non-URL even when the user is not | 607 // URLs with search terms, we may have a non-URL even when the user is not |
602 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser | 608 // editing; and in some cases, e.g. for "site:foo.com" searches, the parser |
603 // may have incorrectly identified a qualifier as a scheme. | 609 // may have incorrectly identified a qualifier as a scheme. |
604 SetStyle(gfx::DIAGONAL_STRIKE, false); | 610 SetStyle(gfx::DIAGONAL_STRIKE, false); |
605 if (!model()->user_input_in_progress() && text_is_url && | 611 if (!model()->user_input_in_progress() && text_is_url && |
606 scheme.is_nonempty() && (security_level_ != security_state::NONE)) { | 612 scheme.is_nonempty() && (security_level_ != security_state::NONE)) { |
607 SkColor security_color = | 613 SkColor security_color = |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1065 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); | 1071 paste_position + 1, IDS_PASTE_AND_GO, IDS_PASTE_AND_GO); |
1066 | 1072 |
1067 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); | 1073 menu_contents->AddSeparator(ui::NORMAL_SEPARATOR); |
1068 | 1074 |
1069 // Minor note: We use IDC_ for command id here while the underlying textfield | 1075 // Minor note: We use IDC_ for command id here while the underlying textfield |
1070 // is using IDS_ for all its command ids. This is because views cannot depend | 1076 // is using IDS_ for all its command ids. This is because views cannot depend |
1071 // on IDC_ for now. | 1077 // on IDC_ for now. |
1072 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, | 1078 menu_contents->AddItemWithStringId(IDC_EDIT_SEARCH_ENGINES, |
1073 IDS_EDIT_SEARCH_ENGINES); | 1079 IDS_EDIT_SEARCH_ENGINES); |
1074 } | 1080 } |
OLD | NEW |