| 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 <memory> | |
| 8 | |
| 9 #include "chrome/browser/ui/webui/copresence_ui_handler.h" | |
| 10 #include "chrome/common/url_constants.h" | |
| 11 #include "chrome/grit/generated_resources.h" | |
| 12 #include "content/public/browser/web_contents.h" | |
| 13 #include "content/public/browser/web_ui.h" | |
| 14 #include "content/public/browser/web_ui_data_source.h" | |
| 15 #include "grit/browser_resources.h" | |
| 16 | |
| 17 using content::WebUIDataSource; | |
| 18 | |
| 19 namespace { | |
| 20 | |
| 21 std::unique_ptr<WebUIDataSource> CreateDataSource() { | |
| 22 std::unique_ptr<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("transmitted_tokens_title", | |
| 35 IDS_COPRESENCE_TRANSMITTED_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_transmit_time", | |
| 43 IDS_COPRESENCE_TOKEN_TRANSMIT_TIME); | |
| 44 data_source->AddLocalizedString("token_receive_time", | |
| 45 IDS_COPRESENCE_TOKEN_RECEIVE_TIME); | |
| 46 | |
| 47 data_source->AddLocalizedString("clear_state", | |
| 48 IDS_COPRESENCE_CLEAR_STATE); | |
| 49 data_source->AddLocalizedString("confirm_delete", | |
| 50 IDS_COPRESENCE_CONFIRM_DELETE); | |
| 51 | |
| 52 data_source->SetJsonPath("strings.js"); | |
| 53 data_source->AddResourcePath("copresence.css", IDR_COPRESENCE_CSS); | |
| 54 data_source->AddResourcePath("copresence.js", IDR_COPRESENCE_JS); | |
| 55 data_source->SetDefaultResource(IDR_COPRESENCE_HTML); | |
| 56 | |
| 57 return data_source; | |
| 58 } | |
| 59 | |
| 60 } // namespace | |
| 61 | |
| 62 CopresenceUI::CopresenceUI(content::WebUI* web_ui) | |
| 63 : content::WebUIController(web_ui) { | |
| 64 // This call takes ownership of the WebUIMessageHandler. | |
| 65 web_ui->AddMessageHandler(new CopresenceUIHandler(web_ui)); | |
| 66 | |
| 67 // This call takes ownership of the WebUIDataSource. | |
| 68 WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), | |
| 69 CreateDataSource().release()); | |
| 70 } | |
| 71 | |
| 72 CopresenceUI::~CopresenceUI() {} | |
| OLD | NEW |