| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" | 5 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" |
| 6 | 6 |
| 7 #include <string> |
| 8 |
| 9 #include "ash/public/cpp/shell_window_ids.h" |
| 7 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 8 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 9 #include "chrome/browser/ui/browser_dialogs.h" | 12 #include "chrome/browser/ui/browser_dialogs.h" |
| 10 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
| 11 #include "chrome/grit/generated_resources.h" | 14 #include "chrome/grit/generated_resources.h" |
| 12 #include "device/bluetooth/bluetooth_device.h" | 15 #include "device/bluetooth/bluetooth_device.h" |
| 13 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 14 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
| 15 | 18 |
| 16 using content::WebContents; | 19 using content::WebContents; |
| 17 using content::WebUIMessageHandler; | 20 using content::WebUIMessageHandler; |
| 18 | 21 |
| 19 namespace chromeos { | 22 namespace chromeos { |
| 20 | 23 |
| 21 namespace { | 24 namespace { |
| 22 | 25 |
| 23 // Default width/height ratio of screen size. | 26 // Default width/height ratio of screen size. |
| 24 const int kDefaultWidth = 480; | 27 const int kDefaultWidth = 480; |
| 25 const int kDefaultHeight = 280; | 28 const int kDefaultHeight = 280; |
| 26 | 29 |
| 27 } // namespace | 30 } // namespace |
| 28 | 31 |
| 29 /////////////////////////////////////////////////////////////////////////////// | 32 /////////////////////////////////////////////////////////////////////////////// |
| 30 // BluetoothPairingDialog, public: | 33 // BluetoothPairingDialog, public: |
| 31 | 34 |
| 32 BluetoothPairingDialog::BluetoothPairingDialog( | 35 BluetoothPairingDialog::BluetoothPairingDialog( |
| 33 gfx::NativeWindow parent_window, | |
| 34 const device::BluetoothDevice* device) | 36 const device::BluetoothDevice* device) |
| 35 : parent_window_(parent_window), | 37 : webui_(nullptr) { |
| 36 webui_(nullptr) { | |
| 37 device_data_.SetString("address", device->GetAddress()); | 38 device_data_.SetString("address", device->GetAddress()); |
| 38 device_data_.SetString("name", device->GetNameForDisplay()); | 39 device_data_.SetString("name", device->GetNameForDisplay()); |
| 39 device_data_.SetBoolean("paired", device->IsPaired()); | 40 device_data_.SetBoolean("paired", device->IsPaired()); |
| 40 device_data_.SetBoolean("connected", device->IsConnected()); | 41 device_data_.SetBoolean("connected", device->IsConnected()); |
| 41 } | 42 } |
| 42 | 43 |
| 43 BluetoothPairingDialog::~BluetoothPairingDialog() { | 44 BluetoothPairingDialog::~BluetoothPairingDialog() { |
| 44 } | 45 } |
| 45 | 46 |
| 46 void BluetoothPairingDialog::Show() { | 47 void BluetoothPairingDialog::ShowInContainer(int container_id) { |
| 48 // Dialog must be in a modal window container. |
| 49 DCHECK(container_id == ash::kShellWindowId_SystemModalContainer || |
| 50 container_id == ash::kShellWindowId_LockSystemModalContainer); |
| 51 |
| 47 // Bluetooth settings are currently stored on the device, accessible for | 52 // 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. | 53 // everyone who uses the machine. As such we can use the active user profile. |
| 49 chrome::ShowWebDialog(parent_window_, | 54 chrome::ShowWebDialogInContainer( |
| 50 ProfileManager::GetActiveUserProfile(), | 55 container_id, ProfileManager::GetActiveUserProfile(), this); |
| 51 this); | |
| 52 } | 56 } |
| 53 | 57 |
| 54 /////////////////////////////////////////////////////////////////////////////// | 58 /////////////////////////////////////////////////////////////////////////////// |
| 55 // LoginWebDialog, protected: | 59 // LoginWebDialog, protected: |
| 56 | 60 |
| 57 ui::ModalType BluetoothPairingDialog::GetDialogModalType() const { | 61 ui::ModalType BluetoothPairingDialog::GetDialogModalType() const { |
| 58 return ui::MODAL_TYPE_SYSTEM; | 62 return ui::MODAL_TYPE_SYSTEM; |
| 59 } | 63 } |
| 60 | 64 |
| 61 base::string16 BluetoothPairingDialog::GetDialogTitle() const { | 65 base::string16 BluetoothPairingDialog::GetDialogTitle() const { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 return true; | 104 return true; |
| 101 } | 105 } |
| 102 | 106 |
| 103 bool BluetoothPairingDialog::HandleContextMenu( | 107 bool BluetoothPairingDialog::HandleContextMenu( |
| 104 const content::ContextMenuParams& params) { | 108 const content::ContextMenuParams& params) { |
| 105 // Disable context menu. | 109 // Disable context menu. |
| 106 return true; | 110 return true; |
| 107 } | 111 } |
| 108 | 112 |
| 109 } // namespace chromeos | 113 } // namespace chromeos |
| OLD | NEW |