| 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/ui/tab_contents/tab_contents_wrapper.h" | 5 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "chrome/browser/autocomplete_history_manager.h" | 8 #include "chrome/browser/autocomplete_history_manager.h" |
| 9 #include "chrome/browser/autofill/autofill_manager.h" | 9 #include "chrome/browser/autofill/autofill_manager.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 11 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 11 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| 12 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" | 12 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" |
| 13 #include "chrome/browser/debugger/devtools_handler.h" | 13 #include "chrome/browser/debugger/devtools_handler.h" |
| 14 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 14 #include "chrome/browser/file_select_helper.h" | 15 #include "chrome/browser/file_select_helper.h" |
| 15 #include "chrome/browser/history/top_sites.h" | 16 #include "chrome/browser/history/top_sites.h" |
| 16 #include "chrome/browser/password_manager/password_manager.h" | 17 #include "chrome/browser/password_manager/password_manager.h" |
| 17 #include "chrome/browser/password_manager_delegate_impl.h" | 18 #include "chrome/browser/password_manager_delegate_impl.h" |
| 18 #include "chrome/browser/prefs/pref_service.h" | 19 #include "chrome/browser/prefs/pref_service.h" |
| 19 #include "chrome/browser/prerender/prerender_observer.h" | 20 #include "chrome/browser/prerender/prerender_observer.h" |
| 20 #include "chrome/browser/printing/print_preview_message_handler.h" | 21 #include "chrome/browser/printing/print_preview_message_handler.h" |
| 21 #include "chrome/browser/printing/print_view_manager.h" | 22 #include "chrome/browser/printing/print_view_manager.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 23 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" | 24 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 47 tab_contents_(contents) { | 48 tab_contents_(contents) { |
| 48 DCHECK(contents); | 49 DCHECK(contents); |
| 49 // Stash this in the property bag so it can be retrieved without having to | 50 // Stash this in the property bag so it can be retrieved without having to |
| 50 // go to a Browser. | 51 // go to a Browser. |
| 51 property_accessor()->SetProperty(contents->property_bag(), this); | 52 property_accessor()->SetProperty(contents->property_bag(), this); |
| 52 | 53 |
| 53 // Create the tab helpers. | 54 // Create the tab helpers. |
| 54 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); | 55 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); |
| 55 autofill_manager_.reset(new AutofillManager(contents)); | 56 autofill_manager_.reset(new AutofillManager(contents)); |
| 56 dev_tools_tab_helper_.reset(new DevToolsTabHelper(contents)); | 57 dev_tools_tab_helper_.reset(new DevToolsTabHelper(contents)); |
| 58 extension_tab_helper_.reset(new ExtensionTabHelper(contents)); |
| 57 find_tab_helper_.reset(new FindTabHelper(contents)); | 59 find_tab_helper_.reset(new FindTabHelper(contents)); |
| 58 password_manager_delegate_.reset(new PasswordManagerDelegateImpl(contents)); | 60 password_manager_delegate_.reset(new PasswordManagerDelegateImpl(contents)); |
| 59 password_manager_.reset( | 61 password_manager_.reset( |
| 60 new PasswordManager(contents, password_manager_delegate_.get())); | 62 new PasswordManager(contents, password_manager_delegate_.get())); |
| 61 search_engine_tab_helper_.reset(new SearchEngineTabHelper(contents)); | 63 search_engine_tab_helper_.reset(new SearchEngineTabHelper(contents)); |
| 62 | 64 |
| 63 // Register for notifications about URL starredness changing on any profile. | 65 // Register for notifications about URL starredness changing on any profile. |
| 64 registrar_.Add(this, NotificationType::URLS_STARRED, | 66 registrar_.Add(this, NotificationType::URLS_STARRED, |
| 65 NotificationService::AllSources()); | 67 NotificationService::AllSources()); |
| 66 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, | 68 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 case net::LOAD_STATE_READING_RESPONSE: | 181 case net::LOAD_STATE_READING_RESPONSE: |
| 180 break; | 182 break; |
| 181 } | 183 } |
| 182 | 184 |
| 183 return string16(); | 185 return string16(); |
| 184 } | 186 } |
| 185 | 187 |
| 186 TabContentsWrapper* TabContentsWrapper::Clone() { | 188 TabContentsWrapper* TabContentsWrapper::Clone() { |
| 187 TabContents* new_contents = tab_contents()->Clone(); | 189 TabContents* new_contents = tab_contents()->Clone(); |
| 188 TabContentsWrapper* new_wrapper = new TabContentsWrapper(new_contents); | 190 TabContentsWrapper* new_wrapper = new TabContentsWrapper(new_contents); |
| 191 |
| 192 new_wrapper->extension_tab_helper()->CopyStateFrom( |
| 193 *extension_tab_helper_.get()); |
| 189 return new_wrapper; | 194 return new_wrapper; |
| 190 } | 195 } |
| 191 | 196 |
| 192 TabContentsWrapper* TabContentsWrapper::GetCurrentWrapperForContents( | 197 TabContentsWrapper* TabContentsWrapper::GetCurrentWrapperForContents( |
| 193 TabContents* contents) { | 198 TabContents* contents) { |
| 194 TabContentsWrapper** wrapper = | 199 TabContentsWrapper** wrapper = |
| 195 property_accessor()->GetProperty(contents->property_bag()); | 200 property_accessor()->GetProperty(contents->property_bag()); |
| 196 | 201 |
| 197 return wrapper ? *wrapper : NULL; | 202 return wrapper ? *wrapper : NULL; |
| 198 } | 203 } |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 } | 287 } |
| 283 | 288 |
| 284 void TabContentsWrapper::UpdateStarredStateForCurrentURL() { | 289 void TabContentsWrapper::UpdateStarredStateForCurrentURL() { |
| 285 BookmarkModel* model = tab_contents()->profile()->GetBookmarkModel(); | 290 BookmarkModel* model = tab_contents()->profile()->GetBookmarkModel(); |
| 286 const bool old_state = is_starred_; | 291 const bool old_state = is_starred_; |
| 287 is_starred_ = (model && model->IsBookmarked(tab_contents()->GetURL())); | 292 is_starred_ = (model && model->IsBookmarked(tab_contents()->GetURL())); |
| 288 | 293 |
| 289 if (is_starred_ != old_state && delegate()) | 294 if (is_starred_ != old_state && delegate()) |
| 290 delegate()->URLStarredChanged(this, is_starred_); | 295 delegate()->URLStarredChanged(this, is_starred_); |
| 291 } | 296 } |
| OLD | NEW |