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_wrapper.h" | 5 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.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/autocomplete_history_manager.h" | 9 #include "chrome/browser/autocomplete_history_manager.h" |
10 #include "chrome/browser/autofill/autofill_external_delegate.h" | 10 #include "chrome/browser/autofill/autofill_external_delegate.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" | 34 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" |
35 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" | 35 #include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
36 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 36 #include "chrome/browser/ui/constrained_window_tab_helper.h" |
37 #include "chrome/browser/ui/find_bar/find_tab_helper.h" | 37 #include "chrome/browser/ui/find_bar/find_tab_helper.h" |
38 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" | 38 #include "chrome/browser/ui/intents/web_intent_picker_controller.h" |
39 #include "chrome/browser/ui/pdf/pdf_tab_observer.h" | 39 #include "chrome/browser/ui/pdf/pdf_tab_observer.h" |
40 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 40 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
41 #include "chrome/browser/ui/sad_tab_observer.h" | 41 #include "chrome/browser/ui/sad_tab_observer.h" |
42 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" | 42 #include "chrome/browser/ui/search_engines/search_engine_tab_helper.h" |
43 #include "chrome/browser/ui/snapshot_tab_helper.h" | 43 #include "chrome/browser/ui/snapshot_tab_helper.h" |
| 44 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
44 #include "chrome/browser/ui/sync/tab_contents_wrapper_synced_tab_delegate.h" | 45 #include "chrome/browser/ui/sync/tab_contents_wrapper_synced_tab_delegate.h" |
45 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" | 46 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" |
46 #include "chrome/common/chrome_switches.h" | 47 #include "chrome/common/chrome_switches.h" |
47 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
48 | 49 |
49 using content::WebContents; | 50 using content::WebContents; |
50 | 51 |
51 namespace { | 52 namespace { |
52 | 53 |
53 static base::LazyInstance<base::PropertyAccessor<TabContentsWrapper*> > | 54 static base::LazyInstance<base::PropertyAccessor<TabContentsWrapper*> > |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 #if !defined(OS_ANDROID) | 128 #if !defined(OS_ANDROID) |
128 print_preview_.reset(new printing::PrintPreviewMessageHandler(contents)); | 129 print_preview_.reset(new printing::PrintPreviewMessageHandler(contents)); |
129 #endif | 130 #endif |
130 | 131 |
131 // Start the in-browser thumbnailing if the feature is enabled. | 132 // Start the in-browser thumbnailing if the feature is enabled. |
132 if (CommandLine::ForCurrentProcess()->HasSwitch( | 133 if (CommandLine::ForCurrentProcess()->HasSwitch( |
133 switches::kEnableInBrowserThumbnailing)) { | 134 switches::kEnableInBrowserThumbnailing)) { |
134 thumbnail_generation_observer_.reset(new ThumbnailGenerator); | 135 thumbnail_generation_observer_.reset(new ThumbnailGenerator); |
135 thumbnail_generation_observer_->StartThumbnailing(web_contents_.get()); | 136 thumbnail_generation_observer_->StartThumbnailing(web_contents_.get()); |
136 } | 137 } |
| 138 |
| 139 // If this is not an incognito window, setup to handle one-click login. |
| 140 #if defined(ENABLE_ONE_CLICK_SIGNIN) |
| 141 if (OneClickSigninHelper::CanOffer(contents)) |
| 142 one_click_signin_helper_.reset(new OneClickSigninHelper(contents)); |
| 143 #endif |
137 } | 144 } |
138 | 145 |
139 TabContentsWrapper::~TabContentsWrapper() { | 146 TabContentsWrapper::~TabContentsWrapper() { |
140 in_destructor_ = true; | 147 in_destructor_ = true; |
141 | 148 |
142 // Need to tear down infobars before the TabContents goes away. | 149 // Need to tear down infobars before the TabContents goes away. |
143 // TODO(avi): Can we get this handled by the tab helper itself? | 150 // TODO(avi): Can we get this handled by the tab helper itself? |
144 infobar_tab_helper_.reset(); | 151 infobar_tab_helper_.reset(); |
145 } | 152 } |
146 | 153 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 195 |
189 //////////////////////////////////////////////////////////////////////////////// | 196 //////////////////////////////////////////////////////////////////////////////// |
190 // WebContentsObserver overrides | 197 // WebContentsObserver overrides |
191 | 198 |
192 void TabContentsWrapper::WebContentsDestroyed(WebContents* tab) { | 199 void TabContentsWrapper::WebContentsDestroyed(WebContents* tab) { |
193 // Destruction of the WebContents should only be done by us from our | 200 // Destruction of the WebContents should only be done by us from our |
194 // destructor. Otherwise it's very likely we (or one of the helpers we own) | 201 // destructor. Otherwise it's very likely we (or one of the helpers we own) |
195 // will attempt to access the TabContents and we'll crash. | 202 // will attempt to access the TabContents and we'll crash. |
196 DCHECK(in_destructor_); | 203 DCHECK(in_destructor_); |
197 } | 204 } |
OLD | NEW |