OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/webui/copresence_ui.h" | |
6 | |
7 #include "chrome/browser/ui/webui/copresence_ui_handler.h" | |
8 #include "chrome/common/url_constants.h" | |
9 #include "chrome/grit/generated_resources.h" | |
10 #include "content/public/browser/web_contents.h" | |
11 #include "content/public/browser/web_ui.h" | |
12 #include "content/public/browser/web_ui_data_source.h" | |
13 #include "grit/browser_resources.h" | |
14 | |
15 using content::WebUIDataSource; | |
16 | |
17 namespace { | |
18 | |
19 // Caller takes ownership of the WebUIDataSource. | |
20 WebUIDataSource* CreateDataSource() { | |
21 WebUIDataSource* data_source = | |
Dan Beam
2014/12/09 05:33:38
nit: you could make ownership more explicit with:
Charlie
2014/12/17 23:39:55
Sure. I like that better too. But the other webui
| |
22 WebUIDataSource::Create(chrome::kChromeUICopresenceHost); | |
23 | |
24 data_source->AddLocalizedString("title", IDS_COPRESENCE_TITLE); | |
25 | |
26 data_source->AddLocalizedString("directives_title", | |
27 IDS_COPRESENCE_DIRECTIVES_TITLE); | |
28 data_source->AddLocalizedString("directive_type", | |
29 IDS_COPRESENCE_DIRECTIVE_TYPE); | |
30 data_source->AddLocalizedString("token_medium", IDS_COPRESENCE_TOKEN_MEDIUM); | |
31 data_source->AddLocalizedString("duration", IDS_COPRESENCE_DURATION); | |
32 | |
33 data_source->AddLocalizedString("sent_tokens_title", | |
34 IDS_COPRESENCE_SENT_TOKENS_TITLE); | |
35 data_source->AddLocalizedString("received_tokens_title", | |
36 IDS_COPRESENCE_RECEIVED_TOKENS_TITLE); | |
37 data_source->AddLocalizedString("token_id", | |
38 IDS_COPRESENCE_TOKEN_ID); | |
39 data_source->AddLocalizedString("token_status", | |
40 IDS_COPRESENCE_TOKEN_STATUS); | |
41 data_source->AddLocalizedString("token_send_time", | |
42 IDS_COPRESENCE_TOKEN_SEND_TIME); | |
43 data_source->AddLocalizedString("token_receive_time", | |
44 IDS_COPRESENCE_TOKEN_RECEIVE_TIME); | |
45 | |
46 data_source->SetJsonPath("strings.js"); | |
47 data_source->AddResourcePath("copresence.css", IDR_COPRESENCE_CSS); | |
48 data_source->AddResourcePath("copresence.js", IDR_COPRESENCE_JS); | |
49 data_source->SetDefaultResource(IDR_COPRESENCE_HTML); | |
50 | |
51 return data_source; | |
52 } | |
53 | |
54 } // namespace | |
55 | |
56 CopresenceUI::CopresenceUI(content::WebUI* web_ui) | |
57 : content::WebUIController(web_ui) { | |
58 DCHECK(web_ui); | |
Dan Beam
2014/12/09 05:33:38
eh, we typically don't do
DCHECK(ptr);
ptr->D
Charlie
2014/12/17 23:39:55
Yes, but then you have to rerun through the debugg
| |
59 | |
60 // This call takes ownership of the WebUIMessageHandler. | |
61 web_ui->AddMessageHandler(new CopresenceUIHandler(web_ui)); | |
62 | |
63 // This call takes ownership of the WebUIDataSource. | |
64 WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), | |
65 CreateDataSource()); | |
66 } | |
67 | |
68 CopresenceUI::~CopresenceUI() {} | |
OLD | NEW |