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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 match, disposition, alternate_nav_url, pasted_text, selected_line); | 72 match, disposition, alternate_nav_url, pasted_text, selected_line); |
73 // WARNING: |match| may refer to a deleted object at this point! | 73 // WARNING: |match| may refer to a deleted object at this point! |
74 OnMatchOpened(match_type); | 74 OnMatchOpened(match_type); |
75 } | 75 } |
76 | 76 |
77 bool OmniboxView::IsEditingOrEmpty() const { | 77 bool OmniboxView::IsEditingOrEmpty() const { |
78 return (model_.get() && model_->user_input_in_progress()) || | 78 return (model_.get() && model_->user_input_in_progress()) || |
79 (GetOmniboxTextLength() == 0); | 79 (GetOmniboxTextLength() == 0); |
80 } | 80 } |
81 | 81 |
82 int OmniboxView::GetIcon() const { | |
83 if (!IsEditingOrEmpty()) | |
84 return controller_->GetToolbarModel()->GetIcon(); | |
85 int id = AutocompleteMatch::TypeToIcon(model_.get() ? | |
86 model_->CurrentTextType() : AutocompleteMatchType::URL_WHAT_YOU_TYPED); | |
87 return (id == IDR_OMNIBOX_HTTP) ? IDR_LOCATION_BAR_HTTP : id; | |
88 } | |
89 | |
90 gfx::VectorIconId OmniboxView::GetVectorIcon() const { | 82 gfx::VectorIconId OmniboxView::GetVectorIcon() const { |
91 #if !defined(OS_ANDROID) && !defined(OS_IOS) | |
92 if (!IsEditingOrEmpty()) | 83 if (!IsEditingOrEmpty()) |
93 return controller_->GetToolbarModel()->GetVectorIcon(); | 84 return controller_->GetToolbarModel()->GetVectorIcon(); |
94 | 85 |
95 return AutocompleteMatch::TypeToVectorIcon( | 86 return AutocompleteMatch::TypeToVectorIcon( |
96 model_ ? model_->CurrentTextType() | 87 model_ ? model_->CurrentTextType() |
97 : AutocompleteMatchType::URL_WHAT_YOU_TYPED); | 88 : AutocompleteMatchType::URL_WHAT_YOU_TYPED); |
98 #else | |
99 NOTIMPLEMENTED(); | |
100 return gfx::VectorIconId::VECTOR_ICON_NONE; | |
101 #endif | |
102 } | 89 } |
103 | 90 |
104 void OmniboxView::SetUserText(const base::string16& text) { | 91 void OmniboxView::SetUserText(const base::string16& text) { |
105 SetUserText(text, true); | 92 SetUserText(text, true); |
106 } | 93 } |
107 | 94 |
108 void OmniboxView::SetUserText(const base::string16& text, | 95 void OmniboxView::SetUserText(const base::string16& text, |
109 bool update_popup) { | 96 bool update_popup) { |
110 if (model_.get()) | 97 if (model_.get()) |
111 model_->SetUserText(text); | 98 model_->SetUserText(text); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 if (client) { | 178 if (client) { |
192 model_.reset(new OmniboxEditModel(this, controller, std::move(client))); | 179 model_.reset(new OmniboxEditModel(this, controller, std::move(client))); |
193 } | 180 } |
194 } | 181 } |
195 | 182 |
196 void OmniboxView::TextChanged() { | 183 void OmniboxView::TextChanged() { |
197 EmphasizeURLComponents(); | 184 EmphasizeURLComponents(); |
198 if (model_.get()) | 185 if (model_.get()) |
199 model_->OnChanged(); | 186 model_->OnChanged(); |
200 } | 187 } |
OLD | NEW |