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_message_handler.h" |
14 #include "chrome/browser/extensions/extension_tab_helper.h" | 15 #include "chrome/browser/extensions/extension_tab_helper.h" |
15 #include "chrome/browser/file_select_helper.h" | 16 #include "chrome/browser/file_select_helper.h" |
16 #include "chrome/browser/history/top_sites.h" | 17 #include "chrome/browser/history/top_sites.h" |
17 #include "chrome/browser/password_manager/password_manager.h" | 18 #include "chrome/browser/password_manager/password_manager.h" |
18 #include "chrome/browser/password_manager_delegate_impl.h" | 19 #include "chrome/browser/password_manager_delegate_impl.h" |
19 #include "chrome/browser/prefs/pref_service.h" | 20 #include "chrome/browser/prefs/pref_service.h" |
20 #include "chrome/browser/prerender/prerender_observer.h" | 21 #include "chrome/browser/prerender/prerender_observer.h" |
21 #include "chrome/browser/printing/print_preview_message_handler.h" | 22 #include "chrome/browser/printing/print_preview_message_handler.h" |
22 #include "chrome/browser/printing/print_view_manager.h" | 23 #include "chrome/browser/printing/print_view_manager.h" |
23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
(...skipping 23 matching lines...) Expand all Loading... |
47 is_starred_(false), | 48 is_starred_(false), |
48 tab_contents_(contents) { | 49 tab_contents_(contents) { |
49 DCHECK(contents); | 50 DCHECK(contents); |
50 // Stash this in the property bag so it can be retrieved without having to | 51 // Stash this in the property bag so it can be retrieved without having to |
51 // go to a Browser. | 52 // go to a Browser. |
52 property_accessor()->SetProperty(contents->property_bag(), this); | 53 property_accessor()->SetProperty(contents->property_bag(), this); |
53 | 54 |
54 // Create the tab helpers. | 55 // Create the tab helpers. |
55 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); | 56 autocomplete_history_manager_.reset(new AutocompleteHistoryManager(contents)); |
56 autofill_manager_.reset(new AutofillManager(contents)); | 57 autofill_manager_.reset(new AutofillManager(contents)); |
57 extension_tab_helper_.reset(new ExtensionTabHelper(contents)); | 58 extension_tab_helper_.reset(new ExtensionTabHelper(this)); |
58 find_tab_helper_.reset(new FindTabHelper(contents)); | 59 find_tab_helper_.reset(new FindTabHelper(contents)); |
59 password_manager_delegate_.reset(new PasswordManagerDelegateImpl(contents)); | 60 password_manager_delegate_.reset(new PasswordManagerDelegateImpl(contents)); |
60 password_manager_.reset( | 61 password_manager_.reset( |
61 new PasswordManager(contents, password_manager_delegate_.get())); | 62 new PasswordManager(contents, password_manager_delegate_.get())); |
62 search_engine_tab_helper_.reset(new SearchEngineTabHelper(contents)); | 63 search_engine_tab_helper_.reset(new SearchEngineTabHelper(contents)); |
63 | 64 |
64 // Register for notifications about URL starredness changing on any profile. | 65 // Register for notifications about URL starredness changing on any profile. |
65 registrar_.Add(this, NotificationType::URLS_STARRED, | 66 registrar_.Add(this, NotificationType::URLS_STARRED, |
66 NotificationService::AllSources()); | 67 NotificationService::AllSources()); |
67 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, | 68 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, |
68 NotificationService::AllSources()); | 69 NotificationService::AllSources()); |
69 | 70 |
70 // Create the per-tab observers. | 71 // Create the per-tab observers. |
71 dev_tools_observer_.reset(new DevToolsObserver(contents)); | 72 dev_tools_observer_.reset(new DevToolsObserver(contents)); |
| 73 extension_message_observer_.reset(new ExtensionMessageObserver(contents)); |
72 file_select_observer_.reset(new FileSelectObserver(contents)); | 74 file_select_observer_.reset(new FileSelectObserver(contents)); |
73 prerender_observer_.reset(new prerender::PrerenderObserver(contents)); | 75 prerender_observer_.reset(new prerender::PrerenderObserver(contents)); |
74 printing_.reset(new printing::PrintViewManager(contents)); | 76 printing_.reset(new printing::PrintViewManager(contents)); |
75 print_preview_.reset(new printing::PrintPreviewMessageHandler(contents)); | 77 print_preview_.reset(new printing::PrintPreviewMessageHandler(contents)); |
76 } | 78 } |
77 | 79 |
78 TabContentsWrapper::~TabContentsWrapper() { | 80 TabContentsWrapper::~TabContentsWrapper() { |
79 // We don't want any notifications while we're running our destructor. | 81 // We don't want any notifications while we're running our destructor. |
80 registrar_.RemoveAll(); | 82 registrar_.RemoveAll(); |
81 } | 83 } |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 } | 289 } |
288 | 290 |
289 void TabContentsWrapper::UpdateStarredStateForCurrentURL() { | 291 void TabContentsWrapper::UpdateStarredStateForCurrentURL() { |
290 BookmarkModel* model = tab_contents()->profile()->GetBookmarkModel(); | 292 BookmarkModel* model = tab_contents()->profile()->GetBookmarkModel(); |
291 const bool old_state = is_starred_; | 293 const bool old_state = is_starred_; |
292 is_starred_ = (model && model->IsBookmarked(tab_contents()->GetURL())); | 294 is_starred_ = (model && model->IsBookmarked(tab_contents()->GetURL())); |
293 | 295 |
294 if (is_starred_ != old_state && delegate()) | 296 if (is_starred_ != old_state && delegate()) |
295 delegate()->URLStarredChanged(this, is_starred_); | 297 delegate()->URLStarredChanged(this, is_starred_); |
296 } | 298 } |
OLD | NEW |