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 GURL extension_url = web_contents->GetLastCommittedURL(); | |
ddorwin
2015/02/05 03:25:26
nit: We don't actually know that this is an extens
xhwang
2015/02/05 05:46:51
Done.
| |
46 const extensions::Extension* extension = | 47 const extensions::Extension* extension = |
47 extensions::ExtensionRegistry::Get(web_contents->GetBrowserContext())-> | 48 extensions::ExtensionRegistry::Get(web_contents->GetBrowserContext()) |
48 enabled_extensions().GetExtensionOrAppByURL(url); | 49 ->enabled_extensions() |
49 std::string origin = extension ? extension->name() : url.GetOrigin().spec(); | 50 .GetExtensionOrAppByURL(extension_url); |
51 | |
52 std::string origin = extension ? extension->name() : requesting_origin.spec(); | |
50 | 53 |
51 PlatformVerificationDialog* dialog = new PlatformVerificationDialog( | 54 PlatformVerificationDialog* dialog = new PlatformVerificationDialog( |
52 web_contents, | 55 web_contents, |
53 base::UTF8ToUTF16(origin), | 56 base::UTF8ToUTF16(origin), |
54 callback); | 57 callback); |
55 | 58 |
56 // Sets up the dialog widget to be shown. | 59 // Sets up the dialog widget to be shown. |
57 web_modal::PopupManager* popup_manager = | 60 web_modal::PopupManager* popup_manager = |
58 web_modal::PopupManager::FromWebContents(web_contents); | 61 web_modal::PopupManager::FromWebContents(web_contents); |
59 DCHECK(popup_manager); | 62 DCHECK(popup_manager); |
60 views::Widget* widget = views::DialogDelegate::CreateDialogWidget( | 63 views::Widget* widget = views::DialogDelegate::CreateDialogWidget( |
61 dialog, NULL, popup_manager->GetHostView()); | 64 dialog, NULL, popup_manager->GetHostView()); |
62 popup_manager->ShowModalDialog(widget->GetNativeView(), web_contents); | 65 popup_manager->ShowModalDialog(widget->GetNativeView(), web_contents); |
66 | |
67 return widget; | |
63 } | 68 } |
64 | 69 |
65 PlatformVerificationDialog::~PlatformVerificationDialog() { | 70 PlatformVerificationDialog::~PlatformVerificationDialog() { |
66 } | 71 } |
67 | 72 |
68 PlatformVerificationDialog::PlatformVerificationDialog( | 73 PlatformVerificationDialog::PlatformVerificationDialog( |
69 content::WebContents* web_contents, | 74 content::WebContents* web_contents, |
70 const base::string16& domain, | 75 const base::string16& domain, |
71 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) | 76 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) |
72 : content::WebContentsObserver(web_contents), | 77 : content::WebContentsObserver(web_contents), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 void PlatformVerificationDialog::DidStartNavigationToPendingEntry( | 153 void PlatformVerificationDialog::DidStartNavigationToPendingEntry( |
149 const GURL& url, | 154 const GURL& url, |
150 content::NavigationController::ReloadType reload_type) { | 155 content::NavigationController::ReloadType reload_type) { |
151 views::Widget* widget = GetWidget(); | 156 views::Widget* widget = GetWidget(); |
152 if (widget) | 157 if (widget) |
153 widget->Close(); | 158 widget->Close(); |
154 } | 159 } |
155 | 160 |
156 } // namespace attestation | 161 } // namespace attestation |
157 } // namespace chromeos | 162 } // namespace chromeos |
OLD | NEW |