OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/supervised_user/supervised_user_interstitial.h" | 5 #include "chrome/browser/supervised_user/supervised_user_interstitial.h" |
6 | 6 |
7 #include "base/memory/weak_ptr.h" | 7 #include "base/memory/weak_ptr.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 private: | 58 private: |
59 friend class content::WebContentsUserData<TabCloser>; | 59 friend class content::WebContentsUserData<TabCloser>; |
60 | 60 |
61 explicit TabCloser(WebContents* web_contents) | 61 explicit TabCloser(WebContents* web_contents) |
62 : web_contents_(web_contents), weak_ptr_factory_(this) { | 62 : web_contents_(web_contents), weak_ptr_factory_(this) { |
63 BrowserThread::PostTask( | 63 BrowserThread::PostTask( |
64 BrowserThread::UI, | 64 BrowserThread::UI, |
65 FROM_HERE, | 65 FROM_HERE, |
66 base::Bind(&TabCloser::CloseTabImpl, weak_ptr_factory_.GetWeakPtr())); | 66 base::Bind(&TabCloser::CloseTabImpl, weak_ptr_factory_.GetWeakPtr())); |
67 } | 67 } |
68 virtual ~TabCloser() {} | 68 ~TabCloser() override {} |
69 | 69 |
70 void CloseTabImpl() { | 70 void CloseTabImpl() { |
71 // On Android, FindBrowserWithWebContents and TabStripModel don't exist. | 71 // On Android, FindBrowserWithWebContents and TabStripModel don't exist. |
72 #if !defined(OS_ANDROID) | 72 #if !defined(OS_ANDROID) |
73 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); | 73 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); |
74 DCHECK(browser); | 74 DCHECK(browser); |
75 TabStripModel* tab_strip = browser->tab_strip_model(); | 75 TabStripModel* tab_strip = browser->tab_strip_model(); |
76 DCHECK_NE(TabStripModel::kNoTab, | 76 DCHECK_NE(TabStripModel::kNoTab, |
77 tab_strip->GetIndexOfWebContents(web_contents_)); | 77 tab_strip->GetIndexOfWebContents(web_contents_)); |
78 if (tab_strip->count() <= 1) { | 78 if (tab_strip->count() <= 1) { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 SupervisedUserServiceFactory::GetForProfile(profile_); | 299 SupervisedUserServiceFactory::GetForProfile(profile_); |
300 supervised_user_service->RemoveObserver(this); | 300 supervised_user_service->RemoveObserver(this); |
301 | 301 |
302 BrowserThread::PostTask( | 302 BrowserThread::PostTask( |
303 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request)); | 303 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request)); |
304 | 304 |
305 // After this, the WebContents may be destroyed. Make sure we don't try to use | 305 // After this, the WebContents may be destroyed. Make sure we don't try to use |
306 // it again. | 306 // it again. |
307 web_contents_ = NULL; | 307 web_contents_ = NULL; |
308 } | 308 } |
OLD | NEW |