Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: components/dom_distiller/webui/dom_distiller_ui.cc

Issue 151003006: Add support for distilling arbitrary URLs in DOM Distiller Viewer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added new strings to iOS whitelist Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/dom_distiller/webui/dom_distiller_ui.h" 5 #include "components/dom_distiller/webui/dom_distiller_ui.h"
6 6
7 #include "components/dom_distiller/core/dom_distiller_constants.h" 7 #include "components/dom_distiller/core/dom_distiller_constants.h"
8 #include "components/dom_distiller/core/dom_distiller_service.h" 8 #include "components/dom_distiller/core/dom_distiller_service.h"
9 #include "components/dom_distiller/webui/dom_distiller_handler.h" 9 #include "components/dom_distiller/webui/dom_distiller_handler.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
11 #include "content/public/browser/web_contents.h" 11 #include "content/public/browser/web_contents.h"
12 #include "content/public/browser/web_ui.h" 12 #include "content/public/browser/web_ui.h"
13 #include "content/public/browser/web_ui_data_source.h" 13 #include "content/public/browser/web_ui_data_source.h"
14 #include "grit/component_resources.h" 14 #include "grit/component_resources.h"
15 #include "grit/component_strings.h" 15 #include "grit/component_strings.h"
16 16
17 namespace dom_distiller { 17 namespace dom_distiller {
18 18
19 DomDistillerUi::DomDistillerUi(content::WebUI* web_ui, 19 DomDistillerUi::DomDistillerUi(content::WebUI* web_ui,
20 DomDistillerService* service, 20 DomDistillerService* service,
21 const std::string& scheme) 21 const std::string& scheme)
22 : content::WebUIController(web_ui) { 22 : content::WebUIController(web_ui) {
23 // Set up WebUIDataSource. 23 // Set up WebUIDataSource.
24 content::WebUIDataSource* source = 24 content::WebUIDataSource* source =
25 content::WebUIDataSource::Create(kChromeUIDomDistillerHost); 25 content::WebUIDataSource::Create(kChromeUIDomDistillerHost);
26 source->SetDefaultResource(IDR_ABOUT_DOM_DISTILLER_HTML); 26 source->SetDefaultResource(IDR_ABOUT_DOM_DISTILLER_HTML);
27 source->AddResourcePath("about_dom_distiller.css", 27 source->AddResourcePath("about_dom_distiller.css",
28 IDR_ABOUT_DOM_DISTILLER_CSS); 28 IDR_ABOUT_DOM_DISTILLER_CSS);
29 source->AddResourcePath("about_dom_distiller.js", 29 source->AddResourcePath("about_dom_distiller.js", IDR_ABOUT_DOM_DISTILLER_JS);
30 IDR_ABOUT_DOM_DISTILLER_JS);
31 30
32 source->SetUseJsonJSFormatV2(); 31 source->SetUseJsonJSFormatV2();
33 source->AddLocalizedString("domDistillerTitle", 32 source->AddLocalizedString("domDistillerTitle",
34 IDS_DOM_DISTILLER_WEBUI_TITLE); 33 IDS_DOM_DISTILLER_WEBUI_TITLE);
35 source->AddLocalizedString("addArticleUrl", 34 source->AddLocalizedString("addArticleUrl",
36 IDS_DOM_DISTILLER_WEBUI_ENTRY_URL); 35 IDS_DOM_DISTILLER_WEBUI_ENTRY_URL);
37 source->AddLocalizedString("addArticleAddButtonLabel", 36 source->AddLocalizedString("addArticleAddButtonLabel",
38 IDS_DOM_DISTILLER_WEBUI_ENTRY_ADD); 37 IDS_DOM_DISTILLER_WEBUI_ENTRY_ADD);
39 source->AddLocalizedString("addArticleFailedLabel", 38 source->AddLocalizedString("addArticleFailedLabel",
40 IDS_DOM_DISTILLER_WEBUI_ENTRY_ADD_FAILED); 39 IDS_DOM_DISTILLER_WEBUI_ENTRY_ADD_FAILED);
40 source->AddLocalizedString("viewUrlButtonLabel",
41 IDS_DOM_DISTILLER_WEBUI_VIEW_URL);
42 source->AddLocalizedString("viewUrlFailedLabel",
43 IDS_DOM_DISTILLER_WEBUI_VIEW_URL_FAILED);
41 source->AddLocalizedString("loadingEntries", 44 source->AddLocalizedString("loadingEntries",
42 IDS_DOM_DISTILLER_WEBUI_FETCHING_ENTRIES); 45 IDS_DOM_DISTILLER_WEBUI_FETCHING_ENTRIES);
43 source->AddLocalizedString("refreshButtonLabel", 46 source->AddLocalizedString("refreshButtonLabel",
44 IDS_DOM_DISTILLER_WEBUI_REFRESH); 47 IDS_DOM_DISTILLER_WEBUI_REFRESH);
45 48
46 content::BrowserContext* browser_context = 49 content::BrowserContext* browser_context =
47 web_ui->GetWebContents()->GetBrowserContext(); 50 web_ui->GetWebContents()->GetBrowserContext();
48 content::WebUIDataSource::Add(browser_context, source); 51 content::WebUIDataSource::Add(browser_context, source);
49 source->SetJsonPath("strings.js"); 52 source->SetJsonPath("strings.js");
50 53
51 // Add message handler. 54 // Add message handler.
52 web_ui->AddMessageHandler(new DomDistillerHandler(service, scheme)); 55 web_ui->AddMessageHandler(new DomDistillerHandler(service, scheme));
53 } 56 }
54 57
55 DomDistillerUi::~DomDistillerUi() {} 58 DomDistillerUi::~DomDistillerUi() {}
56 59
57 } // namespace dom_distiller 60 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698