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/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/api/chrome_device_permissions_prompt.h" |
8 #include "chrome/browser/ui/views/constrained_window_views.h" | 9 #include "chrome/browser/ui/views/constrained_window_views.h" |
9 #include "chrome/grit/generated_resources.h" | 10 #include "chrome/grit/generated_resources.h" |
10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
11 #include "device/usb/usb_device.h" | 12 #include "device/usb/usb_device.h" |
12 #include "extensions/common/extension.h" | 13 #include "extensions/common/extension.h" |
13 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
14 #include "ui/base/models/table_model.h" | 15 #include "ui/base/models/table_model.h" |
15 #include "ui/base/models/table_model_observer.h" | 16 #include "ui/base/models/table_model_observer.h" |
16 #include "ui/views/controls/label.h" | 17 #include "ui/views/controls/label.h" |
17 #include "ui/views/controls/table/table_view.h" | 18 #include "ui/views/controls/table/table_view.h" |
18 #include "ui/views/layout/box_layout.h" | 19 #include "ui/views/layout/box_layout.h" |
19 #include "ui/views/layout/layout_constants.h" | 20 #include "ui/views/layout/layout_constants.h" |
20 | 21 |
21 using device::UsbDevice; | 22 using device::UsbDevice; |
22 using extensions::DevicePermissionsPrompt; | 23 using extensions::DevicePermissionsPrompt; |
23 | 24 |
24 namespace { | |
25 | |
26 void ShowDevicePermissionsDialogImpl( | |
27 content::WebContents* web_contents, | |
28 DevicePermissionsPrompt::Delegate* delegate, | |
29 scoped_refptr<DevicePermissionsPrompt::Prompt> prompt) { | |
30 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
31 ShowWebModalDialogViews(new DevicePermissionsDialogView(delegate, prompt), | |
32 web_contents); | |
33 } | |
34 | |
35 } // namespace | |
36 | |
37 class DevicePermissionsTableModel | 25 class DevicePermissionsTableModel |
38 : public ui::TableModel, | 26 : public ui::TableModel, |
39 public DevicePermissionsPrompt::Prompt::Observer { | 27 public DevicePermissionsPrompt::Prompt::Observer { |
40 public: | 28 public: |
41 explicit DevicePermissionsTableModel( | 29 explicit DevicePermissionsTableModel( |
42 scoped_refptr<DevicePermissionsPrompt::Prompt> prompt) | 30 scoped_refptr<DevicePermissionsPrompt::Prompt> prompt) |
43 : prompt_(prompt) { | 31 : prompt_(prompt) { |
44 prompt_->SetObserver(this); | 32 prompt_->SetObserver(this); |
45 } | 33 } |
46 | 34 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 } | 154 } |
167 | 155 |
168 base::string16 DevicePermissionsDialogView::GetWindowTitle() const { | 156 base::string16 DevicePermissionsDialogView::GetWindowTitle() const { |
169 return prompt_->GetHeading(); | 157 return prompt_->GetHeading(); |
170 } | 158 } |
171 | 159 |
172 gfx::Size DevicePermissionsDialogView::GetPreferredSize() const { | 160 gfx::Size DevicePermissionsDialogView::GetPreferredSize() const { |
173 return gfx::Size(500, 250); | 161 return gfx::Size(500, 250); |
174 } | 162 } |
175 | 163 |
176 // static | 164 void ChromeDevicePermissionsPrompt::ShowDialog() { |
177 DevicePermissionsPrompt::ShowDialogCallback | 165 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
178 DevicePermissionsPrompt::GetDefaultShowDialogCallback() { | 166 ShowWebModalDialogViews(new DevicePermissionsDialogView(delegate(), prompt()), |
179 return base::Bind(&ShowDevicePermissionsDialogImpl); | 167 web_contents()); |
180 } | 168 } |
OLD | NEW |