Chromium Code Reviews| 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 | |
|
xiyuan
2014/12/05 18:56:55
nit: nuke one empty line
Charlie
2014/12/05 21:26:08
Done.
| |
| 6 #include "chrome/browser/ui/webui/copresence_ui.h" | |
| 7 | |
| 8 #include "chrome/browser/ui/webui/copresence_ui_handler.h" | |
| 9 #include "chrome/common/url_constants.h" | |
| 10 #include "chrome/grit/generated_resources.h" | |
| 11 #include "content/public/browser/web_contents.h" | |
| 12 #include "content/public/browser/web_ui.h" | |
| 13 #include "content/public/browser/web_ui_data_source.h" | |
| 14 #include "grit/browser_resources.h" | |
| 15 | |
| 16 using content::WebUIDataSource; | |
| 17 | |
| 18 namespace { | |
| 19 | |
| 20 // Caller takes ownership of the WebUIDataSource. | |
| 21 WebUIDataSource* CreateDataSource() { | |
| 22 WebUIDataSource* data_source = | |
| 23 WebUIDataSource::Create(chrome::kChromeUICopresenceHost); | |
| 24 | |
| 25 data_source->AddLocalizedString("title", IDS_COPRESENCE_TITLE); | |
| 26 | |
| 27 data_source->AddLocalizedString("directives_title", | |
| 28 IDS_COPRESENCE_DIRECTIVES_TITLE); | |
| 29 data_source->AddLocalizedString("directive_type", | |
| 30 IDS_COPRESENCE_DIRECTIVE_TYPE); | |
| 31 data_source->AddLocalizedString("token_medium", IDS_COPRESENCE_TOKEN_MEDIUM); | |
| 32 data_source->AddLocalizedString("duration", IDS_COPRESENCE_DURATION); | |
| 33 | |
| 34 data_source->AddLocalizedString("sent_tokens_title", | |
| 35 IDS_COPRESENCE_SENT_TOKENS_TITLE); | |
| 36 data_source->AddLocalizedString("received_tokens_title", | |
| 37 IDS_COPRESENCE_RECEIVED_TOKENS_TITLE); | |
| 38 data_source->AddLocalizedString("token_id", | |
| 39 IDS_COPRESENCE_TOKEN_ID); | |
| 40 data_source->AddLocalizedString("token_status", | |
| 41 IDS_COPRESENCE_TOKEN_STATUS); | |
| 42 data_source->AddLocalizedString("token_send_time", | |
| 43 IDS_COPRESENCE_TOKEN_SEND_TIME); | |
| 44 data_source->AddLocalizedString("token_receive_time", | |
| 45 IDS_COPRESENCE_TOKEN_RECEIVE_TIME); | |
| 46 | |
| 47 data_source->SetJsonPath("strings.js"); | |
| 48 data_source->AddResourcePath("copresence.css", IDR_COPRESENCE_CSS); | |
| 49 data_source->AddResourcePath("copresence.js", IDR_COPRESENCE_JS); | |
| 50 data_source->SetDefaultResource(IDR_COPRESENCE_HTML); | |
| 51 | |
| 52 return data_source; | |
| 53 } | |
| 54 | |
| 55 } // namespace | |
| 56 | |
| 57 CopresenceUI::CopresenceUI(content::WebUI* web_ui) | |
| 58 : content::WebUIController(web_ui) { | |
| 59 DCHECK(web_ui); | |
| 60 | |
| 61 // This call takes ownership of the WebUIMessageHandler. | |
| 62 web_ui->AddMessageHandler(new CopresenceUIHandler(web_ui)); | |
| 63 | |
| 64 // This call takes ownership of the WebUIDataSource. | |
| 65 WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), | |
| 66 CreateDataSource()); | |
| 67 } | |
| 68 | |
| 69 CopresenceUI::~CopresenceUI() {} | |
| OLD | NEW |