| 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 18 matching lines...) Expand all Loading... |
| 29 #include "content/public/browser/render_view_host.h" | 29 #include "content/public/browser/render_view_host.h" |
| 30 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
| 31 #include "content/public/browser/web_contents_user_data.h" | 31 #include "content/public/browser/web_contents_user_data.h" |
| 32 #include "content/public/browser/web_ui.h" | 32 #include "content/public/browser/web_ui.h" |
| 33 #include "grit/browser_resources.h" | 33 #include "grit/browser_resources.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 34 #include "ui/base/l10n/l10n_util.h" |
| 35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
| 36 #include "ui/base/webui/jstemplate_builder.h" | 36 #include "ui/base/webui/jstemplate_builder.h" |
| 37 #include "ui/base/webui/web_ui_util.h" | 37 #include "ui/base/webui/web_ui_util.h" |
| 38 | 38 |
| 39 #if defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| 40 #include "chrome/browser/supervised_user/child_accounts/child_account_feedback_r
eporter_android.h" | 40 #include "chrome/browser/supervised_user/child_accounts/child_account_feedback_r
eporter_android.h" |
| 41 #else | 41 #else |
| 42 #include "chrome/browser/ui/browser_finder.h" | 42 #include "chrome/browser/ui/browser_finder.h" |
| 43 #include "chrome/browser/ui/chrome_pages.h" | 43 #include "chrome/browser/ui/chrome_pages.h" |
| 44 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 44 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 using content::BrowserThread; | 47 using content::BrowserThread; |
| 48 using content::WebContents; | 48 using content::WebContents; |
| 49 | 49 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 69 : web_contents_(web_contents), weak_ptr_factory_(this) { | 69 : web_contents_(web_contents), weak_ptr_factory_(this) { |
| 70 BrowserThread::PostTask( | 70 BrowserThread::PostTask( |
| 71 BrowserThread::UI, | 71 BrowserThread::UI, |
| 72 FROM_HERE, | 72 FROM_HERE, |
| 73 base::Bind(&TabCloser::CloseTabImpl, weak_ptr_factory_.GetWeakPtr())); | 73 base::Bind(&TabCloser::CloseTabImpl, weak_ptr_factory_.GetWeakPtr())); |
| 74 } | 74 } |
| 75 ~TabCloser() override {} | 75 ~TabCloser() override {} |
| 76 | 76 |
| 77 void CloseTabImpl() { | 77 void CloseTabImpl() { |
| 78 // On Android, FindBrowserWithWebContents and TabStripModel don't exist. | 78 // On Android, FindBrowserWithWebContents and TabStripModel don't exist. |
| 79 #if !defined(OS_ANDROID) | 79 #if !defined(OS_ANDROID) && !defined(USE_AURA) |
| 80 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); | 80 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); |
| 81 DCHECK(browser); | 81 DCHECK(browser); |
| 82 TabStripModel* tab_strip = browser->tab_strip_model(); | 82 TabStripModel* tab_strip = browser->tab_strip_model(); |
| 83 DCHECK_NE(TabStripModel::kNoTab, | 83 DCHECK_NE(TabStripModel::kNoTab, |
| 84 tab_strip->GetIndexOfWebContents(web_contents_)); | 84 tab_strip->GetIndexOfWebContents(web_contents_)); |
| 85 if (tab_strip->count() <= 1) { | 85 if (tab_strip->count() <= 1) { |
| 86 // Don't close the last tab in the window. | 86 // Don't close the last tab in the window. |
| 87 web_contents_->RemoveUserData(UserDataKey()); | 87 web_contents_->RemoveUserData(UserDataKey()); |
| 88 return; | 88 return; |
| 89 } | 89 } |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 url_, base::Bind(&SupervisedUserInterstitial::OnAccessRequestAdded, | 319 url_, base::Bind(&SupervisedUserInterstitial::OnAccessRequestAdded, |
| 320 weak_ptr_factory_.GetWeakPtr())); | 320 weak_ptr_factory_.GetWeakPtr())); |
| 321 return; | 321 return; |
| 322 } | 322 } |
| 323 | 323 |
| 324 if (command == "\"feedback\"") { | 324 if (command == "\"feedback\"") { |
| 325 base::string16 reason = l10n_util::GetStringUTF16( | 325 base::string16 reason = l10n_util::GetStringUTF16( |
| 326 SupervisedUserURLFilter::GetBlockMessageID(reason_)); | 326 SupervisedUserURLFilter::GetBlockMessageID(reason_)); |
| 327 std::string message = l10n_util::GetStringFUTF8( | 327 std::string message = l10n_util::GetStringFUTF8( |
| 328 IDS_BLOCK_INTERSTITIAL_DEFAULT_FEEDBACK_TEXT, reason); | 328 IDS_BLOCK_INTERSTITIAL_DEFAULT_FEEDBACK_TEXT, reason); |
| 329 #if defined(OS_ANDROID) | 329 #if defined(OS_ANDROID) && !defined(USE_AURA) |
| 330 ReportChildAccountFeedback(web_contents_, message, url_); | 330 ReportChildAccountFeedback(web_contents_, message, url_); |
| 331 #else | 331 #else |
| 332 chrome::ShowFeedbackPage(chrome::FindBrowserWithWebContents(web_contents_), | 332 chrome::ShowFeedbackPage(chrome::FindBrowserWithWebContents(web_contents_), |
| 333 message, std::string()); | 333 message, std::string()); |
| 334 #endif | 334 #endif |
| 335 return; | 335 return; |
| 336 } | 336 } |
| 337 | 337 |
| 338 NOTREACHED(); | 338 NOTREACHED(); |
| 339 } | 339 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 SupervisedUserServiceFactory::GetForProfile(profile_); | 386 SupervisedUserServiceFactory::GetForProfile(profile_); |
| 387 supervised_user_service->RemoveObserver(this); | 387 supervised_user_service->RemoveObserver(this); |
| 388 | 388 |
| 389 BrowserThread::PostTask( | 389 BrowserThread::PostTask( |
| 390 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request)); | 390 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request)); |
| 391 | 391 |
| 392 // After this, the WebContents may be destroyed. Make sure we don't try to use | 392 // After this, the WebContents may be destroyed. Make sure we don't try to use |
| 393 // it again. | 393 // it again. |
| 394 web_contents_ = NULL; | 394 web_contents_ = NULL; |
| 395 } | 395 } |
| OLD | NEW |