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

Unified Diff: chrome/browser/ui/webui/domain_reliability_internals_ui.cc

Issue 357103002: Domain Reliability: Add rudimentary WebUI page. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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/domain_reliability_internals_ui.cc
diff --git a/chrome/browser/ui/webui/domain_reliability_internals_ui.cc b/chrome/browser/ui/webui/domain_reliability_internals_ui.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bd854ae03543be46297ec58aa7b78f511d4554bb
--- /dev/null
+++ b/chrome/browser/ui/webui/domain_reliability_internals_ui.cc
@@ -0,0 +1,66 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/domain_reliability_internals_ui.h"
+
+#include "chrome/browser/domain_reliability/service_factory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/url_constants.h"
+#include "components/domain_reliability/service.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "grit/browser_resources.h"
+#include "grit/generated_resources.h"
+
+using domain_reliability::DomainReliabilityService;
+using domain_reliability::DomainReliabilityServiceFactory;
+
+DomainReliabilityInternalsUI::DomainReliabilityInternalsUI(
+ content::WebUI* web_ui)
+ : content::WebUIController(web_ui) {
+ content::WebUIDataSource* html_source = content::WebUIDataSource::Create(
+ chrome::kChromeUIDomainReliabilityInternalsHost);
+ html_source->SetUseJsonJSFormatV2();
+ html_source->SetJsonPath("strings.js");
+ html_source->AddResourcePath("domain_reliability_internals.css",
+ IDR_DOMAIN_RELIABILITY_INTERNALS_CSS);
+ html_source->AddResourcePath("domain_reliability_internals.js",
+ IDR_DOMAIN_RELIABILITY_INTERNALS_JS);
+ html_source->SetDefaultResource(IDR_DOMAIN_RELIABILITY_INTERNALS_HTML);
+
+ web_ui->RegisterMessageCallback("updateData",
+ base::Bind(&DomainReliabilityInternalsUI::UpdateData,
+ base::Unretained(this)));
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ content::WebUIDataSource::Add(profile, html_source);
+}
+
+DomainReliabilityInternalsUI::~DomainReliabilityInternalsUI() {}
+
+void DomainReliabilityInternalsUI::UpdateData(
+ const base::ListValue* args) const {
+ Profile* profile = Profile::FromWebUI(web_ui());
+ DomainReliabilityServiceFactory* factory =
+ DomainReliabilityServiceFactory::GetInstance();
+ DCHECK(profile);
+ DCHECK(factory);
+
+ DomainReliabilityService* service = factory->GetForBrowserContext(profile);
+ if (!service) {
+ LOG(WARNING) << "No DomainReliabilityService!";
+ NOTREACHED();
Bernhard Bauer 2014/06/28 11:16:35 If this can't happen, you don't need to deal with
Deprecated (see juliatuttle) 2014/06/30 16:58:21 This actually can happen (I've changed the underly
+ return;
+ }
+
+ service->GetWebUIData(base::Bind(
+ &DomainReliabilityInternalsUI::OnDataUpdated,
+ base::Unretained(this)));
+}
+
+void DomainReliabilityInternalsUI::OnDataUpdated(
+ scoped_ptr<const base::Value> data) const {
+ web_ui()->CallJavascriptFunction(
+ "domain_reliability_internals.onDataUpdated", *data);
+}

Powered by Google App Engine
This is Rietveld 408576698