| 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" |
| 11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
| 12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/infobars/infobar_service.h" | 15 #include "chrome/browser/infobars/infobar_service.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/supervised_user/supervised_user_service.h" | 17 #include "chrome/browser/supervised_user/supervised_user_service.h" |
| 17 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" | 18 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" |
| 18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 19 #include "chrome/grit/generated_resources.h" | 20 #include "chrome/grit/generated_resources.h" |
| 20 #include "components/infobars/core/infobar.h" | 21 #include "components/infobars/core/infobar.h" |
| 21 #include "components/infobars/core/infobar_delegate.h" | 22 #include "components/infobars/core/infobar_delegate.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/interstitial_page.h" | 24 #include "content/public/browser/interstitial_page.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 } | 261 } |
| 261 } else { | 262 } else { |
| 262 request_sent_message = l10n_util::GetStringFUTF16( | 263 request_sent_message = l10n_util::GetStringFUTF16( |
| 263 IDS_BLOCK_INTERSTITIAL_REQUEST_SENT_MESSAGE, custodian); | 264 IDS_BLOCK_INTERSTITIAL_REQUEST_SENT_MESSAGE, custodian); |
| 264 request_failed_message = l10n_util::GetStringFUTF16( | 265 request_failed_message = l10n_util::GetStringFUTF16( |
| 265 IDS_BLOCK_INTERSTITIAL_REQUEST_FAILED_MESSAGE, custodian); | 266 IDS_BLOCK_INTERSTITIAL_REQUEST_FAILED_MESSAGE, custodian); |
| 266 } | 267 } |
| 267 strings.SetString("requestSentMessage", request_sent_message); | 268 strings.SetString("requestSentMessage", request_sent_message); |
| 268 strings.SetString("requestFailedMessage", request_failed_message); | 269 strings.SetString("requestFailedMessage", request_failed_message); |
| 269 | 270 |
| 270 webui::SetFontAndTextDirection(&strings); | 271 const std::string& app_locale = g_browser_process->GetApplicationLocale(); |
| 272 webui::SetLoadTimeDataDefaults(app_locale, &strings); |
| 271 | 273 |
| 272 base::StringPiece html(ResourceBundle::GetSharedInstance().GetRawDataResource( | 274 base::StringPiece html(ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 273 IDR_SUPERVISED_USER_BLOCK_INTERSTITIAL_HTML)); | 275 IDR_SUPERVISED_USER_BLOCK_INTERSTITIAL_HTML)); |
| 274 | 276 |
| 275 return webui::GetI18nTemplateHtml(html, &strings); | 277 return webui::GetI18nTemplateHtml(html, &strings); |
| 276 } | 278 } |
| 277 | 279 |
| 278 void SupervisedUserInterstitial::CommandReceived(const std::string& command) { | 280 void SupervisedUserInterstitial::CommandReceived(const std::string& command) { |
| 279 // For use in histograms. | 281 // For use in histograms. |
| 280 enum Commands { | 282 enum Commands { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 SupervisedUserServiceFactory::GetForProfile(profile_); | 382 SupervisedUserServiceFactory::GetForProfile(profile_); |
| 381 supervised_user_service->RemoveObserver(this); | 383 supervised_user_service->RemoveObserver(this); |
| 382 | 384 |
| 383 BrowserThread::PostTask( | 385 BrowserThread::PostTask( |
| 384 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request)); | 386 BrowserThread::IO, FROM_HERE, base::Bind(callback_, continue_request)); |
| 385 | 387 |
| 386 // After this, the WebContents may be destroyed. Make sure we don't try to use | 388 // After this, the WebContents may be destroyed. Make sure we don't try to use |
| 387 // it again. | 389 // it again. |
| 388 web_contents_ = NULL; | 390 web_contents_ = NULL; |
| 389 } | 391 } |
| OLD | NEW |