Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / dom_distiller / webui / dom_distiller_ui.cc
1 // Copyright 2013 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 "components/dom_distiller/webui/dom_distiller_ui.h"
6
7 #include "components/dom_distiller/core/dom_distiller_constants.h"
8 #include "components/dom_distiller/core/dom_distiller_service.h"
9 #include "components/dom_distiller/webui/dom_distiller_handler.h"
10 #include "content/public/browser/browser_context.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/components_resources.h"
15 #include "grit/components_strings.h"
16
17 namespace dom_distiller {
18
19 DomDistillerUi::DomDistillerUi(content::WebUI* web_ui,
20                                DomDistillerService* service,
21                                const std::string& scheme)
22     : content::WebUIController(web_ui) {
23   // Set up WebUIDataSource.
24   content::WebUIDataSource* source =
25       content::WebUIDataSource::Create(kChromeUIDomDistillerHost);
26   source->SetDefaultResource(IDR_ABOUT_DOM_DISTILLER_HTML);
27   source->AddResourcePath("about_dom_distiller.css",
28                           IDR_ABOUT_DOM_DISTILLER_CSS);
29   source->AddResourcePath("about_dom_distiller.js", IDR_ABOUT_DOM_DISTILLER_JS);
30
31   source->AddLocalizedString("domDistillerTitle",
32                              IDS_DOM_DISTILLER_WEBUI_TITLE);
33   source->AddLocalizedString("addArticleUrl",
34                              IDS_DOM_DISTILLER_WEBUI_ENTRY_URL);
35   source->AddLocalizedString("addArticleAddButtonLabel",
36                              IDS_DOM_DISTILLER_WEBUI_ENTRY_ADD);
37   source->AddLocalizedString("addArticleFailedLabel",
38                              IDS_DOM_DISTILLER_WEBUI_ENTRY_ADD_FAILED);
39   source->AddLocalizedString("viewUrlButtonLabel",
40                              IDS_DOM_DISTILLER_WEBUI_VIEW_URL);
41   source->AddLocalizedString("viewUrlFailedLabel",
42                              IDS_DOM_DISTILLER_WEBUI_VIEW_URL_FAILED);
43   source->AddLocalizedString("loadingEntries",
44                              IDS_DOM_DISTILLER_WEBUI_FETCHING_ENTRIES);
45   source->AddLocalizedString("refreshButtonLabel",
46                              IDS_DOM_DISTILLER_WEBUI_REFRESH);
47
48   content::BrowserContext* browser_context =
49       web_ui->GetWebContents()->GetBrowserContext();
50   content::WebUIDataSource::Add(browser_context, source);
51   source->SetJsonPath("strings.js");
52
53   // Add message handler.
54   web_ui->AddMessageHandler(new DomDistillerHandler(service, scheme));
55 }
56
57 DomDistillerUi::~DomDistillerUi() {}
58
59 }  // namespace dom_distiller