OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/webui/help/help_ui.h" | 5 #include "chrome/browser/ui/webui/help/help_ui.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/webui/help/help_handler.h" | 8 #include "chrome/browser/ui/webui/help/help_handler.h" |
9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
11 #include "content/public/browser/web_ui.h" | 11 #include "content/public/browser/web_ui.h" |
12 #include "content/public/browser/web_ui_data_source.h" | 12 #include "content/public/browser/web_ui_data_source.h" |
13 #include "grit/browser_resources.h" | 13 #include "grit/browser_resources.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 content::WebUIDataSource* CreateAboutPageHTMLSource() { | 17 content::WebUIDataSource* CreateAboutPageHTMLSource() { |
18 content::WebUIDataSource* source = | 18 content::WebUIDataSource* source = |
19 content::WebUIDataSource::Create(chrome::kChromeUIHelpFrameHost); | 19 content::WebUIDataSource::Create(chrome::kChromeUIHelpFrameHost); |
20 | 20 |
21 source->SetJsonPath("strings.js"); | 21 source->SetJsonPath("strings.js"); |
22 source->SetUseJsonJSFormatV2(); | |
23 source->AddResourcePath("help.js", IDR_HELP_JS); | 22 source->AddResourcePath("help.js", IDR_HELP_JS); |
24 source->AddResourcePath("help_page.js", IDR_HELP_PAGE_JS); | 23 source->AddResourcePath("help_page.js", IDR_HELP_PAGE_JS); |
25 source->AddResourcePath("channel_change_page.js", IDR_CHANNEL_CHANGE_PAGE_JS); | 24 source->AddResourcePath("channel_change_page.js", IDR_CHANNEL_CHANGE_PAGE_JS); |
26 source->SetDefaultResource(IDR_HELP_HTML); | 25 source->SetDefaultResource(IDR_HELP_HTML); |
27 source->DisableDenyXFrameOptions(); | 26 source->DisableDenyXFrameOptions(); |
28 return source; | 27 return source; |
29 } | 28 } |
30 | 29 |
31 } // namespace | 30 } // namespace |
32 | 31 |
33 HelpUI::HelpUI(content::WebUI* web_ui) | 32 HelpUI::HelpUI(content::WebUI* web_ui) |
34 : WebUIController(web_ui) { | 33 : WebUIController(web_ui) { |
35 Profile* profile = Profile::FromWebUI(web_ui); | 34 Profile* profile = Profile::FromWebUI(web_ui); |
36 content::WebUIDataSource* source = CreateAboutPageHTMLSource(); | 35 content::WebUIDataSource* source = CreateAboutPageHTMLSource(); |
37 | 36 |
38 HelpHandler* handler = new HelpHandler(); | 37 HelpHandler* handler = new HelpHandler(); |
39 base::DictionaryValue localized_strings; | 38 base::DictionaryValue localized_strings; |
40 HelpHandler::GetLocalizedValues(&localized_strings); | 39 HelpHandler::GetLocalizedValues(&localized_strings); |
41 source->AddLocalizedStrings(localized_strings); | 40 source->AddLocalizedStrings(localized_strings); |
42 content::WebUIDataSource::Add(profile, source); | 41 content::WebUIDataSource::Add(profile, source); |
43 web_ui->AddMessageHandler(handler); | 42 web_ui->AddMessageHandler(handler); |
44 } | 43 } |
45 | 44 |
46 HelpUI::~HelpUI() { | 45 HelpUI::~HelpUI() { |
47 } | 46 } |
OLD | NEW |