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

Side by Side Diff: chrome/browser/ui/webui/about_ui.cc

Issue 10387010: Select theme resources from ResourceBundle at requested scale factor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with master. Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 #include "content/public/common/process_type.h" 58 #include "content/public/common/process_type.h"
59 #include "crypto/nss_util.h" 59 #include "crypto/nss_util.h"
60 #include "googleurl/src/gurl.h" 60 #include "googleurl/src/gurl.h"
61 #include "grit/browser_resources.h" 61 #include "grit/browser_resources.h"
62 #include "grit/chromium_strings.h" 62 #include "grit/chromium_strings.h"
63 #include "grit/generated_resources.h" 63 #include "grit/generated_resources.h"
64 #include "grit/locale_settings.h" 64 #include "grit/locale_settings.h"
65 #include "net/base/escape.h" 65 #include "net/base/escape.h"
66 #include "net/base/net_util.h" 66 #include "net/base/net_util.h"
67 #include "ui/base/l10n/l10n_util.h" 67 #include "ui/base/l10n/l10n_util.h"
68 #include "ui/base/layout.h"
68 #include "ui/base/resource/resource_bundle.h" 69 #include "ui/base/resource/resource_bundle.h"
69 #include "v8/include/v8.h" 70 #include "v8/include/v8.h"
70 #include "webkit/glue/user_agent.h" 71 #include "webkit/glue/user_agent.h"
71 #include "webkit/glue/webkit_glue.h" 72 #include "webkit/glue/webkit_glue.h"
72 #include "webkit/plugins/webplugininfo.h" 73 #include "webkit/plugins/webplugininfo.h"
73 74
74 #if defined(OS_LINUX) || defined(OS_OPENBSD) 75 #if defined(OS_LINUX) || defined(OS_OPENBSD)
76 #include "content/public/browser/zygote_host_linux.h"
75 #include "content/public/common/sandbox_linux.h" 77 #include "content/public/common/sandbox_linux.h"
76 #include "content/public/browser/zygote_host_linux.h"
77 #endif 78 #endif
78 79
79 #if defined(OS_WIN) 80 #if defined(OS_WIN)
80 #include "chrome/browser/enumerate_modules_model_win.h" 81 #include "chrome/browser/enumerate_modules_model_win.h"
81 #endif 82 #endif
82 83
83 #if defined(OS_CHROMEOS) 84 #if defined(OS_CHROMEOS)
84 #include "chrome/browser/chromeos/cros/cros_library.h" 85 #include "chrome/browser/chromeos/cros/cros_library.h"
85 #include "chrome/browser/chromeos/cros/cryptohome_library.h" 86 #include "chrome/browser/chromeos/cros/cryptohome_library.h"
86 #include "chrome/browser/chromeos/cros/network_library.h" 87 #include "chrome/browser/chromeos/cros/network_library.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 BrowserThread::UI, FROM_HERE, 240 BrowserThread::UI, FROM_HERE,
240 base::Bind(&ChromeOSTermsHandler::ResponseOnUIThread, this)); 241 base::Bind(&ChromeOSTermsHandler::ResponseOnUIThread, this));
241 } 242 }
242 243
243 void ResponseOnUIThread() { 244 void ResponseOnUIThread() {
244 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 245 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
245 // If we fail to load Chrome OS EULA from disk, load it from resources. 246 // If we fail to load Chrome OS EULA from disk, load it from resources.
246 // Do nothing if OEM EULA load failed. 247 // Do nothing if OEM EULA load failed.
247 if (contents_.empty() && path_ != chrome::kOemEulaURLPath) { 248 if (contents_.empty() && path_ != chrome::kOemEulaURLPath) {
248 contents_ = ResourceBundle::GetSharedInstance().GetRawDataResource( 249 contents_ = ResourceBundle::GetSharedInstance().GetRawDataResource(
249 IDR_TERMS_HTML).as_string(); 250 IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE).as_string();
250 } 251 }
251 source_->FinishDataRequest(contents_, request_id_); 252 source_->FinishDataRequest(contents_, request_id_);
252 } 253 }
253 254
254 // Where the results are fed to. 255 // Where the results are fed to.
255 scoped_refptr<AboutUIHTMLSource> source_; 256 scoped_refptr<AboutUIHTMLSource> source_;
256 257
257 // Path in the URL. 258 // Path in the URL.
258 std::string path_; 259 std::string path_;
259 260
(...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want 831 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want
831 // the refcount to be greater than 0. 832 // the refcount to be greater than 0.
832 scoped_refptr<AboutMemoryHandler> 833 scoped_refptr<AboutMemoryHandler>
833 handler(new AboutMemoryHandler(source, request_id)); 834 handler(new AboutMemoryHandler(source, request_id));
834 // TODO(jamescook): Maybe this shouldn't update UMA? 835 // TODO(jamescook): Maybe this shouldn't update UMA?
835 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS); 836 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS);
836 } else { 837 } else {
837 source->FinishDataRequest( 838 source->FinishDataRequest(
838 ResourceBundle::GetSharedInstance().GetRawDataResource( 839 ResourceBundle::GetSharedInstance().GetRawDataResource(
839 path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS : 840 path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS :
840 IDR_ABOUT_MEMORY_HTML).as_string(), request_id); 841 IDR_ABOUT_MEMORY_HTML,
842 ui::SCALE_FACTOR_NONE).as_string(), request_id);
841 } 843 }
842 } 844 }
843 845
844 // Handler for filling in the "about:stats" page, as called by the browser's 846 // Handler for filling in the "about:stats" page, as called by the browser's
845 // About handler processing. 847 // About handler processing.
846 // |query| is roughly the query string of the about:stats URL. 848 // |query| is roughly the query string of the about:stats URL.
847 // Returns a string containing the HTML to render for the about:stats page. 849 // Returns a string containing the HTML to render for the about:stats page.
848 // Conditional Output: 850 // Conditional Output:
849 // if |query| is "json", returns a JSON format of all counters. 851 // if |query| is "json", returns a JSON format of all counters.
850 // if |query| is "raw", returns plain text of counter deltas. 852 // if |query| is "raw", returns plain text of counter deltas.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 data.append(name); 983 data.append(name);
982 data.append(":"); 984 data.append(":");
983 data.append(base::IntToString(delta)); 985 data.append(base::IntToString(delta));
984 data.append("\n"); 986 data.append("\n");
985 } 987 }
986 } 988 }
987 data.append("</pre>"); 989 data.append("</pre>");
988 } else { 990 } else {
989 // Get about_stats.html/js from resource bundle. 991 // Get about_stats.html/js from resource bundle.
990 data = ResourceBundle::GetSharedInstance().GetRawDataResource( 992 data = ResourceBundle::GetSharedInstance().GetRawDataResource(
991 (query == kStatsJsPath ? IDR_ABOUT_STATS_JS : IDR_ABOUT_STATS_HTML)). 993 (query == kStatsJsPath ? IDR_ABOUT_STATS_JS : IDR_ABOUT_STATS_HTML),
992 as_string(); 994 ui::SCALE_FACTOR_NONE).as_string();
993 995
994 if (query != kStatsJsPath) { 996 if (query != kStatsJsPath) {
995 // Clear the timer list since we stored the data in the timers list 997 // Clear the timer list since we stored the data in the timers list
996 // as well. 998 // as well.
997 for (int index = static_cast<int>(timers->GetSize())-1; index >= 0; 999 for (int index = static_cast<int>(timers->GetSize())-1; index >= 0;
998 index--) { 1000 index--) {
999 Value* value; 1001 Value* value;
1000 timers->Remove(index, &value); 1002 timers->Remove(index, &value);
1001 // We don't care about the value pointer; it's still tracked 1003 // We don't care about the value pointer; it's still tracked
1002 // on the counters list. 1004 // on the counters list.
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1077 1079
1078 AppendFooter(&data); 1080 AppendFooter(&data);
1079 return data; 1081 return data;
1080 } 1082 }
1081 #endif 1083 #endif
1082 1084
1083 std::string AboutVersionStaticContent(const std::string& query) { 1085 std::string AboutVersionStaticContent(const std::string& query) {
1084 return ResourceBundle::GetSharedInstance().GetRawDataResource( 1086 return ResourceBundle::GetSharedInstance().GetRawDataResource(
1085 query == kVersionJsPath ? 1087 query == kVersionJsPath ?
1086 IDR_ABOUT_VERSION_JS : 1088 IDR_ABOUT_VERSION_JS :
1087 IDR_ABOUT_VERSION_HTML).as_string(); 1089 IDR_ABOUT_VERSION_HTML, ui::SCALE_FACTOR_NONE).as_string();
1088 } 1090 }
1089 1091
1090 std::string AboutVersionStrings(DictionaryValue* localized_strings, 1092 std::string AboutVersionStrings(DictionaryValue* localized_strings,
1091 Profile* profile) { 1093 Profile* profile) {
1092 DCHECK(profile); 1094 DCHECK(profile);
1093 localized_strings->SetString("title", 1095 localized_strings->SetString("title",
1094 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_TITLE)); 1096 l10n_util::GetStringUTF16(IDS_ABOUT_VERSION_TITLE));
1095 chrome::VersionInfo version_info; 1097 chrome::VersionInfo version_info;
1096 1098
1097 localized_strings->SetString("name", 1099 localized_strings->SetString("name",
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
1378 bool is_incognito, 1380 bool is_incognito,
1379 int request_id) { 1381 int request_id) {
1380 std::string response; 1382 std::string response;
1381 std::string host = source_name(); 1383 std::string host = source_name();
1382 // Add your data source here, in alphabetical order. 1384 // Add your data source here, in alphabetical order.
1383 if (host == chrome::kChromeUIChromeURLsHost) { 1385 if (host == chrome::kChromeUIChromeURLsHost) {
1384 response = ChromeURLs(); 1386 response = ChromeURLs();
1385 } else if (host == chrome::kChromeUICreditsHost) { 1387 } else if (host == chrome::kChromeUICreditsHost) {
1386 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML; 1388 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML;
1387 response = ResourceBundle::GetSharedInstance().GetRawDataResource( 1389 response = ResourceBundle::GetSharedInstance().GetRawDataResource(
1388 idr).as_string(); 1390 idr, ui::SCALE_FACTOR_NONE).as_string();
1389 #if defined(OS_CHROMEOS) 1391 #if defined(OS_CHROMEOS)
1390 } else if (host == chrome::kChromeUICryptohomeHost) { 1392 } else if (host == chrome::kChromeUICryptohomeHost) {
1391 FinishCryptohomeDataRequest(this, path, request_id); 1393 FinishCryptohomeDataRequest(this, path, request_id);
1392 return; 1394 return;
1393 } else if (host == chrome::kChromeUIDiscardsHost) { 1395 } else if (host == chrome::kChromeUIDiscardsHost) {
1394 response = AboutDiscards(path); 1396 response = AboutDiscards(path);
1395 #endif 1397 #endif
1396 #if defined(USE_ASH) 1398 #if defined(USE_ASH)
1397 } else if (host == chrome::kChromeUITransparencyHost) { 1399 } else if (host == chrome::kChromeUITransparencyHost) {
1398 response = AboutTransparency(path); 1400 response = AboutTransparency(path);
(...skipping 10 matching lines...) Expand all
1409 } else if (host == chrome::kChromeUIMemoryHost) { 1411 } else if (host == chrome::kChromeUIMemoryHost) {
1410 response = GetAboutMemoryRedirectResponse(profile()); 1412 response = GetAboutMemoryRedirectResponse(profile());
1411 } else if (host == chrome::kChromeUIMemoryRedirectHost) { 1413 } else if (host == chrome::kChromeUIMemoryRedirectHost) {
1412 FinishMemoryDataRequest(path, this, request_id); 1414 FinishMemoryDataRequest(path, this, request_id);
1413 return; 1415 return;
1414 #if defined(OS_CHROMEOS) 1416 #if defined(OS_CHROMEOS)
1415 } else if (host == chrome::kChromeUINetworkHost) { 1417 } else if (host == chrome::kChromeUINetworkHost) {
1416 response = AboutNetwork(path); 1418 response = AboutNetwork(path);
1417 } else if (host == chrome::kChromeUIOSCreditsHost) { 1419 } else if (host == chrome::kChromeUIOSCreditsHost) {
1418 response = ResourceBundle::GetSharedInstance().GetRawDataResource( 1420 response = ResourceBundle::GetSharedInstance().GetRawDataResource(
1419 IDR_OS_CREDITS_HTML).as_string(); 1421 IDR_OS_CREDITS_HTML, ui::SCALE_FACTOR_NONE).as_string();
1420 #endif 1422 #endif
1421 #if defined(OS_LINUX) || defined(OS_OPENBSD) 1423 #if defined(OS_LINUX) || defined(OS_OPENBSD)
1422 } else if (host == chrome::kChromeUISandboxHost) { 1424 } else if (host == chrome::kChromeUISandboxHost) {
1423 response = AboutSandbox(); 1425 response = AboutSandbox();
1424 #endif 1426 #endif
1425 } else if (host == chrome::kChromeUIStatsHost) { 1427 } else if (host == chrome::kChromeUIStatsHost) {
1426 response = AboutStats(path); 1428 response = AboutStats(path);
1427 } else if (host == chrome::kChromeUITermsHost) { 1429 } else if (host == chrome::kChromeUITermsHost) {
1428 #if defined(OS_CHROMEOS) 1430 #if defined(OS_CHROMEOS)
1429 ChromeOSTermsHandler::Start(this, path, request_id); 1431 ChromeOSTermsHandler::Start(this, path, request_id);
1430 return; 1432 return;
1431 #else 1433 #else
1432 response = ResourceBundle::GetSharedInstance().GetRawDataResource( 1434 response = ResourceBundle::GetSharedInstance().GetRawDataResource(
1433 IDR_TERMS_HTML).as_string(); 1435 IDR_TERMS_HTML, ui::SCALE_FACTOR_NONE).as_string();
1434 #endif 1436 #endif
1435 } else if (host == chrome::kChromeUIVersionHost) { 1437 } else if (host == chrome::kChromeUIVersionHost) {
1436 if (path == kStringsJsPath) { 1438 if (path == kStringsJsPath) {
1437 // The Flash version information is needed on this page, so make sure 1439 // The Flash version information is needed on this page, so make sure
1438 // the plugins are loaded. 1440 // the plugins are loaded.
1439 PluginService::GetInstance()->GetPlugins( 1441 PluginService::GetInstance()->GetPlugins(
1440 base::Bind(&HandleAboutVersionStrings, 1442 base::Bind(&HandleAboutVersionStrings,
1441 make_scoped_refptr(this), request_id)); 1443 make_scoped_refptr(this), request_id));
1442 return; 1444 return;
1443 } else { 1445 } else {
(...skipping 23 matching lines...) Expand all
1467 1469
1468 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) 1470 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name)
1469 : WebUIController(web_ui) { 1471 : WebUIController(web_ui) {
1470 Profile* profile = Profile::FromWebUI(web_ui); 1472 Profile* profile = Profile::FromWebUI(web_ui);
1471 ChromeURLDataManager::DataSource* source = 1473 ChromeURLDataManager::DataSource* source =
1472 new AboutUIHTMLSource(name, profile); 1474 new AboutUIHTMLSource(name, profile);
1473 if (source) { 1475 if (source) {
1474 ChromeURLDataManager::AddDataSource(profile, source); 1476 ChromeURLDataManager::AddDataSource(profile, source);
1475 } 1477 }
1476 } 1478 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698