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 20 matching lines...) Expand all Loading... | |
31 #include "chrome/browser/browser_about_handler.h" | 31 #include "chrome/browser/browser_about_handler.h" |
32 #include "chrome/browser/browser_process.h" | 32 #include "chrome/browser/browser_process.h" |
33 #include "chrome/browser/defaults.h" | 33 #include "chrome/browser/defaults.h" |
34 #include "chrome/browser/memory_details.h" | 34 #include "chrome/browser/memory_details.h" |
35 #include "chrome/browser/net/predictor.h" | 35 #include "chrome/browser/net/predictor.h" |
36 #include "chrome/browser/net/url_fixer_upper.h" | 36 #include "chrome/browser/net/url_fixer_upper.h" |
37 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
38 #include "chrome/browser/profiles/profile_manager.h" | 38 #include "chrome/browser/profiles/profile_manager.h" |
39 #include "chrome/browser/ui/browser_dialogs.h" | 39 #include "chrome/browser/ui/browser_dialogs.h" |
40 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 40 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
41 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | |
42 #include "chrome/common/chrome_paths.h" | 41 #include "chrome/common/chrome_paths.h" |
43 #include "chrome/common/jstemplate_builder.h" | 42 #include "chrome/common/jstemplate_builder.h" |
44 #include "chrome/common/render_messages.h" | 43 #include "chrome/common/render_messages.h" |
45 #include "chrome/common/url_constants.h" | 44 #include "chrome/common/url_constants.h" |
46 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
47 #include "content/public/browser/render_process_host.h" | 46 #include "content/public/browser/render_process_host.h" |
48 #include "content/public/browser/render_view_host.h" | 47 #include "content/public/browser/render_view_host.h" |
49 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
50 #include "content/public/common/content_client.h" | 49 #include "content/public/common/content_client.h" |
51 #include "content/public/common/process_type.h" | 50 #include "content/public/common/process_type.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 std::string GetAboutMemoryRedirectResponse(Profile* profile) { | 108 std::string GetAboutMemoryRedirectResponse(Profile* profile) { |
110 return StringPrintf("<meta http-equiv=\"refresh\" content=\"0;%s\">", | 109 return StringPrintf("<meta http-equiv=\"refresh\" content=\"0;%s\">", |
111 chrome::kChromeUIMemoryRedirectURL); | 110 chrome::kChromeUIMemoryRedirectURL); |
112 } | 111 } |
113 | 112 |
114 // Handling about:memory is complicated enough to encapsulate its related | 113 // Handling about:memory is complicated enough to encapsulate its related |
115 // methods into a single class. The user should create it (on the heap) and call | 114 // methods into a single class. The user should create it (on the heap) and call |
116 // its |StartFetch()| method. | 115 // its |StartFetch()| method. |
117 class AboutMemoryHandler : public MemoryDetails { | 116 class AboutMemoryHandler : public MemoryDetails { |
118 public: | 117 public: |
119 AboutMemoryHandler(AboutUIHTMLSource* source, int request_id) | 118 AboutMemoryHandler(const base::WeakPtr<AboutUIHTMLSource>& source, |
119 int request_id) | |
120 : source_(source), | 120 : source_(source), |
121 request_id_(request_id) { | 121 request_id_(request_id) { |
122 } | 122 } |
123 | 123 |
124 virtual void OnDetailsAvailable() OVERRIDE; | 124 virtual void OnDetailsAvailable() OVERRIDE; |
125 | 125 |
126 private: | 126 private: |
127 ~AboutMemoryHandler() {} | 127 ~AboutMemoryHandler() {} |
128 | 128 |
129 void BindProcessMetrics(DictionaryValue* data, | 129 void BindProcessMetrics(DictionaryValue* data, |
130 ProcessMemoryInformation* info); | 130 ProcessMemoryInformation* info); |
131 void AppendProcess(ListValue* child_data, ProcessMemoryInformation* info); | 131 void AppendProcess(ListValue* child_data, ProcessMemoryInformation* info); |
132 | 132 |
133 scoped_refptr<AboutUIHTMLSource> source_; | 133 base::WeakPtr<AboutUIHTMLSource> source_; |
134 int request_id_; | 134 int request_id_; |
135 | 135 |
136 DISALLOW_COPY_AND_ASSIGN(AboutMemoryHandler); | 136 DISALLOW_COPY_AND_ASSIGN(AboutMemoryHandler); |
137 }; | 137 }; |
138 | 138 |
139 #if defined(OS_CHROMEOS) | 139 #if defined(OS_CHROMEOS) |
140 class ChromeOSTermsHandler | 140 class ChromeOSTermsHandler |
141 : public base::RefCountedThreadSafe<ChromeOSTermsHandler> { | 141 : public base::RefCountedThreadSafe<ChromeOSTermsHandler> { |
142 public: | 142 public: |
143 static void Start(AboutUIHTMLSource* source, | 143 static void Start(const base::WeakPtr<AboutUIHTMLSource>& source, |
144 const std::string& path, | 144 const std::string& path, |
145 int request_id) { | 145 int request_id) { |
146 scoped_refptr<ChromeOSTermsHandler> handler( | 146 scoped_refptr<ChromeOSTermsHandler> handler( |
147 new ChromeOSTermsHandler(source, path, request_id)); | 147 new ChromeOSTermsHandler(source, path, request_id)); |
148 handler->StartOnUIThread(); | 148 handler->StartOnUIThread(); |
149 } | 149 } |
150 | 150 |
151 private: | 151 private: |
152 friend class base::RefCountedThreadSafe<ChromeOSTermsHandler>; | 152 friend class base::RefCountedThreadSafe<ChromeOSTermsHandler>; |
153 | 153 |
154 ChromeOSTermsHandler(AboutUIHTMLSource* source, | 154 ChromeOSTermsHandler(const base::WeakPtr<AboutUIHTMLSource>& source, |
155 const std::string& path, | 155 const std::string& path, |
156 int request_id) | 156 int request_id) |
157 : source_(source), | 157 : source_(source), |
158 path_(path), | 158 path_(path), |
159 request_id_(request_id), | 159 request_id_(request_id), |
160 // Previously we were using "initial locale" http://crbug.com/145142 | 160 // Previously we were using "initial locale" http://crbug.com/145142 |
161 locale_(g_browser_process->GetApplicationLocale()) { | 161 locale_(g_browser_process->GetApplicationLocale()) { |
162 } | 162 } |
163 | 163 |
164 ~ChromeOSTermsHandler() {} | 164 ~ChromeOSTermsHandler() {} |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
197 } | 197 } |
198 } | 198 } |
199 } | 199 } |
200 BrowserThread::PostTask( | 200 BrowserThread::PostTask( |
201 BrowserThread::UI, FROM_HERE, | 201 BrowserThread::UI, FROM_HERE, |
202 base::Bind(&ChromeOSTermsHandler::ResponseOnUIThread, this)); | 202 base::Bind(&ChromeOSTermsHandler::ResponseOnUIThread, this)); |
203 } | 203 } |
204 | 204 |
205 void ResponseOnUIThread() { | 205 void ResponseOnUIThread() { |
206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 206 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
207 if (!source_) | |
James Hawkins
2013/01/14 20:30:25
Under what circumstances would this be NULL (at a
jam
2013/01/14 20:33:57
Previously, DataSource derived classes got refcoun
| |
208 return; | |
209 | |
207 // If we fail to load Chrome OS EULA from disk, load it from resources. | 210 // If we fail to load Chrome OS EULA from disk, load it from resources. |
208 // Do nothing if OEM EULA load failed. | 211 // Do nothing if OEM EULA load failed. |
209 if (contents_.empty() && path_ != chrome::kOemEulaURLPath) | 212 if (contents_.empty() && path_ != chrome::kOemEulaURLPath) |
210 contents_ = l10n_util::GetStringUTF8(IDS_TERMS_HTML); | 213 contents_ = l10n_util::GetStringUTF8(IDS_TERMS_HTML); |
211 source_->FinishDataRequest(contents_, request_id_); | 214 source_->FinishDataRequest(contents_, request_id_); |
212 } | 215 } |
213 | 216 |
214 // Where the results are fed to. | 217 // Where the results are fed to. |
215 scoped_refptr<AboutUIHTMLSource> source_; | 218 base::WeakPtr<AboutUIHTMLSource> source_; |
216 | 219 |
217 // Path in the URL. | 220 // Path in the URL. |
218 std::string path_; | 221 std::string path_; |
219 | 222 |
220 // ID identifying the request. | 223 // ID identifying the request. |
221 int request_id_; | 224 int request_id_; |
222 | 225 |
223 // Locale of the EULA. | 226 // Locale of the EULA. |
224 std::string locale_; | 227 std::string locale_; |
225 | 228 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
493 AppendFooter(&output); | 496 AppendFooter(&output); |
494 return output; | 497 return output; |
495 } | 498 } |
496 | 499 |
497 #endif // USE_ASH | 500 #endif // USE_ASH |
498 | 501 |
499 // AboutDnsHandler bounces the request back to the IO thread to collect | 502 // AboutDnsHandler bounces the request back to the IO thread to collect |
500 // the DNS information. | 503 // the DNS information. |
501 class AboutDnsHandler : public base::RefCountedThreadSafe<AboutDnsHandler> { | 504 class AboutDnsHandler : public base::RefCountedThreadSafe<AboutDnsHandler> { |
502 public: | 505 public: |
503 static void Start(AboutUIHTMLSource* source, int request_id) { | 506 static void Start(const base::WeakPtr<AboutUIHTMLSource>& source, |
507 int request_id) { | |
504 scoped_refptr<AboutDnsHandler> handler( | 508 scoped_refptr<AboutDnsHandler> handler( |
505 new AboutDnsHandler(source, request_id)); | 509 new AboutDnsHandler(source, request_id)); |
506 handler->StartOnUIThread(); | 510 handler->StartOnUIThread(); |
507 } | 511 } |
508 | 512 |
509 private: | 513 private: |
510 friend class base::RefCountedThreadSafe<AboutDnsHandler>; | 514 friend class base::RefCountedThreadSafe<AboutDnsHandler>; |
511 | 515 |
512 AboutDnsHandler(AboutUIHTMLSource* source, int request_id) | 516 AboutDnsHandler(const base::WeakPtr<AboutUIHTMLSource>& source, |
517 int request_id) | |
513 : source_(source), | 518 : source_(source), |
514 request_id_(request_id) { | 519 request_id_(request_id) { |
515 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 520 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
516 } | 521 } |
517 | 522 |
518 virtual ~AboutDnsHandler() {} | 523 virtual ~AboutDnsHandler() {} |
519 | 524 |
520 // Calls FinishOnUIThread() on completion. | 525 // Calls FinishOnUIThread() on completion. |
521 void StartOnUIThread() { | 526 void StartOnUIThread() { |
522 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 527 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 13 matching lines...) Expand all Loading... | |
536 chrome_browser_net::Predictor::PredictorGetHtmlInfo(predictor, &data); | 541 chrome_browser_net::Predictor::PredictorGetHtmlInfo(predictor, &data); |
537 AppendFooter(&data); | 542 AppendFooter(&data); |
538 | 543 |
539 BrowserThread::PostTask( | 544 BrowserThread::PostTask( |
540 BrowserThread::UI, FROM_HERE, | 545 BrowserThread::UI, FROM_HERE, |
541 base::Bind(&AboutDnsHandler::FinishOnUIThread, this, data)); | 546 base::Bind(&AboutDnsHandler::FinishOnUIThread, this, data)); |
542 } | 547 } |
543 | 548 |
544 void FinishOnUIThread(const std::string& data) { | 549 void FinishOnUIThread(const std::string& data) { |
545 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 550 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
546 source_->FinishDataRequest(data, request_id_); | 551 if (source_) |
552 source_->FinishDataRequest(data, request_id_); | |
547 } | 553 } |
548 | 554 |
549 // Where the results are fed to. | 555 // Where the results are fed to. |
550 scoped_refptr<AboutUIHTMLSource> source_; | 556 base::WeakPtr<AboutUIHTMLSource> source_; |
551 | 557 |
552 // ID identifying the request. | 558 // ID identifying the request. |
553 int request_id_; | 559 int request_id_; |
554 | 560 |
555 DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler); | 561 DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler); |
556 }; | 562 }; |
557 | 563 |
558 void FinishMemoryDataRequest(const std::string& path, | 564 void FinishMemoryDataRequest(const std::string& path, |
559 AboutUIHTMLSource* source, | 565 AboutUIHTMLSource* source, |
560 int request_id) { | 566 int request_id) { |
561 if (path == kStringsJsPath) { | 567 if (path == kStringsJsPath) { |
562 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want | 568 // The AboutMemoryHandler cleans itself up, but |StartFetch()| will want |
563 // the refcount to be greater than 0. | 569 // the refcount to be greater than 0. |
564 scoped_refptr<AboutMemoryHandler> | 570 scoped_refptr<AboutMemoryHandler> |
565 handler(new AboutMemoryHandler(source, request_id)); | 571 handler(new AboutMemoryHandler(source->AsWeakPtr(), request_id)); |
566 // TODO(jamescook): Maybe this shouldn't update UMA? | 572 // TODO(jamescook): Maybe this shouldn't update UMA? |
567 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS); | 573 handler->StartFetch(MemoryDetails::UPDATE_USER_METRICS); |
568 } else { | 574 } else { |
569 source->FinishDataRequest( | 575 source->FinishDataRequest( |
570 ResourceBundle::GetSharedInstance().GetRawDataResource( | 576 ResourceBundle::GetSharedInstance().GetRawDataResource( |
571 path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS : | 577 path == kMemoryJsPath ? IDR_ABOUT_MEMORY_JS : |
572 IDR_ABOUT_MEMORY_HTML).as_string(), request_id); | 578 IDR_ABOUT_MEMORY_HTML).as_string(), request_id); |
573 } | 579 } |
574 } | 580 } |
575 | 581 |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
857 if (info->is_diagnostics) | 863 if (info->is_diagnostics) |
858 child_label.append(" (diagnostics)"); | 864 child_label.append(" (diagnostics)"); |
859 child->SetString("child_name", child_label); | 865 child->SetString("child_name", child_label); |
860 ListValue* titles = new ListValue(); | 866 ListValue* titles = new ListValue(); |
861 child->Set("titles", titles); | 867 child->Set("titles", titles); |
862 for (size_t i = 0; i < info->titles.size(); ++i) | 868 for (size_t i = 0; i < info->titles.size(); ++i) |
863 titles->Append(new StringValue(info->titles[i])); | 869 titles->Append(new StringValue(info->titles[i])); |
864 } | 870 } |
865 | 871 |
866 void AboutMemoryHandler::OnDetailsAvailable() { | 872 void AboutMemoryHandler::OnDetailsAvailable() { |
873 if (!source_) | |
874 return; | |
875 | |
867 // the root of the JSON hierarchy for about:memory jstemplate | 876 // the root of the JSON hierarchy for about:memory jstemplate |
868 scoped_ptr<DictionaryValue> root(new DictionaryValue); | 877 scoped_ptr<DictionaryValue> root(new DictionaryValue); |
869 ListValue* browsers = new ListValue(); | 878 ListValue* browsers = new ListValue(); |
870 root->Set("browsers", browsers); | 879 root->Set("browsers", browsers); |
871 | 880 |
872 const std::vector<ProcessData>& browser_processes = processes(); | 881 const std::vector<ProcessData>& browser_processes = processes(); |
873 | 882 |
874 // Aggregate per-process data into browser summary data. | 883 // Aggregate per-process data into browser summary data. |
875 string16 log_string; | 884 string16 log_string; |
876 for (size_t index = 0; index < browser_processes.size(); index++) { | 885 for (size_t index = 0; index < browser_processes.size(); index++) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
931 AppendProcess(child_data, &process.processes[index]); | 940 AppendProcess(child_data, &process.processes[index]); |
932 } | 941 } |
933 | 942 |
934 root->SetBoolean("show_other_browsers", | 943 root->SetBoolean("show_other_browsers", |
935 browser_defaults::kShowOtherBrowsersInAboutMemory); | 944 browser_defaults::kShowOtherBrowsersInAboutMemory); |
936 | 945 |
937 DictionaryValue load_time_data; | 946 DictionaryValue load_time_data; |
938 load_time_data.SetString( | 947 load_time_data.SetString( |
939 "summary_desc", | 948 "summary_desc", |
940 l10n_util::GetStringUTF16(IDS_MEMORY_USAGE_SUMMARY_DESC)); | 949 l10n_util::GetStringUTF16(IDS_MEMORY_USAGE_SUMMARY_DESC)); |
941 ChromeWebUIDataSource::SetFontAndTextDirection(&load_time_data); | 950 URLDataSource::SetFontAndTextDirection(&load_time_data); |
942 load_time_data.Set("jstemplateData", root.release()); | 951 load_time_data.Set("jstemplateData", root.release()); |
943 | 952 |
944 jstemplate_builder::UseVersion2 version2; | 953 jstemplate_builder::UseVersion2 version2; |
945 std::string data; | 954 std::string data; |
946 jstemplate_builder::AppendJsonJS(&load_time_data, &data); | 955 jstemplate_builder::AppendJsonJS(&load_time_data, &data); |
947 source_->FinishDataRequest(data, request_id_); | 956 source_->FinishDataRequest(data, request_id_); |
948 } | 957 } |
949 | 958 |
950 } // namespace | 959 } // namespace |
951 | 960 |
952 // AboutUIHTMLSource ---------------------------------------------------------- | 961 // AboutUIHTMLSource ---------------------------------------------------------- |
953 | 962 |
954 AboutUIHTMLSource::AboutUIHTMLSource(const std::string& source_name, | 963 AboutUIHTMLSource::AboutUIHTMLSource(const std::string& source_name, |
955 Profile* profile) | 964 Profile* profile) |
956 : DataSource(source_name, MessageLoop::current()), | 965 : source_name_(source_name), |
957 profile_(profile) {} | 966 profile_(profile) {} |
958 | 967 |
959 AboutUIHTMLSource::~AboutUIHTMLSource() {} | 968 AboutUIHTMLSource::~AboutUIHTMLSource() {} |
960 | 969 |
970 std::string AboutUIHTMLSource::GetSource() { | |
971 return source_name_; | |
972 } | |
973 | |
961 void AboutUIHTMLSource::StartDataRequest(const std::string& path, | 974 void AboutUIHTMLSource::StartDataRequest(const std::string& path, |
962 bool is_incognito, | 975 bool is_incognito, |
963 int request_id) { | 976 int request_id) { |
964 std::string response; | 977 std::string response; |
965 std::string host = source_name(); | |
966 // Add your data source here, in alphabetical order. | 978 // Add your data source here, in alphabetical order. |
967 if (host == chrome::kChromeUIChromeURLsHost) { | 979 if (source_name_ == chrome::kChromeUIChromeURLsHost) { |
968 response = ChromeURLs(); | 980 response = ChromeURLs(); |
969 } else if (host == chrome::kChromeUICreditsHost) { | 981 } else if (source_name_ == chrome::kChromeUICreditsHost) { |
970 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML; | 982 int idr = (path == kCreditsJsPath) ? IDR_CREDITS_JS : IDR_CREDITS_HTML; |
971 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 983 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
972 idr).as_string(); | 984 idr).as_string(); |
973 #if defined(OS_CHROMEOS) | 985 #if defined(OS_CHROMEOS) |
974 } else if (host == chrome::kChromeUIDiscardsHost) { | 986 } else if (source_name_ == chrome::kChromeUIDiscardsHost) { |
975 response = AboutDiscards(path); | 987 response = AboutDiscards(path); |
976 #endif | 988 #endif |
977 #if defined(USE_ASH) | 989 #if defined(USE_ASH) |
978 } else if (host == chrome::kChromeUITransparencyHost) { | 990 } else if (source_name_ == chrome::kChromeUITransparencyHost) { |
979 response = AboutTransparency(path); | 991 response = AboutTransparency(path); |
980 #endif | 992 #endif |
981 } else if (host == chrome::kChromeUIDNSHost) { | 993 } else if (source_name_ == chrome::kChromeUIDNSHost) { |
982 AboutDnsHandler::Start(this, request_id); | 994 AboutDnsHandler::Start(AsWeakPtr(), request_id); |
983 return; | 995 return; |
984 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 996 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
985 } else if (host == chrome::kChromeUILinuxProxyConfigHost) { | 997 } else if (source_name_ == chrome::kChromeUILinuxProxyConfigHost) { |
986 response = AboutLinuxProxyConfig(); | 998 response = AboutLinuxProxyConfig(); |
987 #endif | 999 #endif |
988 } else if (host == chrome::kChromeUIMemoryHost) { | 1000 } else if (source_name_ == chrome::kChromeUIMemoryHost) { |
989 response = GetAboutMemoryRedirectResponse(profile()); | 1001 response = GetAboutMemoryRedirectResponse(profile()); |
990 } else if (host == chrome::kChromeUIMemoryRedirectHost) { | 1002 } else if (source_name_ == chrome::kChromeUIMemoryRedirectHost) { |
991 FinishMemoryDataRequest(path, this, request_id); | 1003 FinishMemoryDataRequest(path, this, request_id); |
992 return; | 1004 return; |
993 #if defined(OS_CHROMEOS) | 1005 #if defined(OS_CHROMEOS) |
994 } else if (host == chrome::kChromeUINetworkHost) { | 1006 } else if (source_name_ == chrome::kChromeUINetworkHost) { |
995 response = chromeos::about_ui::AboutNetwork(path); | 1007 response = chromeos::about_ui::AboutNetwork(path); |
996 } else if (host == chrome::kChromeUIOSCreditsHost) { | 1008 } else if (source_name_ == chrome::kChromeUIOSCreditsHost) { |
997 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1009 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
998 IDR_OS_CREDITS_HTML).as_string(); | 1010 IDR_OS_CREDITS_HTML).as_string(); |
999 #endif | 1011 #endif |
1000 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 1012 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
1001 } else if (host == chrome::kChromeUISandboxHost) { | 1013 } else if (source_name_ == chrome::kChromeUISandboxHost) { |
1002 response = AboutSandbox(); | 1014 response = AboutSandbox(); |
1003 #endif | 1015 #endif |
1004 } else if (host == chrome::kChromeUIStatsHost) { | 1016 } else if (source_name_ == chrome::kChromeUIStatsHost) { |
1005 response = AboutStats(path); | 1017 response = AboutStats(path); |
1006 } else if (host == chrome::kChromeUITermsHost) { | 1018 } else if (source_name_ == chrome::kChromeUITermsHost) { |
1007 #if defined(OS_CHROMEOS) | 1019 #if defined(OS_CHROMEOS) |
1008 ChromeOSTermsHandler::Start(this, path, request_id); | 1020 ChromeOSTermsHandler::Start(AsWeakPtr(), path, request_id); |
1009 return; | 1021 return; |
1010 #else | 1022 #else |
1011 response = l10n_util::GetStringUTF8(IDS_TERMS_HTML); | 1023 response = l10n_util::GetStringUTF8(IDS_TERMS_HTML); |
1012 #endif | 1024 #endif |
1013 } | 1025 } |
1014 | 1026 |
1015 FinishDataRequest(response, request_id); | 1027 FinishDataRequest(response, request_id); |
1016 } | 1028 } |
1017 | 1029 |
1018 void AboutUIHTMLSource::FinishDataRequest(const std::string& html, | 1030 void AboutUIHTMLSource::FinishDataRequest(const std::string& html, |
1019 int request_id) { | 1031 int request_id) { |
1020 std::string html_copy(html); | 1032 std::string html_copy(html); |
1021 SendResponse(request_id, base::RefCountedString::TakeString(&html_copy)); | 1033 url_data_source()->SendResponse( |
1034 request_id, base::RefCountedString::TakeString(&html_copy)); | |
1022 } | 1035 } |
1023 | 1036 |
1024 std::string AboutUIHTMLSource::GetMimeType(const std::string& path) const { | 1037 std::string AboutUIHTMLSource::GetMimeType(const std::string& path) const { |
1025 if (path == kCreditsJsPath || | 1038 if (path == kCreditsJsPath || |
1026 path == kStatsJsPath || | 1039 path == kStatsJsPath || |
1027 path == kStringsJsPath || | 1040 path == kStringsJsPath || |
1028 path == kMemoryJsPath) { | 1041 path == kMemoryJsPath) { |
1029 return "application/javascript"; | 1042 return "application/javascript"; |
1030 } | 1043 } |
1031 return "text/html"; | 1044 return "text/html"; |
1032 } | 1045 } |
1033 | 1046 |
1034 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) | 1047 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) |
1035 : WebUIController(web_ui) { | 1048 : WebUIController(web_ui) { |
1036 Profile* profile = Profile::FromWebUI(web_ui); | 1049 Profile* profile = Profile::FromWebUI(web_ui); |
1037 | 1050 |
1038 #if defined(ENABLE_THEMES) | 1051 #if defined(ENABLE_THEMES) |
1039 // Set up the chrome://theme/ source. | 1052 // Set up the chrome://theme/ source. |
1040 ThemeSource* theme = new ThemeSource(profile); | 1053 ThemeSource* theme = new ThemeSource(profile); |
1041 ChromeURLDataManager::AddDataSource(profile, theme); | 1054 ChromeURLDataManager::AddDataSource(profile, theme); |
1042 #endif | 1055 #endif |
1043 | 1056 |
1044 ChromeURLDataManager::DataSource* source = | 1057 content::URLDataSourceDelegate* source = new AboutUIHTMLSource(name, profile); |
1045 new AboutUIHTMLSource(name, profile); | 1058 ChromeURLDataManager::AddDataSource(profile, source); |
1046 if (source) { | |
1047 ChromeURLDataManager::AddDataSource(profile, source); | |
1048 } | |
1049 } | 1059 } |
OLD | NEW |