summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/extensions/extensions_ui.cc
blob: 37424d434bc055454ac2886c19305846e9523d48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/webui/extensions/extensions_ui.h"

#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chrome_url_data_manager.h"
#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
#include "chrome/browser/ui/webui/options/pack_extension_handler.h"
#include "chrome/browser/ui/webui/options/extension_settings_handler.h"
#include "chrome/browser/ui/webui/shared_resources_data_source.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "grit/browser_resources.h"

using content::WebContents;

namespace {

ChromeWebUIDataSource* CreateExtensionsHTMLSource() {
  ChromeWebUIDataSource* source =
      new ChromeWebUIDataSource(chrome::kChromeUIExtensionsFrameHost);

  source->set_json_path("strings.js");
  source->add_resource_path("extensions.js", IDR_EXTENSIONS_JS);
  source->add_resource_path("extension_list.js", IDR_EXTENSION_LIST_JS);
  source->set_default_resource(IDR_EXTENSIONS_HTML);
  return source;
}

}  // namespace

ExtensionsUI::ExtensionsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
  Profile* profile = Profile::FromWebUI(web_ui);
  ChromeWebUIDataSource* source = CreateExtensionsHTMLSource();
  profile->GetChromeURLDataManager()->AddDataSource(source);
  profile->GetChromeURLDataManager()->AddDataSource(
      new SharedResourcesDataSource());

  ExtensionSettingsHandler* handler = new ExtensionSettingsHandler();
  handler->GetLocalizedValues(source->localized_strings());
  web_ui->AddMessageHandler(handler);

  PackExtensionHandler* pack_handler = new PackExtensionHandler();
  pack_handler->GetLocalizedValues(source->localized_strings());
  web_ui->AddMessageHandler(pack_handler);
}

ExtensionsUI::~ExtensionsUI() {
}