| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 void OmniboxView::SetUserText(const base::string16& text, | 109 void OmniboxView::SetUserText(const base::string16& text, |
| 110 const base::string16& display_text, | 110 const base::string16& display_text, |
| 111 bool update_popup) { | 111 bool update_popup) { |
| 112 if (model_.get()) | 112 if (model_.get()) |
| 113 model_->SetUserText(text); | 113 model_->SetUserText(text); |
| 114 SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup, | 114 SetWindowTextAndCaretPos(display_text, display_text.length(), update_popup, |
| 115 true); | 115 true); |
| 116 } | 116 } |
| 117 | 117 |
| 118 void OmniboxView::ShowURL() { |
| 119 SetFocus(); |
| 120 controller_->GetToolbarModel()->set_url_replacement_enabled(false); |
| 121 model_->UpdatePermanentText(); |
| 122 RevertWithoutResettingSearchTermReplacement(); |
| 123 SelectAll(true); |
| 124 } |
| 125 |
| 118 void OmniboxView::RevertAll() { | 126 void OmniboxView::RevertAll() { |
| 119 controller_->GetToolbarModel()->set_url_replacement_enabled(true); | 127 controller_->GetToolbarModel()->set_url_replacement_enabled(true); |
| 120 RevertWithoutResettingSearchTermReplacement(); | 128 RevertWithoutResettingSearchTermReplacement(); |
| 121 } | 129 } |
| 122 | 130 |
| 123 void OmniboxView::RevertWithoutResettingSearchTermReplacement() { | 131 void OmniboxView::RevertWithoutResettingSearchTermReplacement() { |
| 124 CloseOmniboxPopup(); | 132 CloseOmniboxPopup(); |
| 125 if (model_.get()) | 133 if (model_.get()) |
| 126 model_->Revert(); | 134 model_->Revert(); |
| 127 TextChanged(); | 135 TextChanged(); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 153 // |profile| can be NULL in tests. | 161 // |profile| can be NULL in tests. |
| 154 if (profile) | 162 if (profile) |
| 155 model_.reset(new OmniboxEditModel(this, controller, profile)); | 163 model_.reset(new OmniboxEditModel(this, controller, profile)); |
| 156 } | 164 } |
| 157 | 165 |
| 158 void OmniboxView::TextChanged() { | 166 void OmniboxView::TextChanged() { |
| 159 EmphasizeURLComponents(); | 167 EmphasizeURLComponents(); |
| 160 if (model_.get()) | 168 if (model_.get()) |
| 161 model_->OnChanged(); | 169 model_->OnChanged(); |
| 162 } | 170 } |
| 163 | |
| 164 void OmniboxView::ShowURL() { | |
| 165 controller_->GetToolbarModel()->set_url_replacement_enabled(false); | |
| 166 model_->UpdatePermanentText(); | |
| 167 RevertWithoutResettingSearchTermReplacement(); | |
| 168 SelectAll(true); | |
| 169 } | |
| OLD | NEW |