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" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 namespace chromeos { | 30 namespace chromeos { |
31 namespace attestation { | 31 namespace attestation { |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 const int kDialogMaxWidthInPixel = 400; | 35 const int kDialogMaxWidthInPixel = 400; |
36 | 36 |
37 } // namespace | 37 } // namespace |
38 | 38 |
39 // static | 39 // static |
40 void PlatformVerificationDialog::ShowDialog( | 40 views::Widget* PlatformVerificationDialog::ShowDialog( |
41 content::WebContents* web_contents, | 41 content::WebContents* web_contents, |
42 const GURL& requesting_origin, | |
42 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) { | 43 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) { |
43 GURL url = web_contents->GetLastCommittedURL(); | |
44 // 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 |
45 // best described by the extension / app name. | 45 // best described by the extension / app name. |
46 const extensions::Extension* extension = | 46 const extensions::Extension* extension = |
47 extensions::ExtensionRegistry::Get(web_contents->GetBrowserContext())-> | 47 extensions::ExtensionRegistry::Get(web_contents->GetBrowserContext()) |
48 enabled_extensions().GetExtensionOrAppByURL(url); | 48 ->enabled_extensions() |
49 std::string origin = extension ? extension->name() : url.GetOrigin().spec(); | 49 .GetExtensionOrAppByURL(web_contents->GetLastCommittedURL()); |
Darren Krahn
2015/02/05 16:40:44
Should we use requesting_origin here too?
xhwang
2015/02/05 18:09:48
I am not sure. If the requesting_origin is differe
xhwang
2015/02/05 22:02:18
Confirmed. GetExtensionOrAppByURL only expects chr
| |
50 | |
51 std::string origin = extension ? extension->name() : requesting_origin.spec(); | |
50 | 52 |
51 PlatformVerificationDialog* dialog = new PlatformVerificationDialog( | 53 PlatformVerificationDialog* dialog = new PlatformVerificationDialog( |
52 web_contents, | 54 web_contents, |
53 base::UTF8ToUTF16(origin), | 55 base::UTF8ToUTF16(origin), |
54 callback); | 56 callback); |
55 | 57 |
56 // Sets up the dialog widget to be shown. | 58 // Sets up the dialog widget to be shown. |
57 web_modal::PopupManager* popup_manager = | 59 web_modal::PopupManager* popup_manager = |
58 web_modal::PopupManager::FromWebContents(web_contents); | 60 web_modal::PopupManager::FromWebContents(web_contents); |
59 DCHECK(popup_manager); | 61 DCHECK(popup_manager); |
60 views::Widget* widget = views::DialogDelegate::CreateDialogWidget( | 62 views::Widget* widget = views::DialogDelegate::CreateDialogWidget( |
61 dialog, NULL, popup_manager->GetHostView()); | 63 dialog, NULL, popup_manager->GetHostView()); |
62 popup_manager->ShowModalDialog(widget->GetNativeView(), web_contents); | 64 popup_manager->ShowModalDialog(widget->GetNativeView(), web_contents); |
65 | |
66 return widget; | |
63 } | 67 } |
64 | 68 |
65 PlatformVerificationDialog::~PlatformVerificationDialog() { | 69 PlatformVerificationDialog::~PlatformVerificationDialog() { |
66 } | 70 } |
67 | 71 |
68 PlatformVerificationDialog::PlatformVerificationDialog( | 72 PlatformVerificationDialog::PlatformVerificationDialog( |
69 content::WebContents* web_contents, | 73 content::WebContents* web_contents, |
70 const base::string16& domain, | 74 const base::string16& domain, |
71 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) | 75 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) |
72 : content::WebContentsObserver(web_contents), | 76 : content::WebContentsObserver(web_contents), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 void PlatformVerificationDialog::DidStartNavigationToPendingEntry( | 152 void PlatformVerificationDialog::DidStartNavigationToPendingEntry( |
149 const GURL& url, | 153 const GURL& url, |
150 content::NavigationController::ReloadType reload_type) { | 154 content::NavigationController::ReloadType reload_type) { |
151 views::Widget* widget = GetWidget(); | 155 views::Widget* widget = GetWidget(); |
152 if (widget) | 156 if (widget) |
153 widget->Close(); | 157 widget->Close(); |
154 } | 158 } |
155 | 159 |
156 } // namespace attestation | 160 } // namespace attestation |
157 } // namespace chromeos | 161 } // namespace chromeos |
OLD | NEW |