| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 5 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 return State( | 240 return State( |
| 241 user_input_in_progress_, user_text_, view_->GetGrayTextAutocompletion(), | 241 user_input_in_progress_, user_text_, view_->GetGrayTextAutocompletion(), |
| 242 keyword_, is_keyword_hint_, | 242 keyword_, is_keyword_hint_, |
| 243 controller_->GetToolbarModel()->url_replacement_enabled(), | 243 controller_->GetToolbarModel()->url_replacement_enabled(), |
| 244 focus_state_, focus_source_, input_); | 244 focus_state_, focus_source_, input_); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void OmniboxEditModel::RestoreState(const State* state) { | 247 void OmniboxEditModel::RestoreState(const State* state) { |
| 248 // We need to update the permanent text correctly and revert the view | 248 // We need to update the permanent text correctly and revert the view |
| 249 // regardless of whether there is saved state. | 249 // regardless of whether there is saved state. |
| 250 bool url_replacement_enabled = !state || state->url_replacement_enabled; |
| 250 controller_->GetToolbarModel()->set_url_replacement_enabled( | 251 controller_->GetToolbarModel()->set_url_replacement_enabled( |
| 251 !state || state->url_replacement_enabled); | 252 url_replacement_enabled); |
| 253 controller_->GetToolbarModel()->set_origin_chip_enabled( |
| 254 url_replacement_enabled); |
| 252 permanent_text_ = controller_->GetToolbarModel()->GetText(); | 255 permanent_text_ = controller_->GetToolbarModel()->GetText(); |
| 253 // Don't muck with the search term replacement state, as we've just set it | 256 // Don't muck with the search term replacement state, as we've just set it |
| 254 // correctly. | 257 // correctly. |
| 255 view_->RevertWithoutResettingSearchTermReplacement(); | 258 view_->RevertWithoutResettingSearchTermReplacement(); |
| 256 // Restore the autocomplete controller's input, or clear it if this is a new | 259 // Restore the autocomplete controller's input, or clear it if this is a new |
| 257 // tab. | 260 // tab. |
| 258 input_ = state ? state->autocomplete_input : AutocompleteInput(); | 261 input_ = state ? state->autocomplete_input : AutocompleteInput(); |
| 259 if (!state) | 262 if (!state) |
| 260 return; | 263 return; |
| 261 | 264 |
| (...skipping 1194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1456 // Update state and notify view if the omnibox has focus and the caret | 1459 // Update state and notify view if the omnibox has focus and the caret |
| 1457 // visibility changed. | 1460 // visibility changed. |
| 1458 const bool was_caret_visible = is_caret_visible(); | 1461 const bool was_caret_visible = is_caret_visible(); |
| 1459 focus_state_ = state; | 1462 focus_state_ = state; |
| 1460 if (focus_state_ != OMNIBOX_FOCUS_NONE && | 1463 if (focus_state_ != OMNIBOX_FOCUS_NONE && |
| 1461 is_caret_visible() != was_caret_visible) | 1464 is_caret_visible() != was_caret_visible) |
| 1462 view_->ApplyCaretVisibility(); | 1465 view_->ApplyCaretVisibility(); |
| 1463 | 1466 |
| 1464 delegate_->OnFocusChanged(focus_state_, reason); | 1467 delegate_->OnFocusChanged(focus_state_, reason); |
| 1465 } | 1468 } |
| OLD | NEW |