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

Side by Side Diff: chrome/browser/ui/webui/local_discovery/local_discovery_ui.cc

Issue 20070002: Demo UI for device discovery and registration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added FILE_PATH_LITERAL macro to fix windows compile problem Created 7 years, 4 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/local_discovery/local_discovery_ui.h" 5 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h" 8 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h"
9 #include "chrome/common/url_constants.h" 9 #include "chrome/common/url_constants.h"
10 #include "content/public/browser/web_ui.h" 10 #include "content/public/browser/web_ui.h"
11 #include "content/public/browser/web_ui_data_source.h" 11 #include "content/public/browser/web_ui_data_source.h"
12 #include "grit/browser_resources.h" 12 #include "grit/browser_resources.h"
13 #include "grit/generated_resources.h"
13 14
14 namespace { 15 namespace {
15 16
16 content::WebUIDataSource* CreateLocalDiscoveryHTMLSource() { 17 content::WebUIDataSource* CreateLocalDiscoveryHTMLSource() {
17 content::WebUIDataSource* source = 18 content::WebUIDataSource* source =
18 content::WebUIDataSource::Create(chrome::kChromeUIDevicesHost); 19 content::WebUIDataSource::Create(chrome::kChromeUIDevicesHost);
19 20
20 source->SetDefaultResource(IDR_LOCAL_DISCOVERY_HTML); 21 source->SetDefaultResource(IDR_LOCAL_DISCOVERY_HTML);
21 source->AddResourcePath("local_discovery.css", IDR_LOCAL_DISCOVERY_CSS); 22 source->AddResourcePath("local_discovery.css", IDR_LOCAL_DISCOVERY_CSS);
22 source->AddResourcePath("local_discovery.js", IDR_LOCAL_DISCOVERY_JS); 23 source->AddResourcePath("local_discovery.js", IDR_LOCAL_DISCOVERY_JS);
24
25 source->SetUseJsonJSFormatV2();
26 source->AddLocalizedString("serviceName",
27 IDS_LOCAL_DISCOVERY_SERVICE_NAME);
28 source->AddLocalizedString("serviceDomain",
29 IDS_LOCAL_DISCOVERY_SERVICE_DOMAIN);
30 source->AddLocalizedString("servicePort",
31 IDS_LOCAL_DISCOVERY_SERVICE_PORT);
32 source->AddLocalizedString("serviceIp",
33 IDS_LOCAL_DISCOVERY_SERVICE_IP);
34 source->AddLocalizedString("serviceLastseen",
35 IDS_LOCAL_DISCOVERY_SERVICE_LASTSEEN);
36 source->AddLocalizedString("serviceRegister",
37 IDS_LOCAL_DISCOVERY_SERVICE_REGISTER);
38 source->AddLocalizedString("registeringService",
39 IDS_LOCAL_DISCOVERY_REGISTERING_SERVICE);
40 source->AddLocalizedString("registrationFailed",
41 IDS_LOCAL_DISCOVERY_REGISTRATION_FAILED);
42 source->AddLocalizedString("registrationSucceeded",
43 IDS_LOCAL_DISCOVERY_REGISTRATION_SUCCEEDED);
44 source->AddLocalizedString("registered",
45 IDS_LOCAL_DISCOVERY_REGISTERED);
46
47 source->SetJsonPath("strings.js");
48
23 return source; 49 return source;
24 } 50 }
25 51
26 } // namespace 52 } // namespace
27 53
28 LocalDiscoveryUI::LocalDiscoveryUI(content::WebUI* web_ui) 54 LocalDiscoveryUI::LocalDiscoveryUI(content::WebUI* web_ui)
29 : WebUIController(web_ui) { 55 : WebUIController(web_ui) {
30 // Set up the chrome://devices/ source. 56 // Set up the chrome://devices/ source.
31 Profile* profile = Profile::FromWebUI(web_ui); 57 Profile* profile = Profile::FromWebUI(web_ui);
32 content::WebUIDataSource::Add(profile, CreateLocalDiscoveryHTMLSource()); 58 content::WebUIDataSource::Add(profile, CreateLocalDiscoveryHTMLSource());
33 59
34 // TODO(gene): Use LocalDiscoveryUIHandler to send updated to the devices 60 // TODO(gene): Use LocalDiscoveryUIHandler to send updated to the devices
35 // page. For example 61 // page. For example
36 // web_ui->AddMessageHandler(new LocalDiscoveryUIHandler()); 62 web_ui->AddMessageHandler(local_discovery::LocalDiscoveryUIHandler::Create());
37 } 63 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698