- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / chromeos / first_run / first_run_ui.cc
1 // Copyright 2013 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/chromeos/first_run/first_run_ui.h"
6
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/webui/chromeos/first_run/first_run_handler.h"
9 #include "chrome/common/url_constants.h"
10 #include "content/public/browser/web_ui.h"
11 #include "content/public/browser/web_ui_data_source.h"
12 #include "grit/browser_resources.h"
13 #include "ui/base/webui/web_ui_util.h"
14
15 namespace {
16
17 const char kFirstRunJSPath[] = "first_run.js";
18
19 content::WebUIDataSource* CreateDataSource() {
20   content::WebUIDataSource* source =
21       content::WebUIDataSource::Create(chrome::kChromeUIFirstRunHost);
22   source->SetUseJsonJSFormatV2();
23   source->SetJsonPath("strings.js");
24   source->SetDefaultResource(IDR_FIRST_RUN_HTML);
25   source->AddResourcePath(kFirstRunJSPath, IDR_FIRST_RUN_JS);
26   base::DictionaryValue localized_strings;
27   webui::SetFontAndTextDirection(&localized_strings);
28   source->AddLocalizedStrings(localized_strings);
29   return source;
30 }
31
32 }  // anonymous namespace
33
34 namespace chromeos {
35
36 FirstRunUI::FirstRunUI(content::WebUI* web_ui)
37     : WebUIController(web_ui),
38       actor_(NULL) {
39   FirstRunHandler* handler = new FirstRunHandler();
40   actor_ = handler;
41   web_ui->AddMessageHandler(handler);
42   content::WebUIDataSource::Add(Profile::FromWebUI(web_ui), CreateDataSource());
43 }
44
45 }  // namespace chromeos
46