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

Side by Side Diff: components/omnibox/browser/omnibox_view.cc

Issue 1410293003: Vectorize LocationIconView icons (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix android Created 5 years, 1 month 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 | « components/omnibox/browser/omnibox_view.h ('k') | components/toolbar/OWNERS » ('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 // This file defines helper functions shared by the various implementations 5 // This file defines helper functions shared by the various implementations
6 // of OmniboxView. 6 // of OmniboxView.
7 7
8 #include "components/omnibox/browser/omnibox_view.h" 8 #include "components/omnibox/browser/omnibox_view.h"
9 9
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
11 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "components/omnibox/browser/autocomplete_match.h" 13 #include "components/omnibox/browser/autocomplete_match.h"
14 #include "components/omnibox/browser/omnibox_client.h" 14 #include "components/omnibox/browser/omnibox_client.h"
15 #include "components/omnibox/browser/omnibox_edit_controller.h" 15 #include "components/omnibox/browser/omnibox_edit_controller.h"
16 #include "components/toolbar/toolbar_model.h" 16 #include "components/toolbar/toolbar_model.h"
17 #include "grit/components_scaled_resources.h" 17 #include "grit/components_scaled_resources.h"
18 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
19 #include "ui/gfx/vector_icons_public.h"
19 20
20 // static 21 // static
21 base::string16 OmniboxView::StripJavascriptSchemas(const base::string16& text) { 22 base::string16 OmniboxView::StripJavascriptSchemas(const base::string16& text) {
22 const base::string16 kJsPrefix( 23 const base::string16 kJsPrefix(
23 base::ASCIIToUTF16(url::kJavaScriptScheme) + base::ASCIIToUTF16(":")); 24 base::ASCIIToUTF16(url::kJavaScriptScheme) + base::ASCIIToUTF16(":"));
24 base::string16 out(text); 25 base::string16 out(text);
25 while (base::StartsWith(out, kJsPrefix, 26 while (base::StartsWith(out, kJsPrefix,
26 base::CompareCase::INSENSITIVE_ASCII)) { 27 base::CompareCase::INSENSITIVE_ASCII)) {
27 base::TrimWhitespace(out.substr(kJsPrefix.length()), base::TRIM_LEADING, 28 base::TrimWhitespace(out.substr(kJsPrefix.length()), base::TRIM_LEADING,
28 &out); 29 &out);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 74 }
74 75
75 int OmniboxView::GetIcon() const { 76 int OmniboxView::GetIcon() const {
76 if (!IsEditingOrEmpty()) 77 if (!IsEditingOrEmpty())
77 return controller_->GetToolbarModel()->GetIcon(); 78 return controller_->GetToolbarModel()->GetIcon();
78 int id = AutocompleteMatch::TypeToIcon(model_.get() ? 79 int id = AutocompleteMatch::TypeToIcon(model_.get() ?
79 model_->CurrentTextType() : AutocompleteMatchType::URL_WHAT_YOU_TYPED); 80 model_->CurrentTextType() : AutocompleteMatchType::URL_WHAT_YOU_TYPED);
80 return (id == IDR_OMNIBOX_HTTP) ? IDR_LOCATION_BAR_HTTP : id; 81 return (id == IDR_OMNIBOX_HTTP) ? IDR_LOCATION_BAR_HTTP : id;
81 } 82 }
82 83
84 gfx::VectorIconId OmniboxView::GetVectorIcon() const {
85 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) && !defined(OS_IOS)
86 if (!IsEditingOrEmpty())
87 return controller_->GetToolbarModel()->GetVectorIcon();
88 // Reuse the dropdown icons...
89 gfx::VectorIconId id = AutocompleteMatch::TypeToVectorIcon(
90 model_ ? model_->CurrentTextType()
91 : AutocompleteMatchType::URL_WHAT_YOU_TYPED);
92 // but use a tweaked version for the HTTP icon.
93 return (id == gfx::VectorIconId::OMNIBOX_HTTP)
94 ? gfx::VectorIconId::LOCATION_BAR_HTTP
95 : id;
96 #else
97 NOTIMPLEMENTED();
98 return gfx::VectorIconId::VECTOR_ICON_NONE;
99 #endif
100 }
101
83 void OmniboxView::SetUserText(const base::string16& text) { 102 void OmniboxView::SetUserText(const base::string16& text) {
84 SetUserText(text, text, true); 103 SetUserText(text, text, true);
85 } 104 }
86 105
87 void OmniboxView::SetUserText(const base::string16& text, 106 void OmniboxView::SetUserText(const base::string16& text,
88 const base::string16& display_text, 107 const base::string16& display_text,
89 bool update_popup) { 108 bool update_popup) {
90 if (model_.get()) 109 if (model_.get())
91 model_->SetUserText(text); 110 model_->SetUserText(text);
92 SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup, 111 SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 model_.reset( 170 model_.reset(
152 new OmniboxEditModel(this, controller, client.Pass())); 171 new OmniboxEditModel(this, controller, client.Pass()));
153 } 172 }
154 } 173 }
155 174
156 void OmniboxView::TextChanged() { 175 void OmniboxView::TextChanged() {
157 EmphasizeURLComponents(); 176 EmphasizeURLComponents();
158 if (model_.get()) 177 if (model_.get())
159 model_->OnChanged(); 178 model_->OnChanged();
160 } 179 }
OLDNEW
« no previous file with comments | « components/omnibox/browser/omnibox_view.h ('k') | components/toolbar/OWNERS » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698