| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 | 93 |
| 94 WebContents* web_contents_; | 94 WebContents* web_contents_; |
| 95 base::WeakPtrFactory<TabCloser> weak_ptr_factory_; | 95 base::WeakPtrFactory<TabCloser> weak_ptr_factory_; |
| 96 }; | 96 }; |
| 97 | 97 |
| 98 } // namespace | 98 } // namespace |
| 99 | 99 |
| 100 DEFINE_WEB_CONTENTS_USER_DATA_KEY(TabCloser); | 100 DEFINE_WEB_CONTENTS_USER_DATA_KEY(TabCloser); |
| 101 | 101 |
| 102 content::InterstitialPageDelegate::TypeID |
| 103 SupervisedUserInterstitial::kTypeForTesting = |
| 104 &SupervisedUserInterstitial::kTypeForTesting; |
| 105 |
| 102 // static | 106 // static |
| 103 void SupervisedUserInterstitial::Show( | 107 void SupervisedUserInterstitial::Show( |
| 104 WebContents* web_contents, | 108 WebContents* web_contents, |
| 105 const GURL& url, | 109 const GURL& url, |
| 106 SupervisedUserURLFilter::FilteringBehaviorReason reason, | 110 SupervisedUserURLFilter::FilteringBehaviorReason reason, |
| 107 const base::Callback<void(bool)>& callback) { | 111 const base::Callback<void(bool)>& callback) { |
| 108 SupervisedUserInterstitial* interstitial = | 112 SupervisedUserInterstitial* interstitial = |
| 109 new SupervisedUserInterstitial(web_contents, url, reason, callback); | 113 new SupervisedUserInterstitial(web_contents, url, reason, callback); |
| 110 | 114 |
| 111 // If Init() does not complete fully, immediately delete the interstitial. | 115 // If Init() does not complete fully, immediately delete the interstitial. |
| 112 if (!interstitial->Init()) | 116 if (!interstitial->Init()) |
| 113 delete interstitial; | 117 delete interstitial; |
| 114 // Otherwise |interstitial_page_| is responsible for deleting it. | 118 // Otherwise |interstitial_page_| is responsible for deleting it. |
| 115 } | 119 } |
| 116 | 120 |
| 121 content::InterstitialPageDelegate::TypeID |
| 122 SupervisedUserInterstitial::GetTypeForTesting() const { |
| 123 return SupervisedUserInterstitial::kTypeForTesting; |
| 124 } |
| 125 |
| 117 SupervisedUserInterstitial::SupervisedUserInterstitial( | 126 SupervisedUserInterstitial::SupervisedUserInterstitial( |
| 118 WebContents* web_contents, | 127 WebContents* web_contents, |
| 119 const GURL& url, | 128 const GURL& url, |
| 120 SupervisedUserURLFilter::FilteringBehaviorReason reason, | 129 SupervisedUserURLFilter::FilteringBehaviorReason reason, |
| 121 const base::Callback<void(bool)>& callback) | 130 const base::Callback<void(bool)>& callback) |
| 122 : web_contents_(web_contents), | 131 : web_contents_(web_contents), |
| 123 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), | 132 profile_(Profile::FromBrowserContext(web_contents->GetBrowserContext())), |
| 124 interstitial_page_(NULL), | 133 interstitial_page_(NULL), |
| 125 url_(url), | 134 url_(url), |
| 126 reason_(reason), | 135 reason_(reason), |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 SupervisedUserServiceFactory::GetForProfile(profile_); | 394 SupervisedUserServiceFactory::GetForProfile(profile_); |
| 386 supervised_user_service->RemoveObserver(this); | 395 supervised_user_service->RemoveObserver(this); |
| 387 | 396 |
| 388 BrowserThread::PostTask( | 397 BrowserThread::PostTask( |
| 389 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request)); | 398 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request)); |
| 390 | 399 |
| 391 // After this, the WebContents may be destroyed. Make sure we don't try to use | 400 // After this, the WebContents may be destroyed. Make sure we don't try to use |
| 392 // it again. | 401 // it again. |
| 393 web_contents_ = NULL; | 402 web_contents_ = NULL; |
| 394 } | 403 } |
| OLD | NEW |