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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/help/help_ui.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/webui/help/help_handler.h"
9 #include "chrome/common/url_constants.h"
10 #include "content/public/browser/web_contents.h"
11 #include "content/public/browser/web_ui.h"
12 #include "content/public/browser/web_ui_data_source.h"
13 #include "grit/browser_resources.h"
17 content::WebUIDataSource
* CreateAboutPageHTMLSource() {
18 content::WebUIDataSource
* source
=
19 content::WebUIDataSource::Create(chrome::kChromeUIHelpFrameHost
);
21 source
->SetJsonPath("strings.js");
22 source
->SetUseJsonJSFormatV2();
23 source
->AddResourcePath("help.js", IDR_HELP_JS
);
24 source
->AddResourcePath("help_focus_manager.js", IDR_HELP_FOCUS_MANAGER_JS
);
25 source
->AddResourcePath("help_base_page.js", IDR_HELP_BASE_PAGE_JS
);
26 source
->AddResourcePath("channel_change_page.js", IDR_CHANNEL_CHANGE_PAGE_JS
);
27 source
->SetDefaultResource(IDR_HELP_HTML
);
28 source
->DisableDenyXFrameOptions();
34 HelpUI::HelpUI(content::WebUI
* web_ui
)
35 : WebUIController(web_ui
) {
36 Profile
* profile
= Profile::FromWebUI(web_ui
);
37 content::WebUIDataSource
* source
= CreateAboutPageHTMLSource();
39 HelpHandler
* handler
= new HelpHandler();
40 handler
->GetLocalizedValues(source
);
41 content::WebUIDataSource::Add(profile
, source
);
42 web_ui
->AddMessageHandler(handler
);