Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / chromeos / bluetooth / bluetooth_pairing_dialog.cc
blobe52157592501a5333248ee39b39041f1852835bd
1 // Copyright (c) 2012 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/chromeos/bluetooth/bluetooth_pairing_dialog.h"
7 #include "base/json/json_writer.h"
8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/browser/ui/browser_dialogs.h"
10 #include "chrome/common/url_constants.h"
11 #include "chrome/grit/generated_resources.h"
12 #include "device/bluetooth/bluetooth_device.h"
13 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/gfx/geometry/size.h"
16 using content::WebContents;
17 using content::WebUIMessageHandler;
19 namespace chromeos {
21 namespace {
23 // Default width/height ratio of screen size.
24 const int kDefaultWidth = 480;
25 const int kDefaultHeight = 280;
27 } // namespace
29 ///////////////////////////////////////////////////////////////////////////////
30 // BluetoothPairingDialog, public:
32 BluetoothPairingDialog::BluetoothPairingDialog(
33 gfx::NativeWindow parent_window,
34 const device::BluetoothDevice* device)
35 : parent_window_(parent_window),
36 webui_(nullptr) {
37 device_data_.SetString("address", device->GetAddress());
38 device_data_.SetString("name", device->GetName());
39 device_data_.SetBoolean("paired", device->IsPaired());
40 device_data_.SetBoolean("connected", device->IsConnected());
43 BluetoothPairingDialog::~BluetoothPairingDialog() {
46 void BluetoothPairingDialog::Show() {
47 // Bluetooth settings are currently stored on the device, accessible for
48 // everyone who uses the machine. As such we can use the active user profile.
49 chrome::ShowWebDialog(parent_window_,
50 ProfileManager::GetActiveUserProfile(),
51 this);
54 ///////////////////////////////////////////////////////////////////////////////
55 // LoginWebDialog, protected:
57 ui::ModalType BluetoothPairingDialog::GetDialogModalType() const {
58 return ui::MODAL_TYPE_SYSTEM;
61 base::string16 BluetoothPairingDialog::GetDialogTitle() const {
62 return l10n_util::GetStringUTF16(
63 IDS_OPTIONS_SETTINGS_BLUETOOTH_ADD_DEVICE_TITLE);
66 GURL BluetoothPairingDialog::GetDialogContentURL() const {
67 return GURL(chrome::kChromeUIBluetoothPairingURL);
70 void BluetoothPairingDialog::GetWebUIMessageHandlers(
71 std::vector<WebUIMessageHandler*>* handlers) const {
74 void BluetoothPairingDialog::GetDialogSize(gfx::Size* size) const {
75 size->SetSize(kDefaultWidth, kDefaultHeight);
78 std::string BluetoothPairingDialog::GetDialogArgs() const {
79 std::string data;
80 base::JSONWriter::Write(device_data_, &data);
81 return data;
84 void BluetoothPairingDialog::OnDialogShown(
85 content::WebUI* webui,
86 content::RenderViewHost* render_view_host) {
87 webui_ = webui;
90 void BluetoothPairingDialog::OnDialogClosed(const std::string& json_retval) {
91 delete this;
94 void BluetoothPairingDialog::OnCloseContents(WebContents* source,
95 bool* out_close_dialog) {
96 *out_close_dialog = true;
99 bool BluetoothPairingDialog::ShouldShowDialogTitle() const {
100 return true;
103 bool BluetoothPairingDialog::HandleContextMenu(
104 const content::ContextMenuParams& params) {
105 // Disable context menu.
106 return true;
109 } // namespace chromeos