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()); |
| 50 |
| 51 // TODO(xhwang): We should only show the name if the request if from the |
| 52 // extension's true frame. See http://crbug.com/455821 |
| 53 std::string origin = extension ? extension->name() : requesting_origin.spec(); |
50 | 54 |
51 PlatformVerificationDialog* dialog = new PlatformVerificationDialog( | 55 PlatformVerificationDialog* dialog = new PlatformVerificationDialog( |
52 web_contents, | 56 web_contents, |
53 base::UTF8ToUTF16(origin), | 57 base::UTF8ToUTF16(origin), |
54 callback); | 58 callback); |
55 | 59 |
56 // Sets up the dialog widget to be shown. | 60 // Sets up the dialog widget to be shown. |
57 web_modal::PopupManager* popup_manager = | 61 web_modal::PopupManager* popup_manager = |
58 web_modal::PopupManager::FromWebContents(web_contents); | 62 web_modal::PopupManager::FromWebContents(web_contents); |
59 DCHECK(popup_manager); | 63 DCHECK(popup_manager); |
60 views::Widget* widget = views::DialogDelegate::CreateDialogWidget( | 64 views::Widget* widget = views::DialogDelegate::CreateDialogWidget( |
61 dialog, NULL, popup_manager->GetHostView()); | 65 dialog, NULL, popup_manager->GetHostView()); |
62 popup_manager->ShowModalDialog(widget->GetNativeView(), web_contents); | 66 popup_manager->ShowModalDialog(widget->GetNativeView(), web_contents); |
| 67 |
| 68 return widget; |
63 } | 69 } |
64 | 70 |
65 PlatformVerificationDialog::~PlatformVerificationDialog() { | 71 PlatformVerificationDialog::~PlatformVerificationDialog() { |
66 } | 72 } |
67 | 73 |
68 PlatformVerificationDialog::PlatformVerificationDialog( | 74 PlatformVerificationDialog::PlatformVerificationDialog( |
69 content::WebContents* web_contents, | 75 content::WebContents* web_contents, |
70 const base::string16& domain, | 76 const base::string16& domain, |
71 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) | 77 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) |
72 : content::WebContentsObserver(web_contents), | 78 : content::WebContentsObserver(web_contents), |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 void PlatformVerificationDialog::DidStartNavigationToPendingEntry( | 154 void PlatformVerificationDialog::DidStartNavigationToPendingEntry( |
149 const GURL& url, | 155 const GURL& url, |
150 content::NavigationController::ReloadType reload_type) { | 156 content::NavigationController::ReloadType reload_type) { |
151 views::Widget* widget = GetWidget(); | 157 views::Widget* widget = GetWidget(); |
152 if (widget) | 158 if (widget) |
153 widget->Close(); | 159 widget->Close(); |
154 } | 160 } |
155 | 161 |
156 } // namespace attestation | 162 } // namespace attestation |
157 } // namespace chromeos | 163 } // namespace chromeos |
OLD | NEW |