Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2006-2008 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/web_contents.h" | 5 #include "chrome/browser/tab_contents/web_contents.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.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" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 received_page_title_(false), | 201 received_page_title_(false), |
| 202 is_starred_(false), | 202 is_starred_(false), |
| 203 #if defined(OS_WIN) | 203 #if defined(OS_WIN) |
| 204 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), | 204 message_box_active_(CreateEvent(NULL, TRUE, FALSE, NULL)), |
| 205 #endif | 205 #endif |
| 206 ALLOW_THIS_IN_INITIALIZER_LIST(fav_icon_helper_(this)), | 206 ALLOW_THIS_IN_INITIALIZER_LIST(fav_icon_helper_(this)), |
| 207 suppress_javascript_messages_(false), | 207 suppress_javascript_messages_(false), |
| 208 load_state_(net::LOAD_STATE_IDLE), | 208 load_state_(net::LOAD_STATE_IDLE), |
| 209 find_ui_active_(false), | 209 find_ui_active_(false), |
| 210 find_op_aborted_(false), | 210 find_op_aborted_(false), |
| 211 current_find_request_id_(find_request_id_counter_++) { | 211 current_find_request_id_(find_request_id_counter_++), |
| 212 find_prepopulate_text_(NULL) { | |
| 212 pending_install_.page_id = 0; | 213 pending_install_.page_id = 0; |
| 213 pending_install_.callback_functor = NULL; | 214 pending_install_.callback_functor = NULL; |
| 214 | 215 |
| 215 render_manager_.Init(profile, site_instance, routing_id, modal_dialog_event); | 216 render_manager_.Init(profile, site_instance, routing_id, modal_dialog_event); |
| 216 | 217 |
| 217 view_->CreateView(); | 218 view_->CreateView(); |
| 218 | 219 |
| 219 // Register for notifications about all interested prefs change. | 220 // Register for notifications about all interested prefs change. |
| 220 PrefService* prefs = profile->GetPrefs(); | 221 PrefService* prefs = profile->GetPrefs(); |
| 221 if (prefs) { | 222 if (prefs) { |
| 222 for (int i = 0; i < kPrefsToObserveLength; ++i) | 223 for (int i = 0; i < kPrefsToObserveLength; ++i) |
| 223 prefs->AddPrefObserver(kPrefsToObserve[i], this); | 224 prefs->AddPrefObserver(kPrefsToObserve[i], this); |
| 224 } | 225 } |
| 225 | 226 |
| 226 // Register for notifications about URL starredness changing on any profile. | 227 // Register for notifications about URL starredness changing on any profile. |
| 227 NotificationService::current()->AddObserver( | 228 NotificationService::current()->AddObserver( |
| 228 this, NotificationType::URLS_STARRED, NotificationService::AllSources()); | 229 this, NotificationType::URLS_STARRED, NotificationService::AllSources()); |
| 229 NotificationService::current()->AddObserver( | 230 NotificationService::current()->AddObserver( |
| 230 this, NotificationType::BOOKMARK_MODEL_LOADED, | 231 this, NotificationType::BOOKMARK_MODEL_LOADED, |
| 231 NotificationService::AllSources()); | 232 NotificationService::AllSources()); |
| 232 NotificationService::current()->AddObserver( | 233 NotificationService::current()->AddObserver( |
| 233 this, NotificationType::RENDER_WIDGET_HOST_DESTROYED, | 234 this, NotificationType::RENDER_WIDGET_HOST_DESTROYED, |
| 234 NotificationService::AllSources()); | 235 NotificationService::AllSources()); |
| 236 | |
| 237 // Keep a global copy of the previous search string (if any). | |
| 238 static string16 global_last_search = string16(); | |
| 239 find_prepopulate_text_ = &global_last_search; | |
|
Ben Goodger (Google)
2009/04/13 20:48:25
is there a reason to save a pointer to this rather
| |
| 235 } | 240 } |
| 236 | 241 |
| 237 WebContents::~WebContents() { | 242 WebContents::~WebContents() { |
| 238 if (pending_install_.callback_functor) | 243 if (pending_install_.callback_functor) |
| 239 pending_install_.callback_functor->Cancel(); | 244 pending_install_.callback_functor->Cancel(); |
| 240 NotificationService::current()->RemoveObserver( | 245 NotificationService::current()->RemoveObserver( |
| 241 this, NotificationType::RENDER_WIDGET_HOST_DESTROYED, | 246 this, NotificationType::RENDER_WIDGET_HOST_DESTROYED, |
| 242 NotificationService::AllSources()); | 247 NotificationService::AllSources()); |
| 243 } | 248 } |
| 244 | 249 |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 bool find_next = (find_text_ == find_text || find_text.empty()) && | 623 bool find_next = (find_text_ == find_text || find_text.empty()) && |
| 619 !find_op_aborted_; | 624 !find_op_aborted_; |
| 620 if (!find_next) | 625 if (!find_next) |
| 621 current_find_request_id_ = find_request_id_counter_++; | 626 current_find_request_id_ = find_request_id_counter_++; |
| 622 | 627 |
| 623 if (!find_text.empty()) | 628 if (!find_text.empty()) |
| 624 find_text_ = find_text; | 629 find_text_ = find_text; |
| 625 | 630 |
| 626 find_op_aborted_ = false; | 631 find_op_aborted_ = false; |
| 627 | 632 |
| 633 // Keep track of what the last search was across the tabs. | |
| 634 *find_prepopulate_text_ = find_text; | |
| 635 | |
| 628 render_view_host()->StartFinding(current_find_request_id_, | 636 render_view_host()->StartFinding(current_find_request_id_, |
| 629 find_text_, | 637 find_text_, |
| 630 forward_direction, | 638 forward_direction, |
| 631 false, // case sensitive | 639 false, // case sensitive |
| 632 find_next); | 640 find_next); |
| 633 } | 641 } |
| 634 | 642 |
| 635 void WebContents::StopFinding(bool clear_selection) { | 643 void WebContents::StopFinding(bool clear_selection) { |
| 636 find_ui_active_ = false; | 644 find_ui_active_ = false; |
| 637 find_op_aborted_ = true; | 645 find_op_aborted_ = true; |
| (...skipping 1394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2032 // -> Use pending DOM UI if any. | 2040 // -> Use pending DOM UI if any. |
| 2033 // | 2041 // |
| 2034 // - Normal state with no load: committed nav entry + no pending nav entry: | 2042 // - Normal state with no load: committed nav entry + no pending nav entry: |
| 2035 // -> Use committed DOM UI. | 2043 // -> Use committed DOM UI. |
| 2036 if (controller()->GetPendingEntry() && | 2044 if (controller()->GetPendingEntry() && |
| 2037 (controller()->GetLastCommittedEntry() || | 2045 (controller()->GetLastCommittedEntry() || |
| 2038 render_manager_.pending_dom_ui())) | 2046 render_manager_.pending_dom_ui())) |
| 2039 return render_manager_.pending_dom_ui(); | 2047 return render_manager_.pending_dom_ui(); |
| 2040 return render_manager_.dom_ui(); | 2048 return render_manager_.dom_ui(); |
| 2041 } | 2049 } |
| OLD | NEW |