OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/ui/views/extensions/device_permissions_dialog_view.h" | 5 #include "chrome/browser/ui/views/extensions/device_permissions_dialog_view.h" |
6 | 6 |
| 7 #include "base/bind.h" |
| 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" |
7 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/thread_task_runner_handle.h" |
8 #include "chrome/browser/extensions/api/chrome_device_permissions_prompt.h" | 12 #include "chrome/browser/extensions/api/chrome_device_permissions_prompt.h" |
9 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
10 #include "components/constrained_window/constrained_window_views.h" | 14 #include "components/constrained_window/constrained_window_views.h" |
| 15 #include "components/web_modal/popup_manager.h" |
11 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
12 #include "device/usb/usb_device.h" | 17 #include "device/usb/usb_device.h" |
13 #include "extensions/common/extension.h" | 18 #include "extensions/common/extension.h" |
14 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
15 #include "ui/base/models/table_model.h" | 20 #include "ui/base/models/table_model.h" |
16 #include "ui/base/models/table_model_observer.h" | 21 #include "ui/base/models/table_model_observer.h" |
17 #include "ui/views/controls/label.h" | 22 #include "ui/views/controls/label.h" |
18 #include "ui/views/controls/table/table_view.h" | 23 #include "ui/views/controls/table/table_view.h" |
19 #include "ui/views/layout/box_layout.h" | 24 #include "ui/views/layout/box_layout.h" |
20 #include "ui/views/layout/layout_constants.h" | 25 #include "ui/views/layout/layout_constants.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 base::string16 DevicePermissionsDialogView::GetWindowTitle() const { | 154 base::string16 DevicePermissionsDialogView::GetWindowTitle() const { |
150 return prompt_->GetHeading(); | 155 return prompt_->GetHeading(); |
151 } | 156 } |
152 | 157 |
153 gfx::Size DevicePermissionsDialogView::GetPreferredSize() const { | 158 gfx::Size DevicePermissionsDialogView::GetPreferredSize() const { |
154 return gfx::Size(500, 250); | 159 return gfx::Size(500, 250); |
155 } | 160 } |
156 | 161 |
157 void ChromeDevicePermissionsPrompt::ShowDialog() { | 162 void ChromeDevicePermissionsPrompt::ShowDialog() { |
158 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 163 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
159 constrained_window::ShowWebModalDialogViews( | 164 |
160 new DevicePermissionsDialogView(prompt()), web_contents()); | 165 web_modal::PopupManager* popup_manager = |
| 166 web_modal::PopupManager::FromWebContents(web_contents()); |
| 167 if (popup_manager) { |
| 168 constrained_window::ShowWebModalDialogViews( |
| 169 new DevicePermissionsDialogView(prompt()), web_contents()); |
| 170 } else { |
| 171 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 172 FROM_HERE, |
| 173 base::Bind(&DevicePermissionsPrompt::Prompt::Dismissed, prompt())); |
| 174 } |
161 } | 175 } |
OLD | NEW |