Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/tab_contents/tab_contents.h" | 5 #include "chrome/browser/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
| 10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
| (...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1077 bool case_sensitive) { | 1077 bool case_sensitive) { |
| 1078 // If find_text is empty, it means FindNext was pressed with a keyboard | 1078 // If find_text is empty, it means FindNext was pressed with a keyboard |
| 1079 // shortcut so unless we have something to search for we return early. | 1079 // shortcut so unless we have something to search for we return early. |
| 1080 if (find_text.empty() && find_text_.empty()) { | 1080 if (find_text.empty() && find_text_.empty()) { |
| 1081 if (last_search_prepopulate_text_->empty()) | 1081 if (last_search_prepopulate_text_->empty()) |
| 1082 return; | 1082 return; |
| 1083 // Try whatever we searched for last in any tab. | 1083 // Try whatever we searched for last in any tab. |
| 1084 find_text = *last_search_prepopulate_text_; | 1084 find_text = *last_search_prepopulate_text_; |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 // Keep track of the previous search. | |
| 1088 previous_find_text_ = find_text_; | |
| 1089 | |
| 1087 // This is a FindNext operation if we are searching for the same text again, | 1090 // This is a FindNext operation if we are searching for the same text again, |
| 1088 // or if the passed in search text is empty (FindNext keyboard shortcut). The | 1091 // or if the passed in search text is empty (FindNext keyboard shortcut). The |
| 1089 // exception to this is if the Find was aborted (then we don't want FindNext | 1092 // exception to this is if the Find was aborted (then we don't want FindNext |
| 1090 // because the highlighting has been cleared and we need it to reappear). We | 1093 // because the highlighting has been cleared and we need it to reappear). We |
| 1091 // therefore treat FindNext after an aborted Find operation as a full fledged | 1094 // therefore treat FindNext after an aborted Find operation as a full fledged |
| 1092 // Find. | 1095 // Find. |
| 1093 bool find_next = (find_text_ == find_text || find_text.empty()) && | 1096 bool find_next = (find_text_ == find_text || find_text.empty()) && |
| 1094 (last_search_case_sensitive_ == case_sensitive) && | 1097 (last_search_case_sensitive_ == case_sensitive) && |
| 1095 !find_op_aborted_; | 1098 !find_op_aborted_; |
| 1096 if (!find_next) | 1099 if (!find_next) |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1110 forward_direction, | 1113 forward_direction, |
| 1111 case_sensitive, | 1114 case_sensitive, |
| 1112 find_next); | 1115 find_next); |
| 1113 } | 1116 } |
| 1114 | 1117 |
| 1115 void TabContents::StopFinding(bool clear_selection) { | 1118 void TabContents::StopFinding(bool clear_selection) { |
| 1116 // When |clear_selection| is true, it means the find string has been cleared | 1119 // When |clear_selection| is true, it means the find string has been cleared |
| 1117 // by the user, but the UI has not been dismissed. | 1120 // by the user, but the UI has not been dismissed. |
| 1118 if (!clear_selection) | 1121 if (!clear_selection) |
| 1119 find_ui_active_ = false; | 1122 find_ui_active_ = false; |
| 1123 find_text_ = string16(); | |
|
Peter Kasting
2009/10/26 21:04:33
Nit: Use "find_text_.clear();"
| |
| 1120 find_op_aborted_ = true; | 1124 find_op_aborted_ = true; |
| 1121 last_search_result_ = FindNotificationDetails(); | 1125 last_search_result_ = FindNotificationDetails(); |
| 1122 render_view_host()->StopFinding(clear_selection); | 1126 render_view_host()->StopFinding(clear_selection); |
| 1123 } | 1127 } |
| 1124 | 1128 |
| 1125 void TabContents::GetPageLanguage() { | 1129 void TabContents::GetPageLanguage() { |
| 1126 render_view_host()->GetPageLanguage(); | 1130 render_view_host()->GetPageLanguage(); |
| 1127 } | 1131 } |
| 1128 | 1132 |
| 1129 void TabContents::OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg, | 1133 void TabContents::OnJavaScriptMessageBoxClosed(IPC::Message* reply_msg, |
| (...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2646 #endif | 2650 #endif |
| 2647 | 2651 |
| 2648 default: | 2652 default: |
| 2649 NOTREACHED(); | 2653 NOTREACHED(); |
| 2650 } | 2654 } |
| 2651 } | 2655 } |
| 2652 | 2656 |
| 2653 void TabContents::set_encoding(const std::string& encoding) { | 2657 void TabContents::set_encoding(const std::string& encoding) { |
| 2654 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); | 2658 encoding_ = CharacterEncoding::GetCanonicalEncodingNameByAliasName(encoding); |
| 2655 } | 2659 } |
| OLD | NEW |