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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 using content::WebContents; | 96 using content::WebContents; |
| 97 | 97 |
| 98 namespace { | 98 namespace { |
| 99 | 99 |
| 100 const char kCreditsJsPath[] = "credits.js"; | 100 const char kCreditsJsPath[] = "credits.js"; |
| 101 const char kMemoryJsPath[] = "memory.js"; | 101 const char kMemoryJsPath[] = "memory.js"; |
| 102 const char kMemoryCssPath[] = "about_memory.css"; | 102 const char kMemoryCssPath[] = "about_memory.css"; |
| 103 const char kStatsJsPath[] = "stats.js"; | 103 const char kStatsJsPath[] = "stats.js"; |
| 104 const char kStringsJsPath[] = "strings.js"; | 104 const char kStringsJsPath[] = "strings.js"; |
| 105 // chrome://terms falls back to offline page after kOnlineTermsTimeoutSec. | 105 // chrome://terms falls back to offline page after kOnlineTermsTimeoutSec. |
| 106 const int kOnlineTermsTimeoutSec = 10; | 106 const int kOnlineTermsTimeoutSec = 7; |
| 107 | 107 |
| 108 // When you type about:memory, it actually loads this intermediate URL that | 108 // When you type about:memory, it actually loads this intermediate URL that |
| 109 // redirects you to the final page. This avoids the problem where typing | 109 // redirects you to the final page. This avoids the problem where typing |
| 110 // "about:memory" on the new tab page or any other page where a process | 110 // "about:memory" on the new tab page or any other page where a process |
| 111 // transition would occur to the about URL will cause some confusion. | 111 // transition would occur to the about URL will cause some confusion. |
| 112 // | 112 // |
| 113 // The problem is that during the processing of the memory page, there are two | 113 // The problem is that during the processing of the memory page, there are two |
| 114 // processes active, the original and the destination one. This can create the | 114 // processes active, the original and the destination one. This can create the |
| 115 // impression that we're using more resources than we actually are. This | 115 // impression that we're using more resources than we actually are. This |
| 116 // redirect solves the problem by eliminating the process transition during the | 116 // redirect solves the problem by eliminating the process transition during the |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 138 void BindProcessMetrics(DictionaryValue* data, | 138 void BindProcessMetrics(DictionaryValue* data, |
| 139 ProcessMemoryInformation* info); | 139 ProcessMemoryInformation* info); |
| 140 void AppendProcess(ListValue* child_data, ProcessMemoryInformation* info); | 140 void AppendProcess(ListValue* child_data, ProcessMemoryInformation* info); |
| 141 | 141 |
| 142 content::URLDataSource::GotDataCallback callback_; | 142 content::URLDataSource::GotDataCallback callback_; |
| 143 | 143 |
| 144 DISALLOW_COPY_AND_ASSIGN(AboutMemoryHandler); | 144 DISALLOW_COPY_AND_ASSIGN(AboutMemoryHandler); |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 #if defined(OS_CHROMEOS) | 147 #if defined(OS_CHROMEOS) |
| 148 | |
| 148 // Helper class that fetches the online Chrome OS terms. Empty string is | 149 // Helper class that fetches the online Chrome OS terms. Empty string is |
| 149 // returned once fetching failed or exceeded |kOnlineTermsTimeoutSec|. | 150 // returned once fetching failed or exceeded |kOnlineTermsTimeoutSec|. |
| 150 class ChromeOSOnlineTermsHandler : public net::URLFetcherDelegate { | 151 class ChromeOSOnlineTermsHandler : public net::URLFetcherDelegate { |
| 151 public: | 152 public: |
| 152 typedef base::Callback<void (ChromeOSOnlineTermsHandler*)> FetchCallback; | 153 typedef base::Callback<void (ChromeOSOnlineTermsHandler*)> FetchCallback; |
| 153 | 154 |
| 154 explicit ChromeOSOnlineTermsHandler(const FetchCallback& callback) | 155 explicit ChromeOSOnlineTermsHandler(const FetchCallback& callback, |
| 156 const std::string& locale) | |
| 155 : fetch_callback_(callback) { | 157 : fetch_callback_(callback) { |
| 156 eula_fetcher_.reset(net::URLFetcher::Create( | 158 std::string eula_URL = base::StringPrintf(chrome::kOnlineEulaURLPath, |
|
Evan Stade
2013/05/07 21:52:17
I thought the idea was to rely on acceptlanguages
vasilii
2013/05/08 07:36:30
No, they have prepared a list of URL in Chrome for
| |
| 157 GURL(l10n_util::GetStringUTF16(IDS_EULA_POLICY_URL)), | 159 locale.c_str()); |
| 158 net::URLFetcher::GET, | 160 eula_fetcher_.reset(net::URLFetcher::Create(GURL(eula_URL), |
| 159 this)); | 161 net::URLFetcher::GET, |
| 162 this)); | |
| 160 eula_fetcher_->SetRequestContext( | 163 eula_fetcher_->SetRequestContext( |
| 161 g_browser_process->system_request_context()); | 164 g_browser_process->system_request_context()); |
| 162 eula_fetcher_->AddExtraRequestHeader("Accept: text/html"); | 165 eula_fetcher_->AddExtraRequestHeader("Accept: text/html"); |
| 163 eula_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 166 eula_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 164 net::LOAD_DO_NOT_SAVE_COOKIES | | 167 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 165 net::LOAD_DISABLE_CACHE); | 168 net::LOAD_DISABLE_CACHE); |
| 166 eula_fetcher_->Start(); | 169 eula_fetcher_->Start(); |
| 167 // Abort the download attempt if it takes longer than one minute. | 170 // Abort the download attempt if it takes longer than one minute. |
| 168 download_timer_.Start(FROM_HERE, | 171 download_timer_.Start(FROM_HERE, |
| 169 base::TimeDelta::FromSeconds(kOnlineTermsTimeoutSec), | 172 base::TimeDelta::FromSeconds(kOnlineTermsTimeoutSec), |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 250 } else if (CommandLine::ForCurrentProcess()->HasSwitch( | 253 } else if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 251 chromeos::switches::kDisableOnlineEULA)) { | 254 chromeos::switches::kDisableOnlineEULA)) { |
| 252 // Fallback to the local file. | 255 // Fallback to the local file. |
| 253 BrowserThread::PostTask( | 256 BrowserThread::PostTask( |
| 254 BrowserThread::FILE, FROM_HERE, | 257 BrowserThread::FILE, FROM_HERE, |
| 255 base::Bind(&ChromeOSTermsHandler::LoadEulaFileOnFileThread, this)); | 258 base::Bind(&ChromeOSTermsHandler::LoadEulaFileOnFileThread, this)); |
| 256 } else { | 259 } else { |
| 257 // Try to load online version of ChromeOS terms first. | 260 // Try to load online version of ChromeOS terms first. |
| 258 // ChromeOSOnlineTermsHandler object destroys itself. | 261 // ChromeOSOnlineTermsHandler object destroys itself. |
| 259 new ChromeOSOnlineTermsHandler( | 262 new ChromeOSOnlineTermsHandler( |
| 260 base::Bind(&ChromeOSTermsHandler::OnOnlineEULAFetched, this)); | 263 base::Bind(&ChromeOSTermsHandler::OnOnlineEULAFetched, this), |
| 264 locale_); | |
| 261 } | 265 } |
| 262 } | 266 } |
| 263 | 267 |
| 264 void OnOnlineEULAFetched(ChromeOSOnlineTermsHandler* loader) { | 268 void OnOnlineEULAFetched(ChromeOSOnlineTermsHandler* loader) { |
| 265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 269 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 266 loader->GetResponseResult(&contents_); | 270 loader->GetResponseResult(&contents_); |
| 267 if (contents_.empty()) { | 271 if (contents_.empty()) { |
| 268 // Load local ChromeOS terms from the file. | 272 // Load local ChromeOS terms from the file. |
| 269 BrowserThread::PostTask( | 273 BrowserThread::PostTask( |
| 270 BrowserThread::FILE, FROM_HERE, | 274 BrowserThread::FILE, FROM_HERE, |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1184 Profile* profile = Profile::FromWebUI(web_ui); | 1188 Profile* profile = Profile::FromWebUI(web_ui); |
| 1185 | 1189 |
| 1186 #if defined(ENABLE_THEMES) | 1190 #if defined(ENABLE_THEMES) |
| 1187 // Set up the chrome://theme/ source. | 1191 // Set up the chrome://theme/ source. |
| 1188 ThemeSource* theme = new ThemeSource(profile); | 1192 ThemeSource* theme = new ThemeSource(profile); |
| 1189 content::URLDataSource::Add(profile, theme); | 1193 content::URLDataSource::Add(profile, theme); |
| 1190 #endif | 1194 #endif |
| 1191 | 1195 |
| 1192 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); | 1196 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); |
| 1193 } | 1197 } |
| OLD | NEW |