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 "chrome/browser/ui/omnibox/omnibox_view.h" | 8 #include "chrome/browser/ui/omnibox/omnibox_view.h" |
9 | 9 |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 model_->OpenMatch(match, disposition, alternate_nav_url, selected_line); | 82 model_->OpenMatch(match, disposition, alternate_nav_url, selected_line); |
83 } | 83 } |
84 | 84 |
85 bool OmniboxView::IsEditingOrEmpty() const { | 85 bool OmniboxView::IsEditingOrEmpty() const { |
86 return (model_.get() && model_->user_input_in_progress()) || | 86 return (model_.get() && model_->user_input_in_progress()) || |
87 (GetOmniboxTextLength() == 0); | 87 (GetOmniboxTextLength() == 0); |
88 } | 88 } |
89 | 89 |
90 int OmniboxView::GetIcon() const { | 90 int OmniboxView::GetIcon() const { |
91 if (IsEditingOrEmpty()) { | 91 if (IsEditingOrEmpty()) { |
92 return AutocompleteMatch::TypeToIcon(model_.get() ? | 92 return AutocompleteMatch::TypeToLocationBarIcon(model_.get() ? |
93 model_->CurrentTextType() : AutocompleteMatch::URL_WHAT_YOU_TYPED); | 93 model_->CurrentTextType() : AutocompleteMatch::URL_WHAT_YOU_TYPED); |
94 } else { | 94 } else { |
95 return toolbar_model_->GetIcon(); | 95 return toolbar_model_->GetIcon(); |
96 } | 96 } |
97 } | 97 } |
98 | 98 |
99 void OmniboxView::SetUserText(const string16& text) { | 99 void OmniboxView::SetUserText(const string16& text) { |
100 SetUserText(text, text, true); | 100 SetUserText(text, text, true); |
101 } | 101 } |
102 | 102 |
(...skipping 28 matching lines...) Expand all Loading... |
131 // |profile| can be NULL in tests. | 131 // |profile| can be NULL in tests. |
132 if (profile) | 132 if (profile) |
133 model_.reset(new OmniboxEditModel(this, controller, profile)); | 133 model_.reset(new OmniboxEditModel(this, controller, profile)); |
134 } | 134 } |
135 | 135 |
136 void OmniboxView::TextChanged() { | 136 void OmniboxView::TextChanged() { |
137 EmphasizeURLComponents(); | 137 EmphasizeURLComponents(); |
138 if (model_.get()) | 138 if (model_.get()) |
139 model_->OnChanged(); | 139 model_->OnChanged(); |
140 } | 140 } |
OLD | NEW |