| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 SetUserText(text, true); | 105 SetUserText(text, true); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void OmniboxView::SetUserText(const base::string16& text, | 108 void OmniboxView::SetUserText(const base::string16& text, |
| 109 bool update_popup) { | 109 bool update_popup) { |
| 110 if (model_.get()) | 110 if (model_.get()) |
| 111 model_->SetUserText(text); | 111 model_->SetUserText(text); |
| 112 SetWindowTextAndCaretPos(text, text.length(), update_popup, true); | 112 SetWindowTextAndCaretPos(text, text.length(), update_popup, true); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void OmniboxView::ShowURL() { | |
| 116 SetFocus(); | |
| 117 controller_->GetToolbarModel()->set_url_replacement_enabled(false); | |
| 118 model_->UpdatePermanentText(); | |
| 119 RevertWithoutResettingSearchTermReplacement(); | |
| 120 SelectAll(true); | |
| 121 } | |
| 122 | |
| 123 void OmniboxView::HideURL() { | |
| 124 controller_->GetToolbarModel()->set_url_replacement_enabled(true); | |
| 125 model_->UpdatePermanentText(); | |
| 126 RevertWithoutResettingSearchTermReplacement(); | |
| 127 } | |
| 128 | |
| 129 void OmniboxView::RevertAll() { | 115 void OmniboxView::RevertAll() { |
| 130 controller_->GetToolbarModel()->set_url_replacement_enabled(true); | 116 controller_->GetToolbarModel()->set_url_replacement_enabled(true); |
| 131 RevertWithoutResettingSearchTermReplacement(); | 117 RevertWithoutResettingSearchTermReplacement(); |
| 132 } | 118 } |
| 133 | 119 |
| 134 void OmniboxView::RevertWithoutResettingSearchTermReplacement() { | 120 void OmniboxView::RevertWithoutResettingSearchTermReplacement() { |
| 135 CloseOmniboxPopup(); | 121 CloseOmniboxPopup(); |
| 136 if (model_.get()) | 122 if (model_.get()) |
| 137 model_->Revert(); | 123 model_->Revert(); |
| 138 TextChanged(); | 124 TextChanged(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 if (client) { | 196 if (client) { |
| 211 model_.reset(new OmniboxEditModel(this, controller, std::move(client))); | 197 model_.reset(new OmniboxEditModel(this, controller, std::move(client))); |
| 212 } | 198 } |
| 213 } | 199 } |
| 214 | 200 |
| 215 void OmniboxView::TextChanged() { | 201 void OmniboxView::TextChanged() { |
| 216 EmphasizeURLComponents(); | 202 EmphasizeURLComponents(); |
| 217 if (model_.get()) | 203 if (model_.get()) |
| 218 model_->OnChanged(); | 204 model_->OnChanged(); |
| 219 } | 205 } |
| OLD | NEW |