Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / webui / extensions / extensions_ui.cc
blob6fd8604c5bf1d9e2adbe76d703775b25208b4ada
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/extensions/extensions_ui.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/webui/extensions/command_handler.h"
9 #include "chrome/browser/ui/webui/extensions/extension_error_handler.h"
10 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h"
11 #include "chrome/browser/ui/webui/extensions/install_extension_handler.h"
12 #include "chrome/browser/ui/webui/extensions/pack_extension_handler.h"
13 #include "chrome/browser/ui/webui/metrics_handler.h"
14 #include "chrome/common/url_constants.h"
15 #include "content/public/browser/web_ui.h"
16 #include "content/public/browser/web_ui_data_source.h"
17 #include "grit/browser_resources.h"
18 #include "grit/theme_resources.h"
19 #include "ui/base/resource/resource_bundle.h"
21 #if defined(OS_CHROMEOS)
22 #include "chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h"
23 #endif
25 namespace extensions {
27 namespace {
29 content::WebUIDataSource* CreateExtensionsHTMLSource() {
30 content::WebUIDataSource* source =
31 content::WebUIDataSource::Create(chrome::kChromeUIExtensionsFrameHost);
33 source->SetUseJsonJSFormatV2();
34 source->SetJsonPath("strings.js");
35 source->AddResourcePath("extensions.js", IDR_EXTENSIONS_JS);
36 source->AddResourcePath("extension_command_list.js",
37 IDR_EXTENSION_COMMAND_LIST_JS);
38 source->AddResourcePath("extension_list.js", IDR_EXTENSION_LIST_JS);
39 source->SetDefaultResource(IDR_EXTENSIONS_HTML);
40 source->DisableDenyXFrameOptions();
41 return source;
44 } // namespace
46 ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
47 Profile* profile = Profile::FromWebUI(web_ui);
48 content::WebUIDataSource* source = CreateExtensionsHTMLSource();
50 ExtensionSettingsHandler* handler = new ExtensionSettingsHandler();
51 handler->GetLocalizedValues(source);
52 web_ui->AddMessageHandler(handler);
54 PackExtensionHandler* pack_handler = new PackExtensionHandler();
55 pack_handler->GetLocalizedValues(source);
56 web_ui->AddMessageHandler(pack_handler);
58 CommandHandler* commands_handler = new CommandHandler(profile);
59 commands_handler->GetLocalizedValues(source);
60 web_ui->AddMessageHandler(commands_handler);
62 ExtensionErrorHandler* extension_error_handler =
63 new ExtensionErrorHandler(profile);
64 extension_error_handler->GetLocalizedValues(source);
65 web_ui->AddMessageHandler(extension_error_handler);
67 InstallExtensionHandler* install_extension_handler =
68 new InstallExtensionHandler();
69 install_extension_handler->GetLocalizedValues(source);
70 web_ui->AddMessageHandler(install_extension_handler);
72 #if defined(OS_CHROMEOS)
73 chromeos::KioskAppsHandler* kiosk_app_handler =
74 new chromeos::KioskAppsHandler();
75 kiosk_app_handler->GetLocalizedValues(source);
76 web_ui->AddMessageHandler(kiosk_app_handler);
77 #endif
79 web_ui->AddMessageHandler(new MetricsHandler());
81 content::WebUIDataSource::Add(profile, source);
84 ExtensionsUI::~ExtensionsUI() {}
86 // static
87 base::RefCountedMemory* ExtensionsUI::GetFaviconResourceBytes(
88 ui::ScaleFactor scale_factor) {
89 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
90 return rb.LoadDataResourceBytesForScale(IDR_EXTENSIONS_FAVICON, scale_factor);
93 } // namespace extensions