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/extensions/extensions_ui.h" | 5 #include "chrome/browser/ui/webui/extensions/extensions_ui.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 8 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
9 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 9 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 10 #include "chrome/browser/ui/webui/extensions/install_extension_handler.h" |
10 #include "chrome/browser/ui/webui/extensions/pack_extension_handler.h" | 11 #include "chrome/browser/ui/webui/extensions/pack_extension_handler.h" |
11 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h" | 12 #include "chrome/browser/ui/webui/extensions/extension_settings_handler.h" |
12 #include "chrome/browser/ui/webui/shared_resources_data_source.h" | 13 #include "chrome/browser/ui/webui/shared_resources_data_source.h" |
13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
14 #include "content/public/browser/web_contents.h" | |
15 #include "content/public/browser/web_ui.h" | 15 #include "content/public/browser/web_ui.h" |
16 #include "grit/browser_resources.h" | 16 #include "grit/browser_resources.h" |
17 | 17 |
18 using content::WebContents; | |
19 | |
20 namespace { | 18 namespace { |
21 | 19 |
22 ChromeWebUIDataSource* CreateExtensionsHTMLSource() { | 20 ChromeWebUIDataSource* CreateExtensionsHTMLSource() { |
23 ChromeWebUIDataSource* source = | 21 ChromeWebUIDataSource* source = |
24 new ChromeWebUIDataSource(chrome::kChromeUIExtensionsFrameHost); | 22 new ChromeWebUIDataSource(chrome::kChromeUIExtensionsFrameHost); |
25 | 23 |
26 source->set_use_json_js_format_v2(); | 24 source->set_use_json_js_format_v2(); |
27 source->set_json_path("strings.js"); | 25 source->set_json_path("strings.js"); |
28 source->add_resource_path("extensions.js", IDR_EXTENSIONS_JS); | 26 source->add_resource_path("extensions.js", IDR_EXTENSIONS_JS); |
29 source->add_resource_path("extension_list.js", IDR_EXTENSION_LIST_JS); | 27 source->add_resource_path("extension_list.js", IDR_EXTENSION_LIST_JS); |
30 source->set_default_resource(IDR_EXTENSIONS_HTML); | 28 source->set_default_resource(IDR_EXTENSIONS_HTML); |
31 return source; | 29 return source; |
32 } | 30 } |
33 | 31 |
34 } // namespace | 32 } // namespace |
35 | 33 |
36 ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 34 ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
37 Profile* profile = Profile::FromWebUI(web_ui); | 35 Profile* profile = Profile::FromWebUI(web_ui); |
38 ChromeWebUIDataSource* source = CreateExtensionsHTMLSource(); | 36 ChromeWebUIDataSource* source = CreateExtensionsHTMLSource(); |
39 ChromeURLDataManager::AddDataSource(profile, source); | 37 ChromeURLDataManager::AddDataSource(profile, source); |
40 ChromeURLDataManager::AddDataSource(profile, new SharedResourcesDataSource()); | 38 ChromeURLDataManager::AddDataSource(profile, new SharedResourcesDataSource()); |
41 | 39 |
42 ExtensionSettingsHandler* handler = new ExtensionSettingsHandler(); | 40 ExtensionSettingsHandler* handler = new ExtensionSettingsHandler(); |
43 handler->GetLocalizedValues(source->localized_strings()); | 41 handler->GetLocalizedValues(source->localized_strings()); |
44 web_ui->AddMessageHandler(handler); | 42 web_ui->AddMessageHandler(handler); |
45 | 43 |
46 PackExtensionHandler* pack_handler = new PackExtensionHandler(); | 44 PackExtensionHandler* pack_handler = new PackExtensionHandler(); |
47 pack_handler->GetLocalizedValues(source->localized_strings()); | 45 pack_handler->GetLocalizedValues(source->localized_strings()); |
48 web_ui->AddMessageHandler(pack_handler); | 46 web_ui->AddMessageHandler(pack_handler); |
| 47 |
| 48 InstallExtensionHandler* install_extension_handler = |
| 49 new InstallExtensionHandler(); |
| 50 install_extension_handler->GetLocalizedValues(source->localized_strings()); |
| 51 web_ui->AddMessageHandler(install_extension_handler); |
49 } | 52 } |
50 | 53 |
51 ExtensionsUI::~ExtensionsUI() { | 54 ExtensionsUI::~ExtensionsUI() { |
52 } | 55 } |
OLD | NEW |