OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/attestation/platform_verification_dialog.h" | 5 #include "chrome/browser/chromeos/attestation/platform_verification_dialog.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/ui/browser_finder.h" | 9 #include "chrome/browser/ui/browser_finder.h" |
10 #include "chrome/browser/ui/browser_navigator.h" | 10 #include "chrome/browser/ui/browser_navigator.h" |
11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
12 #include "chrome/browser/ui/singleton_tabs.h" | 12 #include "chrome/browser/ui/singleton_tabs.h" |
13 #include "chrome/common/url_constants.h" | 13 #include "chrome/common/url_constants.h" |
14 #include "components/web_modal/web_contents_modal_dialog_host.h" | 14 #include "components/web_modal/popup_manager.h" |
15 #include "components/web_modal/web_contents_modal_dialog_manager.h" | |
16 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" | |
17 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/page_transition_types.h" | 16 #include "content/public/common/page_transition_types.h" |
19 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
20 #include "extensions/common/extension.h" | 18 #include "extensions/common/extension.h" |
21 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
22 #include "ui/aura/window.h" | 20 #include "ui/aura/window.h" |
23 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/views/border.h" | 22 #include "ui/views/border.h" |
25 #include "ui/views/controls/styled_label.h" | 23 #include "ui/views/controls/styled_label.h" |
26 #include "ui/views/layout/fill_layout.h" | 24 #include "ui/views/layout/fill_layout.h" |
27 #include "ui/views/layout/layout_constants.h" | 25 #include "ui/views/layout/layout_constants.h" |
28 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
| 27 #include "ui/views/window/dialog_delegate.h" |
29 | 28 |
30 namespace chromeos { | 29 namespace chromeos { |
31 namespace attestation { | 30 namespace attestation { |
32 | 31 |
33 namespace { | 32 namespace { |
34 | 33 |
35 const int kDialogMaxWidthInPixel = 400; | 34 const int kDialogMaxWidthInPixel = 400; |
36 | 35 |
37 } // namespace | 36 } // namespace |
38 | 37 |
39 // static | 38 // static |
40 void PlatformVerificationDialog::ShowDialog( | 39 void PlatformVerificationDialog::ShowDialog( |
41 content::WebContents* web_contents, | 40 content::WebContents* web_contents, |
42 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) { | 41 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) { |
43 GURL url = web_contents->GetLastCommittedURL(); | 42 GURL url = web_contents->GetLastCommittedURL(); |
44 // In the case of an extension or hosted app, the origin of the request is | 43 // In the case of an extension or hosted app, the origin of the request is |
45 // best described by the extension / app name. | 44 // best described by the extension / app name. |
46 const extensions::Extension* extension = | 45 const extensions::Extension* extension = |
47 extensions::ExtensionRegistry::Get(web_contents->GetBrowserContext())-> | 46 extensions::ExtensionRegistry::Get(web_contents->GetBrowserContext())-> |
48 enabled_extensions().GetExtensionOrAppByURL(url); | 47 enabled_extensions().GetExtensionOrAppByURL(url); |
49 std::string origin = extension ? extension->name() : url.GetOrigin().spec(); | 48 std::string origin = extension ? extension->name() : url.GetOrigin().spec(); |
50 | 49 |
51 PlatformVerificationDialog* dialog = new PlatformVerificationDialog( | 50 PlatformVerificationDialog* dialog = new PlatformVerificationDialog( |
52 web_contents, | 51 web_contents, |
53 base::UTF8ToUTF16(origin), | 52 base::UTF8ToUTF16(origin), |
54 callback); | 53 callback); |
55 | 54 |
56 web_modal::WebContentsModalDialogManager* manager = | 55 // Sets up the dialog widget to be shown. |
57 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); | 56 web_modal::PopupManager* popup_manager = |
58 const gfx::NativeWindow parent = | 57 web_modal::PopupManager::FromWebContents(web_contents); |
59 manager->delegate()->GetWebContentsModalDialogHost()->GetHostView(); | 58 DCHECK(popup_manager); |
60 views::Widget* widget = CreateDialogWidget(dialog, NULL, parent); | 59 views::Widget* widget = views::DialogDelegate::CreateDialogWidget( |
61 manager->ShowModalDialog(widget->GetNativeView()); | 60 dialog, NULL, popup_manager->GetHostView()); |
62 widget->Show(); | 61 popup_manager->ShowModalDialog(widget->GetNativeView(), web_contents); |
63 } | 62 } |
64 | 63 |
65 PlatformVerificationDialog::~PlatformVerificationDialog() { | 64 PlatformVerificationDialog::~PlatformVerificationDialog() { |
66 } | 65 } |
67 | 66 |
68 PlatformVerificationDialog::PlatformVerificationDialog( | 67 PlatformVerificationDialog::PlatformVerificationDialog( |
69 content::WebContents* web_contents, | 68 content::WebContents* web_contents, |
70 const base::string16& domain, | 69 const base::string16& domain, |
71 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) | 70 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) |
72 : web_contents_(web_contents), | 71 : web_contents_(web_contents), |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 profile, learn_more_url, content::PAGE_TRANSITION_LINK); | 139 profile, learn_more_url, content::PAGE_TRANSITION_LINK); |
141 params.disposition = SINGLETON_TAB; | 140 params.disposition = SINGLETON_TAB; |
142 chrome::Navigate(¶ms); | 141 chrome::Navigate(¶ms); |
143 } else { | 142 } else { |
144 chrome::ShowSingletonTab(browser, learn_more_url); | 143 chrome::ShowSingletonTab(browser, learn_more_url); |
145 } | 144 } |
146 } | 145 } |
147 | 146 |
148 } // namespace attestation | 147 } // namespace attestation |
149 } // namespace chromeos | 148 } // namespace chromeos |
OLD | NEW |