Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.cc

Issue 2684793004: [Harmony] Harmonize Bluetooth dialogs. (Closed)
Patch Set: Address jamescook@'s comments. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/bluetooth_pair_device.css » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 7 #include <string>
8 8
9 #include "ash/public/cpp/shell_window_ids.h" 9 #include "ash/public/cpp/shell_window_ids.h"
10 #include "ash/shell.h"
10 #include "base/json/json_writer.h" 11 #include "base/json/json_writer.h"
12 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
11 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/ui/ash/ash_util.h"
12 #include "chrome/browser/ui/browser_dialogs.h" 15 #include "chrome/browser/ui/browser_dialogs.h"
16 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
13 #include "chrome/common/url_constants.h" 17 #include "chrome/common/url_constants.h"
14 #include "chrome/grit/generated_resources.h" 18 #include "chrome/grit/generated_resources.h"
15 #include "device/bluetooth/bluetooth_device.h" 19 #include "device/bluetooth/bluetooth_device.h"
20 #include "services/ui/public/cpp/property_type_converters.h"
21 #include "services/ui/public/interfaces/window_manager.mojom.h"
16 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/gfx/geometry/size.h" 23 #include "ui/gfx/geometry/size.h"
24 #include "ui/views/controls/webview/web_dialog_view.h"
25 #include "ui/views/widget/widget.h"
18 26
19 using content::WebContents; 27 using content::WebContents;
20 using content::WebUIMessageHandler; 28 using content::WebUIMessageHandler;
21 29
22 namespace chromeos { 30 namespace chromeos {
23 31
24 namespace { 32 namespace {
25 33
26 // Default width/height ratio of screen size. 34 // Default width/height ratio of screen size.
27 const int kDefaultWidth = 480; 35 const int kDefaultWidth = 480;
(...skipping 14 matching lines...) Expand all
42 } 50 }
43 51
44 BluetoothPairingDialog::~BluetoothPairingDialog() { 52 BluetoothPairingDialog::~BluetoothPairingDialog() {
45 } 53 }
46 54
47 void BluetoothPairingDialog::ShowInContainer(int container_id) { 55 void BluetoothPairingDialog::ShowInContainer(int container_id) {
48 // Dialog must be in a modal window container. 56 // Dialog must be in a modal window container.
49 DCHECK(container_id == ash::kShellWindowId_SystemModalContainer || 57 DCHECK(container_id == ash::kShellWindowId_SystemModalContainer ||
50 container_id == ash::kShellWindowId_LockSystemModalContainer); 58 container_id == ash::kShellWindowId_LockSystemModalContainer);
51 59
52 // Bluetooth settings are currently stored on the device, accessible for 60 // This block of code is almost the same as chrome::ShowWebDialogInContainer()
53 // everyone who uses the machine. As such we can use the active user profile. 61 // except we're creating a frameless window.
54 chrome::ShowWebDialogInContainer( 62 views::Widget* widget = new views::Widget; // Owned by native widget
55 container_id, ProfileManager::GetActiveUserProfile(), this); 63 views::WebDialogView* view =
64 new views::WebDialogView(ProfileManager::GetActiveUserProfile(), this,
65 new ChromeWebContentsHandler);
66 views::Widget::InitParams params(
67 views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
68 params.delegate = view;
69 if (chrome::IsRunningInMash()) {
70 using ui::mojom::WindowManager;
71 params.mus_properties[WindowManager::kContainerId_InitProperty] =
72 mojo::ConvertTo<std::vector<uint8_t>>(container_id);
73 } else {
74 params.parent = ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
75 container_id);
76 }
77 widget->Init(params);
78
79 // Observer is needed for ChromeVox extension to send messages between content
80 // and background scripts.
81 extensions::ChromeExtensionWebContentsObserver::CreateForWebContents(
82 view->web_contents());
83
84 widget->Show();
56 } 85 }
57 86
58 /////////////////////////////////////////////////////////////////////////////// 87 ///////////////////////////////////////////////////////////////////////////////
59 // LoginWebDialog, protected: 88 // LoginWebDialog, protected:
60 89
61 ui::ModalType BluetoothPairingDialog::GetDialogModalType() const { 90 ui::ModalType BluetoothPairingDialog::GetDialogModalType() const {
62 return ui::MODAL_TYPE_SYSTEM; 91 return ui::MODAL_TYPE_SYSTEM;
63 } 92 }
64 93
65 base::string16 BluetoothPairingDialog::GetDialogTitle() const { 94 base::string16 BluetoothPairingDialog::GetDialogTitle() const {
(...skipping 28 matching lines...) Expand all
94 void BluetoothPairingDialog::OnDialogClosed(const std::string& json_retval) { 123 void BluetoothPairingDialog::OnDialogClosed(const std::string& json_retval) {
95 delete this; 124 delete this;
96 } 125 }
97 126
98 void BluetoothPairingDialog::OnCloseContents(WebContents* source, 127 void BluetoothPairingDialog::OnCloseContents(WebContents* source,
99 bool* out_close_dialog) { 128 bool* out_close_dialog) {
100 *out_close_dialog = true; 129 *out_close_dialog = true;
101 } 130 }
102 131
103 bool BluetoothPairingDialog::ShouldShowDialogTitle() const { 132 bool BluetoothPairingDialog::ShouldShowDialogTitle() const {
104 return true; 133 return false;
105 } 134 }
106 135
107 bool BluetoothPairingDialog::HandleContextMenu( 136 bool BluetoothPairingDialog::HandleContextMenu(
108 const content::ContextMenuParams& params) { 137 const content::ContextMenuParams& params) {
109 // Disable context menu. 138 // Disable context menu.
110 return true; 139 return true;
111 } 140 }
112 141
113 } // namespace chromeos 142 } // namespace chromeos
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/chromeos/bluetooth_pair_device.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698