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