Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / webui / chromeos / bluetooth_pairing_ui.cc
1 // Copyright (c) 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/bluetooth_pairing_ui.h"
6
7 #include "base/values.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h"
10 #include "chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.h"
11 #include "chrome/common/url_constants.h"
12 #include "content/public/browser/web_ui.h"
13 #include "content/public/browser/web_ui_data_source.h"
14 #include "grit/browser_resources.h"
15
16 using content::WebContents;
17 using content::WebUIMessageHandler;
18
19 namespace chromeos {
20
21 BluetoothPairingUI::BluetoothPairingUI(content::WebUI* web_ui)
22     : WebDialogUI(web_ui),
23       core_handler_(new options::CoreChromeOSOptionsHandler()),
24       bluetooth_handler_(new options::BluetoothOptionsHandler()) {
25   base::DictionaryValue localized_strings;
26
27   web_ui->AddMessageHandler(core_handler_);
28   core_handler_->set_handlers_host(this);
29   core_handler_->GetLocalizedValues(&localized_strings);
30
31   web_ui->AddMessageHandler(bluetooth_handler_);
32   bluetooth_handler_->GetLocalizedValues(&localized_strings);
33
34   content::WebUIDataSource* source =
35       content::WebUIDataSource::Create(chrome::kChromeUIBluetoothPairingHost);
36   source->AddLocalizedStrings(localized_strings);
37   source->SetJsonPath("strings.js");
38   source->SetDefaultResource(IDR_BLUETOOTH_PAIR_DEVICE_HTML);
39   source->DisableContentSecurityPolicy();
40
41   Profile* profile = Profile::FromWebUI(web_ui);
42   content::WebUIDataSource::Add(profile, source);
43 }
44
45 BluetoothPairingUI::~BluetoothPairingUI() {
46   // Uninitialize all registered handlers. The base class owns them and it will
47   // eventually delete them.
48   core_handler_->Uninitialize();
49   bluetooth_handler_->Uninitialize();
50 }
51
52 void BluetoothPairingUI::InitializeHandlers() {
53   core_handler_->InitializeHandler();
54   bluetooth_handler_->InitializeHandler();
55   core_handler_->InitializePage();
56   bluetooth_handler_->InitializePage();
57 }
58
59 }  // namespace chromeos