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 // 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" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 } | 74 } |
75 | 75 |
76 int OmniboxView::GetIcon() const { | 76 int OmniboxView::GetIcon() const { |
77 if (!IsEditingOrEmpty()) | 77 if (!IsEditingOrEmpty()) |
78 return controller_->GetToolbarModel()->GetIcon(); | 78 return controller_->GetToolbarModel()->GetIcon(); |
79 int id = AutocompleteMatch::TypeToIcon(model_.get() ? | 79 int id = AutocompleteMatch::TypeToIcon(model_.get() ? |
80 model_->CurrentTextType() : AutocompleteMatchType::URL_WHAT_YOU_TYPED); | 80 model_->CurrentTextType() : AutocompleteMatchType::URL_WHAT_YOU_TYPED); |
81 return (id == IDR_OMNIBOX_HTTP) ? IDR_LOCATION_BAR_HTTP : id; | 81 return (id == IDR_OMNIBOX_HTTP) ? IDR_LOCATION_BAR_HTTP : id; |
82 } | 82 } |
83 | 83 |
84 gfx::VectorIconId OmniboxView::GetVectorIcon() const { | 84 gfx::VectorIconId OmniboxView::GetVectorIcon(bool invert) const { |
85 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) && !defined(OS_IOS) | 85 #if !defined(OS_ANDROID) && !defined(OS_MACOSX) && !defined(OS_IOS) |
86 if (!IsEditingOrEmpty()) | 86 if (!IsEditingOrEmpty()) { |
87 return controller_->GetToolbarModel()->GetVectorIcon(); | 87 gfx::VectorIconId id = controller_->GetToolbarModel()->GetVectorIcon(); |
88 if (!invert) | |
89 return id; | |
90 | |
91 switch (id) { | |
92 case gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID: | |
93 return gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID_INVERT; | |
94 case gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID: | |
95 return gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID_INVERT; | |
96 | |
97 default: | |
98 return id; | |
99 } | |
Peter Kasting
2015/11/17 21:27:03
Nit: Shorter:
gfx::VectorIconId id = controll
| |
100 } | |
88 // Reuse the dropdown icons... | 101 // Reuse the dropdown icons... |
89 gfx::VectorIconId id = AutocompleteMatch::TypeToVectorIcon( | 102 gfx::VectorIconId id = AutocompleteMatch::TypeToVectorIcon( |
90 model_ ? model_->CurrentTextType() | 103 model_ ? model_->CurrentTextType() |
91 : AutocompleteMatchType::URL_WHAT_YOU_TYPED); | 104 : AutocompleteMatchType::URL_WHAT_YOU_TYPED); |
92 // but use a tweaked version for the HTTP icon. | 105 // but use a tweaked version for the HTTP icon. |
93 return (id == gfx::VectorIconId::OMNIBOX_HTTP) | 106 return (id == gfx::VectorIconId::OMNIBOX_HTTP) |
94 ? gfx::VectorIconId::LOCATION_BAR_HTTP | 107 ? gfx::VectorIconId::LOCATION_BAR_HTTP |
95 : id; | 108 : id; |
96 #else | 109 #else |
97 NOTIMPLEMENTED(); | 110 NOTIMPLEMENTED(); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 model_.reset( | 183 model_.reset( |
171 new OmniboxEditModel(this, controller, client.Pass())); | 184 new OmniboxEditModel(this, controller, client.Pass())); |
172 } | 185 } |
173 } | 186 } |
174 | 187 |
175 void OmniboxView::TextChanged() { | 188 void OmniboxView::TextChanged() { |
176 EmphasizeURLComponents(); | 189 EmphasizeURLComponents(); |
177 if (model_.get()) | 190 if (model_.get()) |
178 model_->OnChanged(); | 191 model_->OnChanged(); |
179 } | 192 } |
OLD | NEW |