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