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. |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 } | 347 } |
344 | 348 |
345 void SupervisedUserInterstitial::OnProceed() { | 349 void SupervisedUserInterstitial::OnProceed() { |
346 DispatchContinueRequest(true); | 350 DispatchContinueRequest(true); |
347 } | 351 } |
348 | 352 |
349 void SupervisedUserInterstitial::OnDontProceed() { | 353 void SupervisedUserInterstitial::OnDontProceed() { |
350 DispatchContinueRequest(false); | 354 DispatchContinueRequest(false); |
351 } | 355 } |
352 | 356 |
| 357 content::InterstitialPageDelegate::TypeID |
| 358 SupervisedUserInterstitial::GetTypeForTesting() const { |
| 359 return SupervisedUserInterstitial::kTypeForTesting; |
| 360 } |
| 361 |
353 void SupervisedUserInterstitial::OnURLFilterChanged() { | 362 void SupervisedUserInterstitial::OnURLFilterChanged() { |
354 if (ShouldProceed()) | 363 if (ShouldProceed()) |
355 interstitial_page_->Proceed(); | 364 interstitial_page_->Proceed(); |
356 } | 365 } |
357 | 366 |
358 void SupervisedUserInterstitial::OnAccessRequestAdded(bool success) { | 367 void SupervisedUserInterstitial::OnAccessRequestAdded(bool success) { |
359 VLOG(1) << "Sent access request for " << url_.spec() | 368 VLOG(1) << "Sent access request for " << url_.spec() |
360 << (success ? " successfully" : " unsuccessfully"); | 369 << (success ? " successfully" : " unsuccessfully"); |
361 std::string jsFunc = | 370 std::string jsFunc = |
362 base::StringPrintf("setRequestStatus(%s);", success ? "true" : "false"); | 371 base::StringPrintf("setRequestStatus(%s);", success ? "true" : "false"); |
(...skipping 22 matching lines...) Expand all 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 |