| 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/autocomplete/autocomplete_edit.h" | 5 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 is_keyword_hint_(false), | 82 is_keyword_hint_(false), |
| 83 profile_(profile), | 83 profile_(profile), |
| 84 in_revert_(false), | 84 in_revert_(false), |
| 85 allow_exact_keyword_match_(false), | 85 allow_exact_keyword_match_(false), |
| 86 instant_complete_behavior_(INSTANT_COMPLETE_DELAYED) { | 86 instant_complete_behavior_(INSTANT_COMPLETE_DELAYED) { |
| 87 } | 87 } |
| 88 | 88 |
| 89 AutocompleteEditModel::~AutocompleteEditModel() { | 89 AutocompleteEditModel::~AutocompleteEditModel() { |
| 90 } | 90 } |
| 91 | 91 |
| 92 void AutocompleteEditModel::SetProfile(Profile* profile) { | |
| 93 DCHECK(profile); | |
| 94 profile_ = profile; | |
| 95 autocomplete_controller_->SetProfile(profile); | |
| 96 popup_->set_profile(profile); | |
| 97 } | |
| 98 | |
| 99 const AutocompleteEditModel::State | 92 const AutocompleteEditModel::State |
| 100 AutocompleteEditModel::GetStateForTabSwitch() { | 93 AutocompleteEditModel::GetStateForTabSwitch() { |
| 101 // Like typing, switching tabs "accepts" the temporary text as the user | 94 // Like typing, switching tabs "accepts" the temporary text as the user |
| 102 // text, because it makes little sense to have temporary text when the | 95 // text, because it makes little sense to have temporary text when the |
| 103 // popup is closed. | 96 // popup is closed. |
| 104 if (user_input_in_progress_) { | 97 if (user_input_in_progress_) { |
| 105 // Weird edge case to match other browsers: if the edit is empty, revert to | 98 // Weird edge case to match other browsers: if the edit is empty, revert to |
| 106 // the permanent text (so the user can get it back easily) but select it (so | 99 // the permanent text (so the user can get it back easily) but select it (so |
| 107 // on switching back, typing will "just work"). | 100 // on switching back, typing will "just work"). |
| 108 const string16 user_text(UserTextFromDisplayText(view_->GetText())); | 101 const string16 user_text(UserTextFromDisplayText(view_->GetText())); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 UseVerbatimInstant(), &suggested_text); | 222 UseVerbatimInstant(), &suggested_text); |
| 230 } | 223 } |
| 231 } else { | 224 } else { |
| 232 instant->DestroyPreviewContents(); | 225 instant->DestroyPreviewContents(); |
| 233 } | 226 } |
| 234 might_support_instant = instant->MightSupportInstant(); | 227 might_support_instant = instant->MightSupportInstant(); |
| 235 } else if (user_input_in_progress() && popup_->IsOpen()) { | 228 } else if (user_input_in_progress() && popup_->IsOpen()) { |
| 236 // Start Prerender of this page instead. | 229 // Start Prerender of this page instead. |
| 237 CHECK(tab->tab_contents()); | 230 CHECK(tab->tab_contents()); |
| 238 prerender::PrerenderManager* prerender_manager = | 231 prerender::PrerenderManager* prerender_manager = |
| 239 tab->profile()->GetPrerenderManager(); | 232 profile_->GetPrerenderManager(); |
| 240 if (prerender_manager) { | 233 if (prerender_manager) { |
| 241 prerender_manager->AddPrerenderFromOmnibox( | 234 prerender_manager->AddPrerenderFromOmnibox( |
| 242 CurrentMatch().destination_url); | 235 CurrentMatch().destination_url); |
| 243 } | 236 } |
| 244 } | 237 } |
| 245 } | 238 } |
| 246 | 239 |
| 247 if (!might_support_instant) { | 240 if (!might_support_instant) { |
| 248 // Hide any suggestions we might be showing. | 241 // Hide any suggestions we might be showing. |
| 249 view_->SetInstantSuggestion(string16(), false); | 242 view_->SetInstantSuggestion(string16(), false); |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 // static | 1010 // static |
| 1018 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1011 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
| 1019 switch (c) { | 1012 switch (c) { |
| 1020 case 0x0020: // Space | 1013 case 0x0020: // Space |
| 1021 case 0x3000: // Ideographic Space | 1014 case 0x3000: // Ideographic Space |
| 1022 return true; | 1015 return true; |
| 1023 default: | 1016 default: |
| 1024 return false; | 1017 return false; |
| 1025 } | 1018 } |
| 1026 } | 1019 } |
| OLD | NEW |