2152f814490039a7e74c0b584c7ab601f035ff50
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / quota_internals / quota_internals_ui.cc
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.
4
5 #include "chrome/browser/ui/webui/quota_internals/quota_internals_ui.h"
6
7 #include <string>
8
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/webui/quota_internals/quota_internals_handler.h"
11 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/web_contents.h"
13 #include "content/public/browser/web_ui.h"
14 #include "content/public/browser/web_ui_data_source.h"
15 #include "grit/quota_internals_resources.h"
16
17 using content::WebContents;
18
19 namespace {
20
21 content::WebUIDataSource* CreateQuotaInternalsHTMLSource() {
22   content::WebUIDataSource* source =
23       content::WebUIDataSource::Create(chrome::kChromeUIQuotaInternalsHost);
24
25   source->SetUseJsonJSFormatV2();
26   source->SetJsonPath("strings.js");
27   source->AddResourcePath(
28       "event_handler.js", IDR_QUOTA_INTERNALS_EVENT_HANDLER_JS);
29   source->AddResourcePath(
30       "message_dispatcher.js", IDR_QUOTA_INTERNALS_MESSAGE_DISPATCHER_JS);
31   source->SetDefaultResource(IDR_QUOTA_INTERNALS_MAIN_HTML);
32   return source;
33 }
34
35 }  // namespace
36
37 QuotaInternalsUI::QuotaInternalsUI(content::WebUI* web_ui)
38     : WebUIController(web_ui) {
39   web_ui->AddMessageHandler(new quota_internals::QuotaInternalsHandler);
40   Profile* profile = Profile::FromWebUI(web_ui);
41   content::WebUIDataSource::Add(profile, CreateQuotaInternalsHTMLSource());
42 }