summaryrefslogtreecommitdiff
path: root/chromium/chrome/browser/ui/webui/chromeos/cryptohome_ui.cc
blob: b17e55cd4811f378409c7c0a0cb4813de53066f5 (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
// 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/chromeos/cryptohome_ui.h"

#include <memory>

#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/cryptohome_web_ui_handler.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"

namespace chromeos {

namespace {

// Returns HTML data source for chrome://cryptohome.
content::WebUIDataSource* CreateCryptohomeUIHTMLSource() {
  content::WebUIDataSource* source =
      content::WebUIDataSource::Create(chrome::kChromeUICryptohomeHost);
  source->AddResourcePath("cryptohome.js", IDR_CRYPTOHOME_JS);
  source->SetDefaultResource(IDR_CRYPTOHOME_HTML);
  return source;
}

}  // namespace

CryptohomeUI::CryptohomeUI(content::WebUI* web_ui) : WebUIController(web_ui) {
  web_ui->AddMessageHandler(std::make_unique<CryptohomeWebUIHandler>());

  Profile* profile = Profile::FromWebUI(web_ui);
  content::WebUIDataSource::Add(profile, CreateCryptohomeUIHTMLSource());
}

}  // namespace chromeos