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 <utility> | 10 #include <utility> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 } | 79 } |
80 | 80 |
81 int OmniboxView::GetIcon() const { | 81 int OmniboxView::GetIcon() const { |
82 if (!IsEditingOrEmpty()) | 82 if (!IsEditingOrEmpty()) |
83 return controller_->GetToolbarModel()->GetIcon(); | 83 return controller_->GetToolbarModel()->GetIcon(); |
84 int id = AutocompleteMatch::TypeToIcon(model_.get() ? | 84 int id = AutocompleteMatch::TypeToIcon(model_.get() ? |
85 model_->CurrentTextType() : AutocompleteMatchType::URL_WHAT_YOU_TYPED); | 85 model_->CurrentTextType() : AutocompleteMatchType::URL_WHAT_YOU_TYPED); |
86 return (id == IDR_OMNIBOX_HTTP) ? IDR_LOCATION_BAR_HTTP : id; | 86 return (id == IDR_OMNIBOX_HTTP) ? IDR_LOCATION_BAR_HTTP : id; |
87 } | 87 } |
88 | 88 |
89 gfx::VectorIconId OmniboxView::GetVectorIcon(bool invert) const { | 89 gfx::VectorIconId OmniboxView::GetVectorIcon() const { |
90 #if !defined(OS_ANDROID) && !defined(OS_IOS) | 90 #if !defined(OS_ANDROID) && !defined(OS_IOS) |
91 if (!IsEditingOrEmpty()) { | 91 if (!IsEditingOrEmpty()) |
92 gfx::VectorIconId id = controller_->GetToolbarModel()->GetVectorIcon(); | 92 return controller_->GetToolbarModel()->GetVectorIcon(); |
93 if (invert) { | 93 |
94 if (id == gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID) | |
95 return gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID_INVERT; | |
96 if (id == gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID) | |
97 return gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID_INVERT; | |
98 } | |
99 return id; | |
100 } | |
101 // Reuse the dropdown icons... | 94 // Reuse the dropdown icons... |
102 gfx::VectorIconId id = AutocompleteMatch::TypeToVectorIcon( | 95 gfx::VectorIconId id = AutocompleteMatch::TypeToVectorIcon( |
103 model_ ? model_->CurrentTextType() | 96 model_ ? model_->CurrentTextType() |
104 : AutocompleteMatchType::URL_WHAT_YOU_TYPED); | 97 : AutocompleteMatchType::URL_WHAT_YOU_TYPED); |
105 // but use a tweaked version for the HTTP icon. | 98 // but use a different version for the HTTP icon. |
106 return (id == gfx::VectorIconId::OMNIBOX_HTTP) | 99 return (id == gfx::VectorIconId::OMNIBOX_HTTP) |
107 ? gfx::VectorIconId::LOCATION_BAR_HTTP | 100 ? gfx::VectorIconId::LOCATION_BAR_HTTP |
108 : id; | 101 : id; |
109 #else | 102 #else |
110 NOTIMPLEMENTED(); | 103 NOTIMPLEMENTED(); |
111 return gfx::VectorIconId::VECTOR_ICON_NONE; | 104 return gfx::VectorIconId::VECTOR_ICON_NONE; |
112 #endif | 105 #endif |
113 } | 106 } |
114 | 107 |
115 void OmniboxView::SetUserText(const base::string16& text) { | 108 void OmniboxView::SetUserText(const base::string16& text) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 if (client) { | 173 if (client) { |
181 model_.reset(new OmniboxEditModel(this, controller, std::move(client))); | 174 model_.reset(new OmniboxEditModel(this, controller, std::move(client))); |
182 } | 175 } |
183 } | 176 } |
184 | 177 |
185 void OmniboxView::TextChanged() { | 178 void OmniboxView::TextChanged() { |
186 EmphasizeURLComponents(); | 179 EmphasizeURLComponents(); |
187 if (model_.get()) | 180 if (model_.get()) |
188 model_->OnChanged(); | 181 model_->OnChanged(); |
189 } | 182 } |
OLD | NEW |