| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/tab_contents/tab_contents.h" | 5 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "chrome/browser/autofill/autocomplete_history_manager.h" | 9 #include "chrome/browser/autofill/autocomplete_history_manager.h" |
| 10 #include "chrome/browser/autofill/autofill_external_delegate.h" | 10 #include "chrome/browser/autofill/autofill_external_delegate.h" |
| 11 #include "chrome/browser/autofill/autofill_manager.h" | 11 #include "chrome/browser/autofill/autofill_manager.h" |
| 12 #include "chrome/browser/automation/automation_tab_helper.h" | 12 #include "chrome/browser/automation/automation_tab_helper.h" |
| 13 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" | 13 #include "chrome/browser/captive_portal/captive_portal_tab_helper.h" |
| 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 14 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 15 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 15 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
| 16 #include "chrome/browser/extensions/tab_helper.h" | 16 #include "chrome/browser/extensions/tab_helper.h" |
| 17 #include "chrome/browser/external_protocol/external_protocol_observer.h" | 17 #include "chrome/browser/external_protocol/external_protocol_observer.h" |
| 18 #include "chrome/browser/favicon/favicon_tab_helper.h" | 18 #include "chrome/browser/favicon/favicon_tab_helper.h" |
| 19 #include "chrome/browser/history/history_tab_helper.h" | 19 #include "chrome/browser/history/history_tab_helper.h" |
| 20 #include "chrome/browser/infobars/infobar_tab_helper.h" | 20 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 21 #include "chrome/browser/net/load_time_stats.h" | 21 #include "chrome/browser/net/load_time_stats.h" |
| 22 #include "chrome/browser/omnibox_search_hint.h" | 22 #include "chrome/browser/omnibox_search_hint.h" |
| 23 #include "chrome/browser/password_manager/password_manager.h" | 23 #include "chrome/browser/password_manager/password_manager.h" |
| 24 #include "chrome/browser/password_manager/password_manager_delegate_impl.h" | 24 #include "chrome/browser/password_manager/password_manager_delegate_impl.h" |
| 25 #include "chrome/browser/plugin_observer.h" | 25 #include "chrome/browser/plugin_observer.h" |
| 26 #include "chrome/browser/prerender/prerender_tab_helper.h" | 26 #include "chrome/browser/prerender/prerender_tab_helper.h" |
| 27 #include "chrome/browser/printing/print_preview_message_handler.h" | 27 #include "chrome/browser/printing/print_preview_message_handler.h" |
| 28 #include "chrome/browser/printing/print_view_manager.h" | 28 #include "chrome/browser/printing/print_view_manager.h" |
| 29 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" | 29 #include "chrome/browser/safe_browsing/safe_browsing_tab_observer.h" |
| 30 #include "chrome/browser/sessions/restore_tab_helper.h" | 30 #include "chrome/browser/sessions/session_tab_helper.h" |
| 31 #include "chrome/browser/sessions/session_service.h" | |
| 32 #include "chrome/browser/sessions/session_service_factory.h" | |
| 33 #include "chrome/browser/tab_contents/navigation_metrics_recorder.h" | 31 #include "chrome/browser/tab_contents/navigation_metrics_recorder.h" |
| 34 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" | 32 #include "chrome/browser/tab_contents/tab_contents_ssl_helper.h" |
| 35 #include "chrome/browser/tab_contents/thumbnail_generator.h" | 33 #include "chrome/browser/tab_contents/thumbnail_generator.h" |
| 36 #include "chrome/browser/translate/translate_tab_helper.h" | 34 #include "chrome/browser/translate/translate_tab_helper.h" |
| 37 #include "chrome/browser/ui/alternate_error_tab_observer.h" | 35 #include "chrome/browser/ui/alternate_error_tab_observer.h" |
| 38 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 36 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
| 39 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 37 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
| 40 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 38 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
| 41 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 39 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
| 42 #include "chrome/browser/ui/hung_plugin_tab_helper.h" | 40 #include "chrome/browser/ui/hung_plugin_tab_helper.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 DCHECK(contents); | 97 DCHECK(contents); |
| 100 DCHECK(!FromWebContents(contents)); | 98 DCHECK(!FromWebContents(contents)); |
| 101 | 99 |
| 102 chrome::SetViewType(contents, chrome::VIEW_TYPE_TAB_CONTENTS); | 100 chrome::SetViewType(contents, chrome::VIEW_TYPE_TAB_CONTENTS); |
| 103 | 101 |
| 104 // Stash this in the WebContents. | 102 // Stash this in the WebContents. |
| 105 contents->SetUserData(&kTabContentsUserDataKey, | 103 contents->SetUserData(&kTabContentsUserDataKey, |
| 106 new TabContentsUserData(this)); | 104 new TabContentsUserData(this)); |
| 107 | 105 |
| 108 // Create the tab helpers. | 106 // Create the tab helpers. |
| 109 // restore_tab_helper because it sets up the tab ID, and other helpers may | 107 // session_tab_helper because it sets up the tab ID, and other helpers may |
| 110 // rely on that. | 108 // rely on that. |
| 111 restore_tab_helper_.reset(new RestoreTabHelper(contents)); | 109 session_tab_helper_.reset(new SessionTabHelper(contents)); |
| 112 | 110 |
| 113 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); | 111 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); |
| 114 autofill_manager_ = new AutofillManager(this); | 112 autofill_manager_ = new AutofillManager(this); |
| 115 if (CommandLine::ForCurrentProcess()->HasSwitch( | 113 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 116 switches::kExternalAutofillPopup)) { | 114 switches::kExternalAutofillPopup)) { |
| 117 autofill_external_delegate_.reset( | 115 autofill_external_delegate_.reset( |
| 118 AutofillExternalDelegate::Create(this, autofill_manager_.get())); | 116 AutofillExternalDelegate::Create(this, autofill_manager_.get())); |
| 119 autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get()); | 117 autofill_manager_->SetExternalDelegate(autofill_external_delegate_.get()); |
| 120 autocomplete_history_manager_->SetExternalDelegate( | 118 autocomplete_history_manager_->SetExternalDelegate( |
| 121 autofill_external_delegate_.get()); | 119 autofill_external_delegate_.get()); |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 | 260 |
| 263 //////////////////////////////////////////////////////////////////////////////// | 261 //////////////////////////////////////////////////////////////////////////////// |
| 264 // WebContentsObserver overrides | 262 // WebContentsObserver overrides |
| 265 | 263 |
| 266 void TabContents::WebContentsDestroyed(WebContents* tab) { | 264 void TabContents::WebContentsDestroyed(WebContents* tab) { |
| 267 // Destruction of the WebContents should only be done by us from our | 265 // Destruction of the WebContents should only be done by us from our |
| 268 // destructor. Otherwise it's very likely we (or one of the helpers we own) | 266 // destructor. Otherwise it's very likely we (or one of the helpers we own) |
| 269 // will attempt to access the WebContents and we'll crash. | 267 // will attempt to access the WebContents and we'll crash. |
| 270 DCHECK(in_destructor_); | 268 DCHECK(in_destructor_); |
| 271 } | 269 } |
| 272 | |
| 273 void TabContents::UserAgentOverrideSet(const std::string& user_agent) { | |
| 274 #if defined(ENABLE_SESSION_SERVICE) | |
| 275 SessionService* session = | |
| 276 SessionServiceFactory::GetForProfile(profile()); | |
| 277 if (session) { | |
| 278 session->SetTabUserAgentOverride(restore_tab_helper()->window_id(), | |
| 279 restore_tab_helper()->session_id(), | |
| 280 user_agent); | |
| 281 } | |
| 282 #endif | |
| 283 } | |
| OLD | NEW |