Chromium Code Reviews| Index: chrome/browser/ui/webui/copresence_ui.cc |
| diff --git a/chrome/browser/ui/webui/copresence_ui.cc b/chrome/browser/ui/webui/copresence_ui.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..74fcb53ce1150f999a2f3d4af93c0452dee6f6ec |
| --- /dev/null |
| +++ b/chrome/browser/ui/webui/copresence_ui.cc |
| @@ -0,0 +1,68 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/webui/copresence_ui.h" |
| + |
| +#include "chrome/browser/ui/webui/copresence_ui_handler.h" |
| +#include "chrome/common/url_constants.h" |
| +#include "chrome/grit/generated_resources.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "content/public/browser/web_ui.h" |
| +#include "content/public/browser/web_ui_data_source.h" |
| +#include "grit/browser_resources.h" |
| + |
| +using content::WebUIDataSource; |
| + |
| +namespace { |
| + |
| +// Caller takes ownership of the WebUIDataSource. |
| +WebUIDataSource* CreateDataSource() { |
| + 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
|
| + WebUIDataSource::Create(chrome::kChromeUICopresenceHost); |
| + |
| + data_source->AddLocalizedString("title", IDS_COPRESENCE_TITLE); |
| + |
| + data_source->AddLocalizedString("directives_title", |
| + IDS_COPRESENCE_DIRECTIVES_TITLE); |
| + data_source->AddLocalizedString("directive_type", |
| + IDS_COPRESENCE_DIRECTIVE_TYPE); |
| + data_source->AddLocalizedString("token_medium", IDS_COPRESENCE_TOKEN_MEDIUM); |
| + data_source->AddLocalizedString("duration", IDS_COPRESENCE_DURATION); |
| + |
| + data_source->AddLocalizedString("sent_tokens_title", |
| + IDS_COPRESENCE_SENT_TOKENS_TITLE); |
| + data_source->AddLocalizedString("received_tokens_title", |
| + IDS_COPRESENCE_RECEIVED_TOKENS_TITLE); |
| + data_source->AddLocalizedString("token_id", |
| + IDS_COPRESENCE_TOKEN_ID); |
| + data_source->AddLocalizedString("token_status", |
| + IDS_COPRESENCE_TOKEN_STATUS); |
| + data_source->AddLocalizedString("token_send_time", |
| + IDS_COPRESENCE_TOKEN_SEND_TIME); |
| + data_source->AddLocalizedString("token_receive_time", |
| + IDS_COPRESENCE_TOKEN_RECEIVE_TIME); |
| + |
| + data_source->SetJsonPath("strings.js"); |
| + data_source->AddResourcePath("copresence.css", IDR_COPRESENCE_CSS); |
| + data_source->AddResourcePath("copresence.js", IDR_COPRESENCE_JS); |
| + data_source->SetDefaultResource(IDR_COPRESENCE_HTML); |
| + |
| + return data_source; |
| +} |
| + |
| +} // namespace |
| + |
| +CopresenceUI::CopresenceUI(content::WebUI* web_ui) |
| + : content::WebUIController(web_ui) { |
| + 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
|
| + |
| + // This call takes ownership of the WebUIMessageHandler. |
| + web_ui->AddMessageHandler(new CopresenceUIHandler(web_ui)); |
| + |
| + // This call takes ownership of the WebUIDataSource. |
| + WebUIDataSource::Add(web_ui->GetWebContents()->GetBrowserContext(), |
| + CreateDataSource()); |
| +} |
| + |
| +CopresenceUI::~CopresenceUI() {} |