Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: chrome/browser/interstitials/security_interstitial_page.cc

Issue 1000333003: Properly decode IDN in interstitials (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move test commands to negative values, and control flow nit Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/interstitials/security_interstitial_page.h" 5 #include "chrome/browser/interstitials/security_interstitial_page.h"
6 6
7 #include "base/i18n/rtl.h" 7 #include "base/i18n/rtl.h"
8 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
9 #include "base/values.h" 10 #include "base/values.h"
10 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/pref_names.h"
11 #include "chrome/grit/browser_resources.h" 14 #include "chrome/grit/browser_resources.h"
12 #include "content/public/browser/interstitial_page.h" 15 #include "content/public/browser/interstitial_page.h"
13 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "net/base/net_util.h"
14 #include "ui/base/resource/resource_bundle.h" 18 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/base/webui/jstemplate_builder.h" 19 #include "ui/base/webui/jstemplate_builder.h"
16 #include "ui/base/webui/web_ui_util.h" 20 #include "ui/base/webui/web_ui_util.h"
17 21
18 SecurityInterstitialPage::SecurityInterstitialPage( 22 SecurityInterstitialPage::SecurityInterstitialPage(
19 content::WebContents* web_contents, 23 content::WebContents* web_contents,
20 const GURL& request_url) 24 const GURL& request_url)
21 : web_contents_(web_contents), 25 : web_contents_(web_contents),
22 request_url_(request_url), 26 request_url_(request_url),
23 interstitial_page_(NULL), 27 interstitial_page_(NULL),
(...skipping 24 matching lines...) Expand all
48 void SecurityInterstitialPage::Show() { 52 void SecurityInterstitialPage::Show() {
49 DCHECK(!interstitial_page_); 53 DCHECK(!interstitial_page_);
50 interstitial_page_ = content::InterstitialPage::Create( 54 interstitial_page_ = content::InterstitialPage::Create(
51 web_contents_, ShouldCreateNewNavigation(), request_url_, this); 55 web_contents_, ShouldCreateNewNavigation(), request_url_, this);
52 if (!create_view_) 56 if (!create_view_)
53 interstitial_page_->DontCreateViewForTesting(); 57 interstitial_page_->DontCreateViewForTesting();
54 interstitial_page_->Show(); 58 interstitial_page_->Show();
55 } 59 }
56 60
57 base::string16 SecurityInterstitialPage::GetFormattedHostName() const { 61 base::string16 SecurityInterstitialPage::GetFormattedHostName() const {
58 base::string16 host(base::UTF8ToUTF16(request_url_.host())); 62 std::string languages;
63 Profile* profile =
64 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
65 if (profile)
66 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
67 base::string16 host = net::IDNToUnicode(request_url_.host(), languages);
59 if (base::i18n::IsRTL()) 68 if (base::i18n::IsRTL())
60 base::i18n::WrapStringWithLTRFormatting(&host); 69 base::i18n::WrapStringWithLTRFormatting(&host);
61 return host; 70 return host;
62 } 71 }
63 72
64 std::string SecurityInterstitialPage::GetHTMLContents() { 73 std::string SecurityInterstitialPage::GetHTMLContents() {
65 base::DictionaryValue load_time_data; 74 base::DictionaryValue load_time_data;
66 PopulateInterstitialStrings(&load_time_data); 75 PopulateInterstitialStrings(&load_time_data);
67 const std::string& app_locale = g_browser_process->GetApplicationLocale(); 76 const std::string& app_locale = g_browser_process->GetApplicationLocale();
68 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data); 77 webui::SetLoadTimeDataDefaults(app_locale, &load_time_data);
69 std::string html = ResourceBundle::GetSharedInstance() 78 std::string html = ResourceBundle::GetSharedInstance()
70 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML) 79 .GetRawDataResource(IDR_SECURITY_INTERSTITIAL_HTML)
71 .as_string(); 80 .as_string();
72 webui::AppendWebUiCssTextDefaults(&html); 81 webui::AppendWebUiCssTextDefaults(&html);
73 return webui::GetI18nTemplateHtml(html, &load_time_data); 82 return webui::GetI18nTemplateHtml(html, &load_time_data);
74 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698