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 "base/memory/scoped_ptr.h" |
| 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 scoped_ptr<WebUIDataSource> CreateDataSource() { |
| 21 scoped_ptr<WebUIDataSource> data_source( |
| 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("transmitted_tokens_title", |
| 34 IDS_COPRESENCE_TRANSMITTED_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_transmit_time", |
| 42 IDS_COPRESENCE_TOKEN_TRANSMIT_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.Pass(); |
| 52 } |
| 53 |
| 54 } // namespace |
| 55 |
| 56 CopresenceUI::CopresenceUI(content::WebUI* web_ui) |
| 57 : content::WebUIController(web_ui) { |
| 58 // This call takes ownership of the WebUIMessageHandler. |
| 59 web_ui->AddMessageHandler(new CopresenceUIHandler(web_ui)); |
| 60 |
| 61 // This call takes ownership of the WebUIDataSource. |
| 62 WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), |
| 63 CreateDataSource().release()); |
| 64 } |
| 65 |
| 66 CopresenceUI::~CopresenceUI() {} |
OLD | NEW |