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.
5 #include "chrome/browser/ui/webui/chromeos/bluetooth_pairing_ui.h"
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"
16 using content::WebContents
;
17 using content::WebUIMessageHandler
;
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
;
27 web_ui
->AddMessageHandler(core_handler_
);
28 core_handler_
->set_handlers_host(this);
29 core_handler_
->GetLocalizedValues(&localized_strings
);
31 web_ui
->AddMessageHandler(bluetooth_handler_
);
32 bluetooth_handler_
->GetLocalizedValues(&localized_strings
);
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();
41 Profile
* profile
= Profile::FromWebUI(web_ui
);
42 content::WebUIDataSource::Add(profile
, source
);
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();
52 void BluetoothPairingUI::InitializeHandlers() {
53 core_handler_
->InitializeHandler();
54 bluetooth_handler_
->InitializeHandler();
55 core_handler_
->InitializePage();
56 bluetooth_handler_
->InitializePage();
59 } // namespace chromeos