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/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
9 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 9 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
10 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" | 10 #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_deleg
ate.h" |
| 11 #include "chrome/browser/file_select_helper.h" |
11 #include "chrome/browser/password_manager/password_manager.h" | 12 #include "chrome/browser/password_manager/password_manager.h" |
12 #include "chrome/browser/password_manager_delegate_impl.h" | 13 #include "chrome/browser/password_manager_delegate_impl.h" |
13 #include "chrome/browser/prefs/pref_service.h" | 14 #include "chrome/browser/prefs/pref_service.h" |
14 #include "chrome/browser/prerender/prerender_observer.h" | 15 #include "chrome/browser/prerender/prerender_observer.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" | 17 #include "chrome/browser/tab_contents/simple_alert_infobar_delegate.h" |
17 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 18 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
18 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" | 19 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper_delegate.h" |
20 #include "chrome/common/pref_names.h" | 21 #include "chrome/common/pref_names.h" |
(...skipping 28 matching lines...) Expand all Loading... |
49 password_manager_.reset( | 50 password_manager_.reset( |
50 new PasswordManager(contents, password_manager_delegate_.get())); | 51 new PasswordManager(contents, password_manager_delegate_.get())); |
51 search_engine_tab_helper_.reset(new SearchEngineTabHelper(contents)); | 52 search_engine_tab_helper_.reset(new SearchEngineTabHelper(contents)); |
52 | 53 |
53 // Register for notifications about URL starredness changing on any profile. | 54 // Register for notifications about URL starredness changing on any profile. |
54 registrar_.Add(this, NotificationType::URLS_STARRED, | 55 registrar_.Add(this, NotificationType::URLS_STARRED, |
55 NotificationService::AllSources()); | 56 NotificationService::AllSources()); |
56 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, | 57 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED, |
57 NotificationService::AllSources()); | 58 NotificationService::AllSources()); |
58 | 59 |
| 60 // Create the per-tab observers. |
| 61 file_select_observer_.reset(new FileSelectObserver(contents)); |
59 prerender_observer_.reset(new prerender::PrerenderObserver(contents)); | 62 prerender_observer_.reset(new prerender::PrerenderObserver(contents)); |
60 } | 63 } |
61 | 64 |
62 TabContentsWrapper::~TabContentsWrapper() { | 65 TabContentsWrapper::~TabContentsWrapper() { |
63 // We don't want any notifications while we're running our destructor. | 66 // We don't want any notifications while we're running our destructor. |
64 registrar_.RemoveAll(); | 67 registrar_.RemoveAll(); |
65 } | 68 } |
66 | 69 |
67 PropertyAccessor<TabContentsWrapper*>* TabContentsWrapper::property_accessor() { | 70 PropertyAccessor<TabContentsWrapper*>* TabContentsWrapper::property_accessor() { |
68 return g_tab_contents_wrapper_property_accessor.Pointer(); | 71 return g_tab_contents_wrapper_property_accessor.Pointer(); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 } | 257 } |
255 | 258 |
256 void TabContentsWrapper::UpdateStarredStateForCurrentURL() { | 259 void TabContentsWrapper::UpdateStarredStateForCurrentURL() { |
257 BookmarkModel* model = tab_contents()->profile()->GetBookmarkModel(); | 260 BookmarkModel* model = tab_contents()->profile()->GetBookmarkModel(); |
258 const bool old_state = is_starred_; | 261 const bool old_state = is_starred_; |
259 is_starred_ = (model && model->IsBookmarked(tab_contents()->GetURL())); | 262 is_starred_ = (model && model->IsBookmarked(tab_contents()->GetURL())); |
260 | 263 |
261 if (is_starred_ != old_state && delegate()) | 264 if (is_starred_ != old_state && delegate()) |
262 delegate()->URLStarredChanged(this, is_starred_); | 265 delegate()->URLStarredChanged(this, is_starred_); |
263 } | 266 } |
OLD | NEW |