| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/views/omnibox/omnibox_view_views.h" | 5 #include "chrome/browser/ui/views/omnibox/omnibox_view_views.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 textfield_->GetSelectedRange(&selection); | 296 textfield_->GetSelectedRange(&selection); |
| 297 GetStateAccessor()->SetProperty( | 297 GetStateAccessor()->SetProperty( |
| 298 tab->property_bag(), | 298 tab->property_bag(), |
| 299 AutocompleteEditState(model_state, ViewState(selection))); | 299 AutocompleteEditState(model_state, ViewState(selection))); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void OmniboxViewViews::Update(const TabContents* contents) { | 302 void OmniboxViewViews::Update(const TabContents* contents) { |
| 303 // NOTE: We're getting the URL text here from the ToolbarModel. | 303 // NOTE: We're getting the URL text here from the ToolbarModel. |
| 304 bool visibly_changed_permanent_text = | 304 bool visibly_changed_permanent_text = |
| 305 model_->UpdatePermanentText(WideToUTF16Hack(toolbar_model_->GetText())); | 305 model_->UpdatePermanentText(WideToUTF16Hack(toolbar_model_->GetText())); |
| 306 | |
| 307 ToolbarModel::SecurityLevel security_level = | 306 ToolbarModel::SecurityLevel security_level = |
| 308 toolbar_model_->GetSecurityLevel(); | 307 toolbar_model_->GetSecurityLevel(); |
| 309 bool changed_security_level = (security_level != security_level_); | 308 bool changed_security_level = (security_level != security_level_); |
| 310 security_level_ = security_level; | 309 security_level_ = security_level; |
| 311 | 310 |
| 312 // TODO(oshima): Copied from gtk implementation which is | 311 // TODO(oshima): Copied from gtk implementation which is |
| 313 // slightly different from WIN impl. Find out the correct implementation | 312 // slightly different from WIN impl. Find out the correct implementation |
| 314 // for views-implementation. | 313 // for views-implementation. |
| 315 if (contents) { | 314 if (contents) { |
| 316 RevertAll(); | 315 RevertAll(); |
| 317 const AutocompleteEditState* state = | 316 const AutocompleteEditState* state = |
| 318 GetStateAccessor()->GetProperty(contents->property_bag()); | 317 GetStateAccessor()->GetProperty(contents->property_bag()); |
| 319 if (state) { | 318 if (state) { |
| 320 model_->RestoreState(state->model_state); | 319 model_->RestoreState(state->model_state); |
| 321 | 320 |
| 322 // Move the marks for the cursor and the other end of the selection to | 321 // Move the marks for the cursor and the other end of the selection to |
| 323 // the previously-saved offsets (but preserve PRIMARY). | 322 // the previously-saved offsets (but preserve PRIMARY). |
| 324 textfield_->SelectRange(state->view_state.selection_range); | 323 textfield_->SelectRange(state->view_state.selection_range); |
| 324 // We do not carry over the current edit history to another tab. |
| 325 // TODO(oshima): consider saving/restoring edit history. |
| 326 textfield_->ClearEditHistory(); |
| 325 } | 327 } |
| 326 } else if (visibly_changed_permanent_text) { | 328 } else if (visibly_changed_permanent_text) { |
| 327 RevertAll(); | 329 RevertAll(); |
| 328 } else if (changed_security_level) { | 330 } else if (changed_security_level) { |
| 329 EmphasizeURLComponents(); | 331 EmphasizeURLComponents(); |
| 330 } | 332 } |
| 331 } | 333 } |
| 332 | 334 |
| 333 void OmniboxViewViews::OpenMatch(const AutocompleteMatch& match, | 335 void OmniboxViewViews::OpenMatch(const AutocompleteMatch& match, |
| 334 WindowOpenDisposition disposition, | 336 WindowOpenDisposition disposition, |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 normal_text_style_ = textfield_->CreateTextStyle(); | 697 normal_text_style_ = textfield_->CreateTextStyle(); |
| 696 security_error_scheme_style_ = textfield_->CreateTextStyle(); | 698 security_error_scheme_style_ = textfield_->CreateTextStyle(); |
| 697 secure_scheme_style_ = textfield_->CreateTextStyle(); | 699 secure_scheme_style_ = textfield_->CreateTextStyle(); |
| 698 | 700 |
| 699 faded_text_style_->set_foreground(kFadedTextColor); | 701 faded_text_style_->set_foreground(kFadedTextColor); |
| 700 normal_text_style_->set_foreground(kNormalTextColor); | 702 normal_text_style_->set_foreground(kNormalTextColor); |
| 701 secure_scheme_style_->set_foreground(kSecureSchemeColor); | 703 secure_scheme_style_->set_foreground(kSecureSchemeColor); |
| 702 security_error_scheme_style_->set_foreground(kSecurityErrorSchemeColor); | 704 security_error_scheme_style_->set_foreground(kSecurityErrorSchemeColor); |
| 703 security_error_scheme_style_->set_strike(true); | 705 security_error_scheme_style_->set_strike(true); |
| 704 } | 706 } |
| OLD | NEW |