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

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: owners,remove assets Created 5 years, 2 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 (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 gfx::VectorIconId id = AutocompleteMatch::TypeToVectorIcon(
89 model_.get() ? model_->CurrentTextType()
Peter Kasting 2015/10/21 19:45:47 Nit: .get() unneeded
Evan Stade 2015/10/21 23:20:01 Done.
90 : AutocompleteMatchType::URL_WHAT_YOU_TYPED);
91 return (id == gfx::VectorIconId::OMNIBOX_HTTP)
92 ? gfx::VectorIconId::LOCATION_BAR_HTTP
93 : id;
Peter Kasting 2015/10/21 19:45:47 Honestly I'm not actually clear on what this last
Evan Stade 2015/10/21 23:20:01 done
94 #else
95 NOTIMPLEMENTED();
96 return gfx::VectorIconId::VECTOR_ICON_NONE;
97 #endif
98 }
99
83 void OmniboxView::SetUserText(const base::string16& text) { 100 void OmniboxView::SetUserText(const base::string16& text) {
84 SetUserText(text, text, true); 101 SetUserText(text, text, true);
85 } 102 }
86 103
87 void OmniboxView::SetUserText(const base::string16& text, 104 void OmniboxView::SetUserText(const base::string16& text,
88 const base::string16& display_text, 105 const base::string16& display_text,
89 bool update_popup) { 106 bool update_popup) {
90 if (model_.get()) 107 if (model_.get())
91 model_->SetUserText(text); 108 model_->SetUserText(text);
92 SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup, 109 SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 model_.reset( 168 model_.reset(
152 new OmniboxEditModel(this, controller, client.Pass())); 169 new OmniboxEditModel(this, controller, client.Pass()));
153 } 170 }
154 } 171 }
155 172
156 void OmniboxView::TextChanged() { 173 void OmniboxView::TextChanged() {
157 EmphasizeURLComponents(); 174 EmphasizeURLComponents();
158 if (model_.get()) 175 if (model_.get())
159 model_->OnChanged(); 176 model_->OnChanged();
160 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698