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

Unified Diff: chrome/browser/ui/webui/chromeos/system_info_ui.cc

Issue 11881055: Simplify WebUI data sources. Currently WebUI data sources implement a URLDataSourceDelegate interfa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix issue in about_ui exposed by cros tests Created 7 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/webui/chromeos/system_info_ui.cc
===================================================================
--- chrome/browser/ui/webui/chromeos/system_info_ui.cc (revision 176942)
+++ chrome/browser/ui/webui/chromeos/system_info_ui.cc (working copy)
@@ -21,11 +21,11 @@
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/system_logs/system_logs_fetcher.h"
#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
+#include "chrome/browser/ui/webui/web_ui_util.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/jstemplate_builder.h"
#include "chrome/common/url_constants.h"
-#include "content/public/browser/url_data_source_delegate.h"
+#include "content/public/browser/url_data_source.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_message_handler.h"
@@ -43,15 +43,16 @@
namespace chromeos {
-class SystemInfoUIHTMLSource : public content::URLDataSourceDelegate {
+class SystemInfoUIHTMLSource : public content::URLDataSource{
public:
SystemInfoUIHTMLSource();
- // content::URLDataSourceDelegate implementation.
+ // content::URLDataSource implementation.
virtual std::string GetSource() OVERRIDE;
- virtual void StartDataRequest(const std::string& path,
- bool is_incognito,
- int request_id) OVERRIDE;
+ virtual void StartDataRequest(
+ const std::string& path,
+ bool is_incognito,
+ const content::URLDataSource::GotDataCallback& callback) OVERRIDE;
virtual std::string GetMimeType(const std::string&) const OVERRIDE {
return "text/html";
}
@@ -65,7 +66,7 @@
// Stored data from StartDataRequest()
std::string path_;
- int request_id_;
+ content::URLDataSource::GotDataCallback callback_;
scoped_ptr<SystemLogsResponse> response_;
base::WeakPtrFactory<SystemInfoUIHTMLSource> weak_ptr_factory_;
@@ -93,8 +94,7 @@
////////////////////////////////////////////////////////////////////////////////
SystemInfoUIHTMLSource::SystemInfoUIHTMLSource()
- : request_id_(0),
- response_(NULL),
+ : response_(NULL),
ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_(this)) {
}
@@ -102,11 +102,12 @@
return chrome::kChromeUISystemInfoHost;
}
-void SystemInfoUIHTMLSource::StartDataRequest(const std::string& path,
- bool is_incognito,
- int request_id) {
+void SystemInfoUIHTMLSource::StartDataRequest(
+ const std::string& path,
+ bool is_incognito,
+ const content::URLDataSource::GotDataCallback& callback) {
path_ = path;
- request_id_ = request_id;
+ callback_ = callback;
SystemLogsFetcher* fetcher = new SystemLogsFetcher();
fetcher->Fetch(base::Bind(&SystemInfoUIHTMLSource::SysInfoComplete,
@@ -135,7 +136,7 @@
l10n_util::GetStringUTF16(IDS_ABOUT_SYS_EXPAND));
strings.SetString("collapse_btn",
l10n_util::GetStringUTF16(IDS_ABOUT_SYS_COLLAPSE));
- URLDataSource::SetFontAndTextDirection(&strings);
+ web_ui_util::SetFontAndTextDirection(&strings);
if (response_.get()) {
ListValue* details = new ListValue();
strings.Set("details", details);
@@ -154,8 +155,7 @@
IDR_ABOUT_SYS_HTML));
std::string full_html = jstemplate_builder::GetTemplatesHtml(
systeminfo_html, &strings, "t" /* template root node id */);
- url_data_source()->SendResponse(
- request_id_, base::RefCountedString::TakeString(&full_html));
+ callback_.Run(base::RefCountedString::TakeString(&full_html));
}
////////////////////////////////////////////////////////////////////////////////

Powered by Google App Engine
This is Rietveld 408576698