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
->SetUseJsonJSFormatV2();
37 source
->AddLocalizedStrings(localized_strings
);
38 source
->SetJsonPath("strings.js");
39 source
->SetDefaultResource(IDR_BLUETOOTH_PAIR_DEVICE_HTML
);
40 source
->DisableContentSecurityPolicy();
42 Profile
* profile
= Profile::FromWebUI(web_ui
);
43 content::WebUIDataSource::Add(profile
, source
);
46 BluetoothPairingUI::~BluetoothPairingUI() {
47 // Uninitialize all registered handlers. The base class owns them and it will
48 // eventually delete them.
49 core_handler_
->Uninitialize();
50 bluetooth_handler_
->Uninitialize();
53 void BluetoothPairingUI::InitializeHandlers() {
54 core_handler_
->InitializeHandler();
55 bluetooth_handler_
->InitializeHandler();
56 core_handler_
->InitializePage();
57 bluetooth_handler_
->InitializePage();
60 } // namespace chromeos