Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/ui/webui/about_ui.h" | 5 #include "chrome/browser/ui/webui/about_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 #include "content/public/browser/web_contents.h" | 47 #include "content/public/browser/web_contents.h" |
| 48 #include "content/public/common/content_client.h" | 48 #include "content/public/common/content_client.h" |
| 49 #include "content/public/common/process_type.h" | 49 #include "content/public/common/process_type.h" |
| 50 #include "google_apis/gaia/google_service_auth_error.h" | 50 #include "google_apis/gaia/google_service_auth_error.h" |
| 51 #include "googleurl/src/gurl.h" | 51 #include "googleurl/src/gurl.h" |
| 52 #include "grit/browser_resources.h" | 52 #include "grit/browser_resources.h" |
| 53 #include "grit/chromium_strings.h" | 53 #include "grit/chromium_strings.h" |
| 54 #include "grit/generated_resources.h" | 54 #include "grit/generated_resources.h" |
| 55 #include "grit/locale_settings.h" | 55 #include "grit/locale_settings.h" |
| 56 #include "net/base/escape.h" | 56 #include "net/base/escape.h" |
| 57 #include "net/base/load_flags.h" | |
| 57 #include "net/base/net_util.h" | 58 #include "net/base/net_util.h" |
| 58 #include "net/http/http_response_headers.h" | 59 #include "net/http/http_response_headers.h" |
| 59 #include "net/url_request/url_fetcher.h" | 60 #include "net/url_request/url_fetcher.h" |
| 60 #include "net/url_request/url_request_status.h" | 61 #include "net/url_request/url_request_status.h" |
| 61 #include "ui/base/l10n/l10n_util.h" | 62 #include "ui/base/l10n/l10n_util.h" |
| 62 #include "ui/base/resource/resource_bundle.h" | 63 #include "ui/base/resource/resource_bundle.h" |
| 63 #include "ui/webui/jstemplate_builder.h" | 64 #include "ui/webui/jstemplate_builder.h" |
| 64 #include "ui/webui/web_ui_util.h" | 65 #include "ui/webui/web_ui_util.h" |
| 65 | 66 |
| 66 #if defined(ENABLE_THEMES) | 67 #if defined(ENABLE_THEMES) |
| 67 #include "chrome/browser/ui/webui/theme_source.h" | 68 #include "chrome/browser/ui/webui/theme_source.h" |
| 68 #endif | 69 #endif |
| 69 | 70 |
| 70 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 71 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
| 71 #include "content/public/browser/zygote_host_linux.h" | 72 #include "content/public/browser/zygote_host_linux.h" |
| 72 #include "content/public/common/sandbox_linux.h" | 73 #include "content/public/common/sandbox_linux.h" |
| 73 #endif | 74 #endif |
| 74 | 75 |
| 75 #if defined(OS_WIN) | 76 #if defined(OS_WIN) |
| 76 #include "chrome/browser/enumerate_modules_model_win.h" | 77 #include "chrome/browser/enumerate_modules_model_win.h" |
| 77 #endif | 78 #endif |
| 78 | 79 |
| 79 #if defined(OS_CHROMEOS) | 80 #if defined(OS_CHROMEOS) |
| 80 #include "chrome/browser/chromeos/customization_document.h" | 81 #include "chrome/browser/chromeos/customization_document.h" |
| 81 #include "chrome/browser/chromeos/memory/oom_priority_manager.h" | 82 #include "chrome/browser/chromeos/memory/oom_priority_manager.h" |
| 82 #include "chrome/browser/ui/webui/chromeos/about_network.h" | 83 #include "chrome/browser/ui/webui/chromeos/about_network.h" |
| 84 #include "chromeos/chromeos_switches.h" | |
| 83 #endif | 85 #endif |
| 84 | 86 |
| 85 #if defined(USE_ASH) | 87 #if defined(USE_ASH) |
| 86 #include "ash/wm/frame_painter.h" | 88 #include "ash/wm/frame_painter.h" |
| 87 #include "base/strings/string_split.h" | 89 #include "base/strings/string_split.h" |
| 88 #endif | 90 #endif |
| 89 | 91 |
| 90 using base::Time; | 92 using base::Time; |
| 91 using base::TimeDelta; | 93 using base::TimeDelta; |
| 92 using content::BrowserThread; | 94 using content::BrowserThread; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 | 152 |
| 151 explicit ChromeOSOnlineTermsHandler(const FetchCallback& callback) | 153 explicit ChromeOSOnlineTermsHandler(const FetchCallback& callback) |
| 152 : fetch_callback_(callback) { | 154 : fetch_callback_(callback) { |
| 153 eula_fetcher_.reset(net::URLFetcher::Create( | 155 eula_fetcher_.reset(net::URLFetcher::Create( |
| 154 GURL(l10n_util::GetStringUTF16(IDS_EULA_POLICY_URL)), | 156 GURL(l10n_util::GetStringUTF16(IDS_EULA_POLICY_URL)), |
| 155 net::URLFetcher::GET, | 157 net::URLFetcher::GET, |
| 156 this)); | 158 this)); |
| 157 eula_fetcher_->SetRequestContext( | 159 eula_fetcher_->SetRequestContext( |
| 158 g_browser_process->system_request_context()); | 160 g_browser_process->system_request_context()); |
| 159 eula_fetcher_->AddExtraRequestHeader("Accept: text/html"); | 161 eula_fetcher_->AddExtraRequestHeader("Accept: text/html"); |
| 162 eula_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | |
| 163 net::LOAD_DO_NOT_SAVE_COOKIES | | |
| 164 net::LOAD_DISABLE_CACHE); | |
| 160 eula_fetcher_->Start(); | 165 eula_fetcher_->Start(); |
| 161 // Abort the download attempt if it takes longer than one minute. | 166 // Abort the download attempt if it takes longer than one minute. |
| 162 download_timer_.Start(FROM_HERE, | 167 download_timer_.Start(FROM_HERE, |
| 163 base::TimeDelta::FromSeconds(kOnlineTermsTimeoutSec), | 168 base::TimeDelta::FromSeconds(kOnlineTermsTimeoutSec), |
| 164 this, | 169 this, |
| 165 &ChromeOSOnlineTermsHandler::OnDownloadTimeout); | 170 &ChromeOSOnlineTermsHandler::OnDownloadTimeout); |
| 166 } | 171 } |
| 167 | 172 |
| 168 void GetResponseResult(std::string* response_string) { | 173 void GetResponseResult(std::string* response_string) { |
| 169 std::string mime_type; | 174 std::string mime_type; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 | 239 |
| 235 virtual ~ChromeOSTermsHandler() {} | 240 virtual ~ChromeOSTermsHandler() {} |
| 236 | 241 |
| 237 void StartOnUIThread() { | 242 void StartOnUIThread() { |
| 238 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 243 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 239 if (path_ == chrome::kOemEulaURLPath) { | 244 if (path_ == chrome::kOemEulaURLPath) { |
| 240 // Load local OEM EULA from the disk. | 245 // Load local OEM EULA from the disk. |
| 241 BrowserThread::PostTask( | 246 BrowserThread::PostTask( |
| 242 BrowserThread::FILE, FROM_HERE, | 247 BrowserThread::FILE, FROM_HERE, |
| 243 base::Bind(&ChromeOSTermsHandler::LoadOemEulaFileOnFileThread, this)); | 248 base::Bind(&ChromeOSTermsHandler::LoadOemEulaFileOnFileThread, this)); |
| 244 } else { | 249 } else { |
|
Evan Stade
2013/04/23 18:50:05
this looks equivalent to
if {} else if {} else {}
| |
| 245 // Try to load online version of ChromeOS terms first. | 250 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 246 // ChromeOSOnlineTermsHandler object destroys itself. | 251 chromeos::switches::kDisableOnlineEULA)) { |
| 247 new ChromeOSOnlineTermsHandler( | 252 // Fallback to the local file. |
| 248 base::Bind(&ChromeOSTermsHandler::OnOnlineEULAFetched, this)); | 253 BrowserThread::PostTask( |
| 254 BrowserThread::FILE, FROM_HERE, | |
| 255 base::Bind(&ChromeOSTermsHandler::LoadEulaFileOnFileThread, this)); | |
| 256 } else { | |
| 257 // Try to load online version of ChromeOS terms first. | |
| 258 // ChromeOSOnlineTermsHandler object destroys itself. | |
| 259 new ChromeOSOnlineTermsHandler( | |
| 260 base::Bind(&ChromeOSTermsHandler::OnOnlineEULAFetched, this)); | |
| 261 } | |
| 249 } | 262 } |
| 250 } | 263 } |
| 251 | 264 |
| 252 void OnOnlineEULAFetched(ChromeOSOnlineTermsHandler* loader) { | 265 void OnOnlineEULAFetched(ChromeOSOnlineTermsHandler* loader) { |
| 253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 254 loader->GetResponseResult(&contents_); | 267 loader->GetResponseResult(&contents_); |
| 255 if (contents_.empty()) { | 268 if (contents_.empty()) { |
| 256 // Load local ChromeOS terms from the file. | 269 // Load local ChromeOS terms from the file. |
| 257 BrowserThread::PostTask( | 270 BrowserThread::PostTask( |
| 258 BrowserThread::FILE, FROM_HERE, | 271 BrowserThread::FILE, FROM_HERE, |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1165 Profile* profile = Profile::FromWebUI(web_ui); | 1178 Profile* profile = Profile::FromWebUI(web_ui); |
| 1166 | 1179 |
| 1167 #if defined(ENABLE_THEMES) | 1180 #if defined(ENABLE_THEMES) |
| 1168 // Set up the chrome://theme/ source. | 1181 // Set up the chrome://theme/ source. |
| 1169 ThemeSource* theme = new ThemeSource(profile); | 1182 ThemeSource* theme = new ThemeSource(profile); |
| 1170 content::URLDataSource::Add(profile, theme); | 1183 content::URLDataSource::Add(profile, theme); |
| 1171 #endif | 1184 #endif |
| 1172 | 1185 |
| 1173 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); | 1186 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); |
| 1174 } | 1187 } |
| OLD | NEW |