| 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/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 | 92 |
| 93 bool OmniboxView::IsEditingOrEmpty() const { | 93 bool OmniboxView::IsEditingOrEmpty() const { |
| 94 return (model_.get() && model_->user_input_in_progress()) || | 94 return (model_.get() && model_->user_input_in_progress()) || |
| 95 (GetOmniboxTextLength() == 0); | 95 (GetOmniboxTextLength() == 0); |
| 96 } | 96 } |
| 97 | 97 |
| 98 int OmniboxView::GetIcon() const { | 98 int OmniboxView::GetIcon() const { |
| 99 if (!IsEditingOrEmpty()) | 99 if (!IsEditingOrEmpty()) |
| 100 return controller_->GetToolbarModel()->GetIcon(); | 100 return controller_->GetToolbarModel()->GetIcon(); |
| 101 return AutocompleteMatch::TypeToLocationBarIcon(model_.get() ? | 101 return AutocompleteMatch::TypeToLocationBarIcon(model_.get() ? |
| 102 model_->CurrentTextType() : AutocompleteMatchType::URL_WHAT_YOU_TYPED); | 102 model_->CurrentTextType() : AutocompleteMatchType::URL_WHAT_YOU_TYPED); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void OmniboxView::SetUserText(const string16& text) { | 105 void OmniboxView::SetUserText(const string16& text) { |
| 106 SetUserText(text, text, true); | 106 SetUserText(text, text, true); |
| 107 } | 107 } |
| 108 | 108 |
| 109 void OmniboxView::SetUserText(const string16& text, | 109 void OmniboxView::SetUserText(const string16& text, |
| 110 const string16& display_text, | 110 const string16& display_text, |
| 111 bool update_popup) { | 111 bool update_popup) { |
| 112 if (model_.get()) | 112 if (model_.get()) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // |profile| can be NULL in tests. | 148 // |profile| can be NULL in tests. |
| 149 if (profile) | 149 if (profile) |
| 150 model_.reset(new OmniboxEditModel(this, controller, profile)); | 150 model_.reset(new OmniboxEditModel(this, controller, profile)); |
| 151 } | 151 } |
| 152 | 152 |
| 153 void OmniboxView::TextChanged() { | 153 void OmniboxView::TextChanged() { |
| 154 EmphasizeURLComponents(); | 154 EmphasizeURLComponents(); |
| 155 if (model_.get()) | 155 if (model_.get()) |
| 156 model_->OnChanged(); | 156 model_->OnChanged(); |
| 157 } | 157 } |
| OLD | NEW |