| 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 if (id == gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID) |
| 90 return gfx::VectorIconId::LOCATION_BAR_HTTPS_VALID_INVERT; |
| 91 if (id == gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID) |
| 92 return gfx::VectorIconId::LOCATION_BAR_HTTPS_INVALID_INVERT; |
| 93 } |
| 94 return id; |
| 95 } |
| 88 // Reuse the dropdown icons... | 96 // Reuse the dropdown icons... |
| 89 gfx::VectorIconId id = AutocompleteMatch::TypeToVectorIcon( | 97 gfx::VectorIconId id = AutocompleteMatch::TypeToVectorIcon( |
| 90 model_ ? model_->CurrentTextType() | 98 model_ ? model_->CurrentTextType() |
| 91 : AutocompleteMatchType::URL_WHAT_YOU_TYPED); | 99 : AutocompleteMatchType::URL_WHAT_YOU_TYPED); |
| 92 // but use a tweaked version for the HTTP icon. | 100 // but use a tweaked version for the HTTP icon. |
| 93 return (id == gfx::VectorIconId::OMNIBOX_HTTP) | 101 return (id == gfx::VectorIconId::OMNIBOX_HTTP) |
| 94 ? gfx::VectorIconId::LOCATION_BAR_HTTP | 102 ? gfx::VectorIconId::LOCATION_BAR_HTTP |
| 95 : id; | 103 : id; |
| 96 #else | 104 #else |
| 97 NOTIMPLEMENTED(); | 105 NOTIMPLEMENTED(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 model_.reset( | 178 model_.reset( |
| 171 new OmniboxEditModel(this, controller, client.Pass())); | 179 new OmniboxEditModel(this, controller, client.Pass())); |
| 172 } | 180 } |
| 173 } | 181 } |
| 174 | 182 |
| 175 void OmniboxView::TextChanged() { | 183 void OmniboxView::TextChanged() { |
| 176 EmphasizeURLComponents(); | 184 EmphasizeURLComponents(); |
| 177 if (model_.get()) | 185 if (model_.get()) |
| 178 model_->OnChanged(); | 186 model_->OnChanged(); |
| 179 } | 187 } |
| OLD | NEW |