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.
5 #include "chrome/browser/ui/webui/copresence_ui.h"
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"
16 using content::WebUIDataSource
;
20 scoped_ptr
<WebUIDataSource
> CreateDataSource() {
21 scoped_ptr
<WebUIDataSource
> data_source(
22 WebUIDataSource::Create(chrome::kChromeUICopresenceHost
));
24 data_source
->AddLocalizedString("title", IDS_COPRESENCE_TITLE
);
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
);
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
);
46 data_source
->AddLocalizedString("clear_state",
47 IDS_COPRESENCE_CLEAR_STATE
);
48 data_source
->AddLocalizedString("confirm_delete",
49 IDS_COPRESENCE_CONFIRM_DELETE
);
51 data_source
->SetJsonPath("strings.js");
52 data_source
->AddResourcePath("copresence.css", IDR_COPRESENCE_CSS
);
53 data_source
->AddResourcePath("copresence.js", IDR_COPRESENCE_JS
);
54 data_source
->SetDefaultResource(IDR_COPRESENCE_HTML
);
56 return data_source
.Pass();
61 CopresenceUI::CopresenceUI(content::WebUI
* web_ui
)
62 : content::WebUIController(web_ui
) {
63 // This call takes ownership of the WebUIMessageHandler.
64 web_ui
->AddMessageHandler(new CopresenceUIHandler(web_ui
));
66 // This call takes ownership of the WebUIDataSource.
67 WebUIDataSource::Add(web_ui
->GetWebContents()->GetBrowserContext(),
68 CreateDataSource().release());
71 CopresenceUI::~CopresenceUI() {}