| 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 1010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 DCHECK(suggested_text); | 1021 DCHECK(suggested_text); |
| 1022 | 1022 |
| 1023 if (in_revert_) | 1023 if (in_revert_) |
| 1024 return false; | 1024 return false; |
| 1025 | 1025 |
| 1026 InstantController* instant = controller_->GetInstant(); | 1026 InstantController* instant = controller_->GetInstant(); |
| 1027 | 1027 |
| 1028 if (!instant) | 1028 if (!instant) |
| 1029 return false; | 1029 return false; |
| 1030 | 1030 |
| 1031 // It's possible the tab strip does not have an active tab contents, for |
| 1032 // instance if the tab has been closed or on return from a sleep state |
| 1033 // (http://crbug.com/105689) |
| 1031 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); | 1034 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); |
| 1032 | |
| 1033 if (!tab) | 1035 if (!tab) |
| 1034 return false; | 1036 return false; |
| 1035 | 1037 |
| 1036 if (user_input_in_progress() && popup_->IsOpen()) { | 1038 if (user_input_in_progress() && popup_->IsOpen()) { |
| 1037 return instant->Update(tab, match, view_->GetText(), UseVerbatimInstant(), | 1039 return instant->Update(tab, match, view_->GetText(), UseVerbatimInstant(), |
| 1038 suggested_text); | 1040 suggested_text); |
| 1039 } else { | |
| 1040 instant->Hide(); | |
| 1041 return false; | |
| 1042 } | 1041 } |
| 1042 |
| 1043 instant->Hide(); |
| 1044 return false; |
| 1043 } | 1045 } |
| 1044 | 1046 |
| 1045 void AutocompleteEditModel::DoPrerender(const AutocompleteMatch& match) { | 1047 void AutocompleteEditModel::DoPrerender(const AutocompleteMatch& match) { |
| 1046 // Do not prerender if the destination URL is the same as the current URL. | 1048 // Do not prerender if the destination URL is the same as the current URL. |
| 1047 if (match.destination_url == PermanentURL()) | 1049 if (match.destination_url == PermanentURL()) |
| 1048 return; | 1050 return; |
| 1051 // It's possible the tab strip does not have an active tab contents, for |
| 1052 // instance if the tab has been closed or on return from a sleep state |
| 1053 // (http://crbug.com/105689) |
| 1049 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); | 1054 TabContentsWrapper* tab = controller_->GetTabContentsWrapper(); |
| 1055 if (!tab) |
| 1056 return; |
| 1050 prerender::PrerenderManager* prerender_manager = | 1057 prerender::PrerenderManager* prerender_manager = |
| 1051 prerender::PrerenderManagerFactory::GetForProfile(tab->profile()); | 1058 prerender::PrerenderManagerFactory::GetForProfile(tab->profile()); |
| 1052 if (prerender_manager) { | 1059 if (prerender_manager) { |
| 1053 RenderViewHost* current_host = tab->tab_contents()->render_view_host(); | 1060 RenderViewHost* current_host = tab->tab_contents()->render_view_host(); |
| 1054 prerender_manager->AddPrerenderFromOmnibox( | 1061 prerender_manager->AddPrerenderFromOmnibox( |
| 1055 match.destination_url, current_host->session_storage_namespace()); | 1062 match.destination_url, current_host->session_storage_namespace()); |
| 1056 } | 1063 } |
| 1057 } | 1064 } |
| 1058 | 1065 |
| 1059 void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) { | 1066 void AutocompleteEditModel::DoPreconnect(const AutocompleteMatch& match) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1075 // static | 1082 // static |
| 1076 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { | 1083 bool AutocompleteEditModel::IsSpaceCharForAcceptingKeyword(wchar_t c) { |
| 1077 switch (c) { | 1084 switch (c) { |
| 1078 case 0x0020: // Space | 1085 case 0x0020: // Space |
| 1079 case 0x3000: // Ideographic Space | 1086 case 0x3000: // Ideographic Space |
| 1080 return true; | 1087 return true; |
| 1081 default: | 1088 default: |
| 1082 return false; | 1089 return false; |
| 1083 } | 1090 } |
| 1084 } | 1091 } |
| OLD | NEW |