summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-24 00:36:35 +0000
committerjennyz@chromium.org <jennyz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-24 00:36:35 +0000
commit424d1bb2d46d3dc43713ed4e347a7f12182f0491 (patch)
tree01d0bd883795ed7199fbbf94e3aedc41d92cb174
parent5c9a983de3d304293cc7051cb726fed2241eb9f2 (diff)
downloadchromium_src-424d1bb2d46d3dc43713ed4e347a7f12182f0491.zip
chromium_src-424d1bb2d46d3dc43713ed4e347a7f12182f0491.tar.gz
chromium_src-424d1bb2d46d3dc43713ed4e347a7f12182f0491.tar.bz2
Make Bluetooth pairing dialog working from uber tray.
TBR=sky BUG=130698 Review URL: https://codereview.chromium.org/12047057 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178437 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_resources.grd1
-rw-r--r--chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.cc102
-rw-r--r--chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h56
-rw-r--r--chrome/browser/chromeos/system/ash_system_tray_delegate.cc6
-rw-r--r--chrome/browser/resources/chromeos/bluetooth_options.js39
-rw-r--r--chrome/browser/resources/chromeos/bluetooth_pair_device.css16
-rw-r--r--chrome/browser/resources/chromeos/bluetooth_pair_device.html42
-rw-r--r--chrome/browser/resources/chromeos/bluetooth_pair_device.js52
-rw-r--r--chrome/browser/resources/chromeos/browser_options.js64
-rw-r--r--chrome/browser/resources/chromeos/fake_bluetooth_overlay_parent.js37
-rw-r--r--chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc3
-rw-r--r--chrome/browser/ui/webui/chromeos/bluetooth_pairing_ui.cc60
-rw-r--r--chrome/browser/ui/webui/chromeos/bluetooth_pairing_ui.h37
-rw-r--r--chrome/chrome_browser_chromeos.gypi2
-rw-r--r--chrome/chrome_browser_ui.gypi2
-rw-r--r--chrome/common/url_constants.cc2
-rw-r--r--chrome/common/url_constants.h2
17 files changed, 523 insertions, 0 deletions
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index fda712b..bc279e1 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -286,6 +286,7 @@
<include name="IDR_OFFLINE_LOAD_HTML" file="resources\chromeos\offline_load.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_OS_CREDITS_HTML" file="resources\chromeos\about_os_credits.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_PROXY_SETTINGS_HTML" file="resources\chromeos\proxy_settings.html" flattenhtml="true" type="BINDATA" />
+ <include name="IDR_BLUETOOTH_PAIR_DEVICE_HTML" file="resources\chromeos\bluetooth_pair_device.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_SIM_UNLOCK_HTML" file="resources\chromeos\sim_unlock.html" flattenhtml="true" type="BINDATA" />
<include name="IDR_WRENCH_MENU_CSS" file="resources\chromeos\wrench_menu.css" flattenhtml="true" type="BINDATA" />
<include name="IDR_WRENCH_MENU_JS" file="resources\chromeos\wrench_menu.js" flattenhtml="true" type="BINDATA" />
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.cc b/chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.cc
new file mode 100644
index 0000000..c7270d0
--- /dev/null
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.cc
@@ -0,0 +1,102 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h"
+
+#include "base/json/json_writer.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/ui/browser_dialogs.h"
+#include "chrome/common/url_constants.h"
+#include "device/bluetooth/bluetooth_device.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/gfx/size.h"
+
+using content::WebContents;
+using content::WebUIMessageHandler;
+
+namespace chromeos {
+
+namespace {
+
+// Default width/height ratio of screen size.
+const int kDefaultWidth = 480;
+const int kDefaultHeight = 280;
+
+} // namespace
+
+///////////////////////////////////////////////////////////////////////////////
+// BluetoothPairingDialog, public:
+
+BluetoothPairingDialog::BluetoothPairingDialog(
+ gfx::NativeWindow parent_window,
+ const device::BluetoothDevice* device)
+ : parent_window_(parent_window) {
+ device_data_.SetString("address", device->address());
+ device_data_.SetString("name", device->GetName());
+ device_data_.SetBoolean("paired", device->IsPaired());
+ device_data_.SetBoolean("bonded", device->IsBonded());
+ device_data_.SetBoolean("connected", device->IsConnected());
+}
+
+BluetoothPairingDialog::~BluetoothPairingDialog() {
+}
+
+void BluetoothPairingDialog::Show() {
+ chrome::ShowWebDialog(parent_window_,
+ ProfileManager::GetDefaultProfile(),
+ this);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// LoginWebDialog, protected:
+
+ui::ModalType BluetoothPairingDialog::GetDialogModalType() const {
+ return ui::MODAL_TYPE_SYSTEM;
+}
+
+string16 BluetoothPairingDialog::GetDialogTitle() const {
+ return l10n_util::GetStringUTF16(
+ IDS_OPTIONS_SETTINGS_BLUETOOTH_ADD_DEVICE_TITLE);
+}
+
+GURL BluetoothPairingDialog::GetDialogContentURL() const {
+ return GURL(chrome::kChromeUIBluetoothPairingURL);
+}
+
+void BluetoothPairingDialog::GetWebUIMessageHandlers(
+ std::vector<WebUIMessageHandler*>* handlers) const {
+}
+
+void BluetoothPairingDialog::GetDialogSize(gfx::Size* size) const {
+ size->SetSize(kDefaultWidth, kDefaultHeight);
+}
+
+std::string BluetoothPairingDialog::GetDialogArgs() const {
+ std::string data;
+ base::JSONWriter::Write(&device_data_, &data);
+ return data;
+}
+
+void BluetoothPairingDialog::OnDialogClosed(const std::string& json_retval) {
+ delete this;
+}
+
+void BluetoothPairingDialog::OnCloseContents(WebContents* source,
+ bool* out_close_dialog) {
+ if (out_close_dialog)
+ *out_close_dialog = true;
+}
+
+bool BluetoothPairingDialog::ShouldShowDialogTitle() const {
+ return true;
+}
+
+bool BluetoothPairingDialog::HandleContextMenu(
+ const content::ContextMenuParams& params) {
+ // Disable context menu.
+ return true;
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h b/chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h
new file mode 100644
index 0000000..624a7e7
--- /dev/null
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_PAIRING_DIALOG_H_
+#define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_PAIRING_DIALOG_H_
+
+#include <string>
+
+#include "base/compiler_specific.h"
+#include "base/values.h"
+#include "ui/gfx/native_widget_types.h"
+#include "ui/web_dialogs/web_dialog_delegate.h"
+
+namespace device {
+class BluetoothDevice;
+}
+
+namespace chromeos {
+
+// Bluetooth device pairing dialog shown form ash tray bubble.
+class BluetoothPairingDialog : public ui::WebDialogDelegate {
+ public:
+ BluetoothPairingDialog(gfx::NativeWindow parent_window,
+ const device::BluetoothDevice* device);
+ virtual ~BluetoothPairingDialog();
+
+ void Show();
+
+ protected:
+ // ui::WebDialogDelegate implementation.
+ virtual ui::ModalType GetDialogModalType() const OVERRIDE;
+ virtual string16 GetDialogTitle() const OVERRIDE;
+ virtual GURL GetDialogContentURL() const OVERRIDE;
+ virtual void GetWebUIMessageHandlers(
+ std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE;
+ virtual void GetDialogSize(gfx::Size* size) const OVERRIDE;
+ virtual std::string GetDialogArgs() const OVERRIDE;
+ // NOTE: This function deletes this object at the end.
+ virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE;
+ virtual void OnCloseContents(
+ content::WebContents* source, bool* out_close_dialog) OVERRIDE;
+ virtual bool ShouldShowDialogTitle() const OVERRIDE;
+ virtual bool HandleContextMenu(
+ const content::ContextMenuParams& params) OVERRIDE;
+
+ private:
+ gfx::NativeWindow parent_window_;
+ DictionaryValue device_data_;
+
+ DISALLOW_COPY_AND_ASSIGN(BluetoothPairingDialog);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_PAIRING_DIALOG_H_
diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
index 0c8f7ab..8e30cd6 100644
--- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
+++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
@@ -40,6 +40,7 @@
#include "chrome/browser/chromeos/accessibility/accessibility_util.h"
#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
#include "chrome/browser/chromeos/audio/audio_handler.h"
+#include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/drive/drive_system_service.h"
@@ -515,6 +516,11 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
NULL,
base::Bind(&base::DoNothing),
base::Bind(&BluetoothDeviceConnectError));
+ } else { // Show paring dialog for the unpaired device.
+ BluetoothPairingDialog* dialog =
+ new BluetoothPairingDialog(GetNativeWindow(), device);
+ // The dialog deletes itself on close.
+ dialog->Show();
}
}
diff --git a/chrome/browser/resources/chromeos/bluetooth_options.js b/chrome/browser/resources/chromeos/bluetooth_options.js
new file mode 100644
index 0000000..7ddff60
--- /dev/null
+++ b/chrome/browser/resources/chromeos/bluetooth_options.js
@@ -0,0 +1,39 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('options', function() {
+ /** @const */ var OptionsPage = options.OptionsPage;
+
+ /**
+ * Encapsulated handling of the BluetoothOptions calls from
+ * BluetoothOptionsHandler that is registered by the webUI,
+ * ie, BluetoothPairingUI.
+ * @constructor
+ */
+ function BluetoothOptions() {
+ OptionsPage.call(this,
+ 'bluetooth',
+ '',
+ 'bluetooth-container');
+ }
+
+ cr.addSingletonGetter(BluetoothOptions);
+
+ BluetoothOptions.prototype = {
+ __proto__: OptionsPage.prototype,
+
+ /** @override */
+ initializePage: function() {
+ OptionsPage.prototype.initializePage.call(this);
+ },
+ };
+
+ BluetoothOptions.updateDiscovery = function() {
+ };
+
+ // Export
+ return {
+ BluetoothOptions: BluetoothOptions
+ };
+});
diff --git a/chrome/browser/resources/chromeos/bluetooth_pair_device.css b/chrome/browser/resources/chromeos/bluetooth_pair_device.css
new file mode 100644
index 0000000..9f39b84
--- /dev/null
+++ b/chrome/browser/resources/chromeos/bluetooth_pair_device.css
@@ -0,0 +1,16 @@
+/* Copyright (c) 2013 The Chromium Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file. */
+
+.close-button {
+ display: none;
+}
+
+#bluetooth-pairing {
+ border: 0;
+ box-shadow: none;
+}
+
+.overlay .page h1 {
+ display: none;
+}
diff --git a/chrome/browser/resources/chromeos/bluetooth_pair_device.html b/chrome/browser/resources/chromeos/bluetooth_pair_device.html
new file mode 100644
index 0000000..761fbc9
--- /dev/null
+++ b/chrome/browser/resources/chromeos/bluetooth_pair_device.html
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML>
+<html i18n-values="dir:textdirection">
+<head>
+<link rel="stylesheet" href="chrome://resources/css/chrome_shared.css">
+<link rel="stylesheet" href="chrome://resources/css/overlay.css">
+
+<link rel="stylesheet" href="../options/options_page.css">
+<link rel="stylesheet" href="../options/chromeos/bluetooth.css">
+<link rel="stylesheet" href="bluetooth_pair_device.css">
+
+<script src="chrome://resources/js/cr.js"></script>
+<script src="chrome://resources/js/event_tracker.js"></script>
+<script src="chrome://resources/js/cr/event_target.js"></script>
+<script src="chrome://resources/js/cr/ui.js"></script>
+<script src="chrome://resources/js/cr/ui/touch_handler.js"></script>
+<script src="chrome://resources/js/cr/ui/array_data_model.js"></script>
+<script src="chrome://resources/js/local_strings.js"></script>
+<script src="chrome://resources/js/load_time_data.js"></script>
+<script src="chrome://resources/js/util.js"></script>
+<script src="chrome://bluetooth-pairing/strings.js"></script>
+
+<script src="../options/options_page.js"></script>
+<script src="../options/chromeos/bluetooth_pair_device_overlay.js"></script>
+<script src="../uber/uber_utils.js"></script>
+
+<script src="bluetooth_options.js"></script>
+<script src="browser_options.js"></script>
+<script src="fake_bluetooth_overlay_parent.js"></script>
+<script src="bluetooth_pair_device.js"></script>
+</head>
+
+<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
+<div id="overlay-container" class="overlay">
+ <include src="../options/chromeos/bluetooth_pair_device_overlay.html">
+</div>
+<div id="page-container">
+ <div id="bluetooth-container"></div>
+</div>
+<div id="searchBox" hidden><input id="search-field" type=text></div>
+<script src="chrome://resources/js/i18n_template2.js"></script>
+</body>
+</html>
diff --git a/chrome/browser/resources/chromeos/bluetooth_pair_device.js b/chrome/browser/resources/chromeos/bluetooth_pair_device.js
new file mode 100644
index 0000000..9b20449
--- /dev/null
+++ b/chrome/browser/resources/chromeos/bluetooth_pair_device.js
@@ -0,0 +1,52 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var OptionsPage = options.OptionsPage;
+var BluetoothPairing = options.BluetoothPairing;
+var FakeBluetoothOverlayParent = options.FakeBluetoothOverlayParent;
+
+/** @override */
+OptionsPage.closeOverlay = function() {
+ chrome.send('DialogClose');
+};
+
+/**
+ * DOMContentLoaded handler, sets up the page.
+ */
+function load() {
+ if (cr.isChromeOS)
+ document.documentElement.setAttribute('os', 'chromeos');
+
+ // Decorate the existing elements in the document.
+ cr.ui.decorate('input[pref][type=checkbox]', options.PrefCheckbox);
+ cr.ui.decorate('input[pref][type=number]', options.PrefNumber);
+ cr.ui.decorate('input[pref][type=radio]', options.PrefRadio);
+ cr.ui.decorate('input[pref][type=range]', options.PrefRange);
+ cr.ui.decorate('select[pref]', options.PrefSelect);
+ cr.ui.decorate('input[pref][type=text]', options.PrefTextField);
+ cr.ui.decorate('input[pref][type=url]', options.PrefTextField);
+
+ // TODO(ivankr): remove when http://crosbug.com/20660 is resolved.
+ var inputs = document.querySelectorAll('input[pref]');
+ for (var i = 0, el; el = inputs[i]; i++) {
+ el.addEventListener('keyup', function(e) {
+ cr.dispatchSimpleEvent(this, 'change');
+ });
+ }
+
+ chrome.send('coreOptionsInitialize');
+
+ OptionsPage.register(FakeBluetoothOverlayParent.getInstance());
+ OptionsPage.registerOverlay(BluetoothPairing.getInstance(),
+ FakeBluetoothOverlayParent.getInstance());
+
+ var device = {};
+ var args = JSON.parse(chrome.getVariableValue('dialogArguments'));
+ device = args;
+ device.pairing = 'bluetoothStartConnecting';
+ BluetoothPairing.showDialog(device);
+ chrome.send('updateBluetoothDevice', [device.address, 'connect']);
+}
+
+document.addEventListener('DOMContentLoaded', load);
diff --git a/chrome/browser/resources/chromeos/browser_options.js b/chrome/browser/resources/chromeos/browser_options.js
new file mode 100644
index 0000000..938e97e
--- /dev/null
+++ b/chrome/browser/resources/chromeos/browser_options.js
@@ -0,0 +1,64 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('options', function() {
+ /** @const */ var OptionsPage = options.OptionsPage;
+
+ /**
+ * Encapsulated handling of the BrowserOptions calls from
+ * BluetoothOptionsHandler that is registered by the webUI,
+ * ie, BluetoothPairingUI.
+ * @constructor
+ */
+ function BrowserOptions() {
+ OptionsPage.call(this,
+ 'bluetooth',
+ '',
+ 'bluetooth-container');
+ }
+
+ cr.addSingletonGetter(BrowserOptions);
+
+ BrowserOptions.prototype = {
+ __proto__: OptionsPage.prototype,
+
+ /** @override */
+ initializePage: function() {
+ OptionsPage.prototype.initializePage.call(this);
+ },
+ };
+
+ BrowserOptions.showBluetoothSettings = function() {
+ };
+
+ BrowserOptions.setBluetoothState = function() {
+ };
+
+ /**
+ * Handles addBluetoothDevice call, display the Bluetooth pairing overlay
+ * for the pairing device.
+ * @param {{name: string,
+ * address: string,
+ * paired: boolean,
+ * bonded: boolean,
+ * pairing: string | undefined
+ * pincode: string | undefined
+ * passkey: number | undefined
+ * connected: boolean}} device
+ */
+ BrowserOptions.addBluetoothDevice = function(device) {
+ // One device can be in the process of pairing. If found, display
+ // the Bluetooth pairing overlay.
+ if (device.pairing)
+ BluetoothPairing.showDialog(device);
+ };
+
+ BrowserOptions.removeBluetoothDevice = function(address) {
+ };
+
+ // Export
+ return {
+ BrowserOptions: BrowserOptions
+ };
+});
diff --git a/chrome/browser/resources/chromeos/fake_bluetooth_overlay_parent.js b/chrome/browser/resources/chromeos/fake_bluetooth_overlay_parent.js
new file mode 100644
index 0000000..eb154bb
--- /dev/null
+++ b/chrome/browser/resources/chromeos/fake_bluetooth_overlay_parent.js
@@ -0,0 +1,37 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+cr.define('options', function() {
+ var OptionsPage = options.OptionsPage;
+
+ /**
+ * Encapsulated a fake parent page for bluetooth overlay page used by Web UI.
+ * @constructor
+ */
+ function FakeBluetoothOverlayParent(model) {
+ OptionsPage.call(this, 'bluetooth',
+ '',
+ 'bluetooth-container');
+ }
+
+ cr.addSingletonGetter(FakeBluetoothOverlayParent);
+
+ FakeBluetoothOverlayParent.prototype = {
+ // Inherit FakeBluetoothOverlayParent from OptionsPage.
+ __proto__: OptionsPage.prototype,
+
+ /**
+ * Initializes FakeBluetoothOverlayParent page.
+ */
+ initializePage: function() {
+ // Call base class implementation to starts preference initialization.
+ OptionsPage.prototype.initializePage.call(this);
+ },
+ };
+
+ // Export
+ return {
+ FakeBluetoothOverlayParent: FakeBluetoothOverlayParent
+ };
+});
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
index 57b8d52..e271659 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -80,6 +80,7 @@
#endif
#if defined(OS_CHROMEOS)
+#include "chrome/browser/ui/webui/chromeos/bluetooth_pairing_ui.h"
#include "chrome/browser/ui/webui/chromeos/choose_mobile_network_ui.h"
#include "chrome/browser/ui/webui/chromeos/cryptohome_ui.h"
#include "chrome/browser/ui/webui/chromeos/diagnostics/diagnostics_ui.h"
@@ -300,6 +301,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<CertificateViewerUI>;
#endif
#if defined(OS_CHROMEOS)
+ if (url.host() == chrome::kChromeUIBluetoothPairingHost)
+ return &NewWebUI<chromeos::BluetoothPairingUI>;
if (url.host() == chrome::kChromeUIChooseMobileNetworkHost)
return &NewWebUI<chromeos::ChooseMobileNetworkUI>;
if (url.host() == chrome::kChromeUICryptohomeHost)
diff --git a/chrome/browser/ui/webui/chromeos/bluetooth_pairing_ui.cc b/chrome/browser/ui/webui/chromeos/bluetooth_pairing_ui.cc
new file mode 100644
index 0000000..8aa1d68
--- /dev/null
+++ b/chrome/browser/ui/webui/chromeos/bluetooth_pairing_ui.cc
@@ -0,0 +1,60 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/chromeos/bluetooth_pairing_ui.h"
+
+#include "base/values.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
+#include "chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h"
+#include "chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler.h"
+#include "chrome/common/url_constants.h"
+#include "content/public/browser/web_ui.h"
+#include "grit/browser_resources.h"
+
+using content::WebContents;
+using content::WebUIMessageHandler;
+
+namespace chromeos {
+
+BluetoothPairingUI::BluetoothPairingUI(content::WebUI* web_ui)
+ : WebDialogUI(web_ui),
+ core_handler_(new options::CoreChromeOSOptionsHandler()),
+ bluetooth_handler_(new options::BluetoothOptionsHandler()) {
+ DictionaryValue localized_strings;
+
+ core_handler_->set_handlers_host(this);
+ core_handler_->GetLocalizedValues(&localized_strings);
+ web_ui->AddMessageHandler(core_handler_);
+
+ bluetooth_handler_->GetLocalizedValues(&localized_strings);
+ web_ui->AddMessageHandler(bluetooth_handler_);
+
+ content::WebUIDataSource* source =
+ ChromeWebUIDataSource::Create(chrome::kChromeUIBluetoothPairingHost);
+ source->SetUseJsonJSFormatV2();
+ source->AddLocalizedStrings(localized_strings);
+ source->SetJsonPath("strings.js");
+ source->SetDefaultResource(IDR_BLUETOOTH_PAIR_DEVICE_HTML);
+ source->DisableContentSecurityPolicy();
+
+ Profile* profile = Profile::FromWebUI(web_ui);
+ ChromeURLDataManager::AddWebUIDataSource(profile, source);
+}
+
+BluetoothPairingUI::~BluetoothPairingUI() {
+ // Uninitialize all registered handlers. The base class owns them and it will
+ // eventually delete them.
+ core_handler_->Uninitialize();
+ bluetooth_handler_->Uninitialize();
+}
+
+void BluetoothPairingUI::InitializeHandlers() {
+ core_handler_->InitializeHandler();
+ bluetooth_handler_->InitializeHandler();
+ core_handler_->InitializePage();
+ bluetooth_handler_->InitializePage();
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/ui/webui/chromeos/bluetooth_pairing_ui.h b/chrome/browser/ui/webui/chromeos/bluetooth_pairing_ui.h
new file mode 100644
index 0000000..263787a
--- /dev/null
+++ b/chrome/browser/ui/webui/chromeos/bluetooth_pairing_ui.h
@@ -0,0 +1,37 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_BLUETOOTH_PAIRING_UI_H_
+#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_BLUETOOTH_PAIRING_UI_H_
+
+#include "chrome/browser/ui/webui/options/options_ui.h"
+#include "ui/web_dialogs/web_dialog_ui.h"
+
+namespace chromeos {
+
+namespace options {
+class CoreChromeOSOptionsHandler;
+class BluetoothOptionsHandler;
+}
+
+// A WebUI to host bluetooth device pairing web ui.
+class BluetoothPairingUI : public ui::WebDialogUI,
+ public ::options::OptionsPageUIHandlerHost {
+ public:
+ explicit BluetoothPairingUI(content::WebUI* web_ui);
+ virtual ~BluetoothPairingUI();
+
+ private:
+ // Overridden from OptionsPageUIHandlerHost:
+ virtual void InitializeHandlers() OVERRIDE;
+
+ options::CoreChromeOSOptionsHandler* core_handler_;
+ options::BluetoothOptionsHandler* bluetooth_handler_;
+
+ DISALLOW_COPY_AND_ASSIGN(BluetoothPairingUI);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_BLUETOOTH_PAIRING_UI_H_
diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi
index 45f9755..8f24f30 100644
--- a/chrome/chrome_browser_chromeos.gypi
+++ b/chrome/chrome_browser_chromeos.gypi
@@ -122,6 +122,8 @@
'browser/chromeos/audio/audio_mixer_cras.h',
'browser/chromeos/background/ash_user_wallpaper_delegate.cc',
'browser/chromeos/background/ash_user_wallpaper_delegate.h',
+ 'browser/chromeos/bluetooth/bluetooth_pairing_dialog.cc',
+ 'browser/chromeos/bluetooth/bluetooth_pairing_dialog.h',
'browser/chromeos/boot_times_loader.cc',
'browser/chromeos/boot_times_loader.h',
'browser/chromeos/camera_detector.cc',
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index 8a243cb..2590e9c 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -1802,6 +1802,8 @@
'browser/ui/webui/chrome_web_ui_data_source.h',
'browser/ui/webui/chromeos/about_network.cc',
'browser/ui/webui/chromeos/about_network.h',
+ 'browser/ui/webui/chromeos/bluetooth_pairing_ui.cc',
+ 'browser/ui/webui/chromeos/bluetooth_pairing_ui.h',
'browser/ui/webui/chromeos/choose_mobile_network_ui.cc',
'browser/ui/webui/chromeos/choose_mobile_network_ui.h',
'browser/ui/webui/chromeos/cryptohome_ui.cc',
diff --git a/chrome/common/url_constants.cc b/chrome/common/url_constants.cc
index 291ae0f..2193ae0 100644
--- a/chrome/common/url_constants.cc
+++ b/chrome/common/url_constants.cc
@@ -81,6 +81,7 @@ const char kChromeUIWelcomeURL[] = "chrome://welcome/";
#if defined(OS_CHROMEOS)
const char kChromeUIActivationMessage[] = "chrome://activationmessage/";
+const char kChromeUIBluetoothPairingURL[] = "chrome://bluetooth-pairing/";
const char kChromeUIChooseMobileNetworkURL[] =
"chrome://choose-mobile-network/";
const char kChromeUIDiagnosticsURL[] = "chrome://diagnostics/";
@@ -217,6 +218,7 @@ const char kChromeUISandboxHost[] = "sandbox";
#if defined(OS_CHROMEOS)
const char kChromeUIActivationMessageHost[] = "activationmessage";
+const char kChromeUIBluetoothPairingHost[] = "bluetooth-pairing";
const char kChromeUIChooseMobileNetworkHost[] = "choose-mobile-network";
const char kChromeUICryptohomeHost[] = "cryptohome";
const char kChromeUIDiagnosticsHost[] = "diagnostics";
diff --git a/chrome/common/url_constants.h b/chrome/common/url_constants.h
index 240d175..1986b00 100644
--- a/chrome/common/url_constants.h
+++ b/chrome/common/url_constants.h
@@ -79,6 +79,7 @@ extern const char kChromeUIWelcomeURL[];
#if defined(OS_CHROMEOS)
extern const char kChromeUIActivationMessage[];
+extern const char kChromeUIBluetoothPairingURL[];
extern const char kChromeUIChooseMobileNetworkURL[];
extern const char kChromeUIDiagnosticsURL[];
extern const char kChromeUIDiscardsURL[];
@@ -212,6 +213,7 @@ extern const char kChromeUISandboxHost[];
#if defined(OS_CHROMEOS)
extern const char kChromeUIActivationMessageHost[];
+extern const char kChromeUIBluetoothPairingHost[];
extern const char kChromeUIChooseMobileNetworkHost[];
extern const char kChromeUICryptohomeHost[];
extern const char kChromeUIDiagnosticsHost[];