Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1052)

Side by Side Diff: chrome/browser/chromeos/attestation/platform_verification_dialog.cc

Issue 236203017: Fixes the crash for "learn more" link of the dialog for v2 apps. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/attestation/platform_verification_dialog.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/ui/browser_finder.h" 8 #include "chrome/browser/ui/browser_finder.h"
bartfab (slow) 2014/04/16 12:22:42 Nit: No longer used.
Jun Mukai 2014/04/16 18:00:59 browser_finder is still used in line 132 below
9 #include "chrome/browser/ui/browser_navigator.h"
9 #include "chrome/browser/ui/browser_window.h" 10 #include "chrome/browser/ui/browser_window.h"
10 #include "chrome/browser/ui/singleton_tabs.h" 11 #include "chrome/browser/ui/singleton_tabs.h"
11 #include "chrome/common/url_constants.h" 12 #include "chrome/common/url_constants.h"
12 #include "components/web_modal/web_contents_modal_dialog_host.h" 13 #include "components/web_modal/web_contents_modal_dialog_host.h"
13 #include "components/web_modal/web_contents_modal_dialog_manager.h" 14 #include "components/web_modal/web_contents_modal_dialog_manager.h"
14 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" 15 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
15 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
16 #include "extensions/browser/extension_registry.h" 17 #include "extensions/browser/extension_registry.h"
17 #include "extensions/common/extension.h" 18 #include "extensions/common/extension.h"
18 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
(...skipping 20 matching lines...) Expand all
39 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) { 40 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) {
40 GURL url = web_contents->GetLastCommittedURL(); 41 GURL url = web_contents->GetLastCommittedURL();
41 // In the case of an extension or hosted app, the origin of the request is 42 // In the case of an extension or hosted app, the origin of the request is
42 // best described by the extension / app name. 43 // best described by the extension / app name.
43 const extensions::Extension* extension = 44 const extensions::Extension* extension =
44 extensions::ExtensionRegistry::Get(web_contents->GetBrowserContext())-> 45 extensions::ExtensionRegistry::Get(web_contents->GetBrowserContext())->
45 enabled_extensions().GetExtensionOrAppByURL(url); 46 enabled_extensions().GetExtensionOrAppByURL(url);
46 std::string origin = extension ? extension->name() : url.GetOrigin().spec(); 47 std::string origin = extension ? extension->name() : url.GetOrigin().spec();
47 48
48 PlatformVerificationDialog* dialog = new PlatformVerificationDialog( 49 PlatformVerificationDialog* dialog = new PlatformVerificationDialog(
49 chrome::FindBrowserWithWebContents(web_contents), 50 web_contents,
50 base::UTF8ToUTF16(origin), 51 base::UTF8ToUTF16(origin),
51 callback); 52 callback);
52 53
53 // Sets up the dialog widget and shows it. 54 // Sets up the dialog widget and shows it.
54 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager = 55 web_modal::WebContentsModalDialogManager* web_contents_modal_dialog_manager =
55 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents); 56 web_modal::WebContentsModalDialogManager::FromWebContents(web_contents);
56 web_modal::WebContentsModalDialogManagerDelegate* modal_delegate = 57 web_modal::WebContentsModalDialogManagerDelegate* modal_delegate =
57 web_contents_modal_dialog_manager->delegate(); 58 web_contents_modal_dialog_manager->delegate();
58 views::Widget* widget = views::Widget::CreateWindowAsFramelessChild( 59 views::Widget* widget = views::Widget::CreateWindowAsFramelessChild(
59 dialog, modal_delegate->GetWebContentsModalDialogHost()->GetHostView()); 60 dialog, modal_delegate->GetWebContentsModalDialogHost()->GetHostView());
60 web_contents_modal_dialog_manager->ShowModalDialog( 61 web_contents_modal_dialog_manager->ShowModalDialog(
61 widget->GetNativeView()); 62 widget->GetNativeView());
62 widget->Show(); 63 widget->Show();
63 } 64 }
64 65
65 PlatformVerificationDialog::~PlatformVerificationDialog() { 66 PlatformVerificationDialog::~PlatformVerificationDialog() {
66 } 67 }
67 68
68 PlatformVerificationDialog::PlatformVerificationDialog( 69 PlatformVerificationDialog::PlatformVerificationDialog(
69 Browser* browser, 70 content::WebContents* web_contents,
70 const base::string16& domain, 71 const base::string16& domain,
71 const PlatformVerificationFlow::Delegate::ConsentCallback& callback) 72 const PlatformVerificationFlow::Delegate::ConsentCallback& callback)
72 : browser_(browser), 73 : web_contents_(web_contents),
73 domain_(domain), 74 domain_(domain),
74 callback_(callback) { 75 callback_(callback) {
75 SetLayoutManager(new views::FillLayout()); 76 SetLayoutManager(new views::FillLayout());
76 SetBorder(views::Border::CreateEmptyBorder( 77 SetBorder(views::Border::CreateEmptyBorder(
77 0, views::kButtonHEdgeMarginNew, 0, views::kButtonHEdgeMarginNew)); 78 0, views::kButtonHEdgeMarginNew, 0, views::kButtonHEdgeMarginNew));
78 const base::string16 learn_more = l10n_util::GetStringUTF16(IDS_LEARN_MORE); 79 const base::string16 learn_more = l10n_util::GetStringUTF16(IDS_LEARN_MORE);
79 std::vector<size_t> offsets; 80 std::vector<size_t> offsets;
80 base::string16 headline = l10n_util::GetStringFUTF16( 81 base::string16 headline = l10n_util::GetStringFUTF16(
81 IDS_PLATFORM_VERIFICATION_DIALOG_HEADLINE, domain_, learn_more, &offsets); 82 IDS_PLATFORM_VERIFICATION_DIALOG_HEADLINE, domain_, learn_more, &offsets);
82 views::StyledLabel* headline_label = new views::StyledLabel(headline, this); 83 views::StyledLabel* headline_label = new views::StyledLabel(headline, this);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 return ui::MODAL_TYPE_CHILD; 122 return ui::MODAL_TYPE_CHILD;
122 } 123 }
123 124
124 gfx::Size PlatformVerificationDialog::GetPreferredSize() { 125 gfx::Size PlatformVerificationDialog::GetPreferredSize() {
125 return gfx::Size(kDialogMaxWidthInPixel, 126 return gfx::Size(kDialogMaxWidthInPixel,
126 GetHeightForWidth(kDialogMaxWidthInPixel)); 127 GetHeightForWidth(kDialogMaxWidthInPixel));
127 } 128 }
128 129
129 void PlatformVerificationDialog::StyledLabelLinkClicked(const gfx::Range& range, 130 void PlatformVerificationDialog::StyledLabelLinkClicked(const gfx::Range& range,
130 int event_flags) { 131 int event_flags) {
131 chrome::ShowSingletonTab(browser_, GURL( 132 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
132 chrome::kEnhancedPlaybackNotificationLearnMoreURL)); 133 GURL learn_more_url(chrome::kEnhancedPlaybackNotificationLearnMoreURL);
bartfab (slow) 2014/04/16 12:22:42 Nit: const.
Jun Mukai 2014/04/16 18:00:59 Done.
134
135 // |web_contents_| might not have a browser in case of v2 apps, in that case
bartfab (slow) 2014/04/16 12:22:42 Nit: s/, in that case/. In that case,/
Jun Mukai 2014/04/16 18:00:59 Done.
136 // open a new tab in a usual way.
bartfab (slow) 2014/04/16 12:22:42 1: Nit: s/ a / the / 2: How do you open a new tab
Jun Mukai 2014/04/16 18:00:59 1: done. 2: as far as I see browser_navigator.cc,
bartfab (slow) 2014/04/16 18:38:59 Thanks for clarifying. I am so used to Chrome OS s
Jun Mukai 2014/04/16 21:23:41 The report is saying a normal v2 app in a normal c
Jun Mukai 2014/04/17 01:33:53 we do not have any plan to provide this in Kiosk a
137 if (!browser) {
138 Profile* profile = Profile::FromBrowserContext(
bartfab (slow) 2014/04/16 12:22:42 Nit: #include "chrome/browser/profiles/profile.h"
Jun Mukai 2014/04/16 18:00:59 Done.
139 web_contents_->GetBrowserContext());
140 chrome::NavigateParams params(
141 profile, learn_more_url, content::PAGE_TRANSITION_LINK);
bartfab (slow) 2014/04/16 12:22:42 Nit: #include "content/public/common/page_transiti
Jun Mukai 2014/04/16 18:00:59 Done.
Jun Mukai 2014/04/16 18:00:59 Done.
142 chrome::Navigate(&params);
143 } else {
144 chrome::ShowSingletonTab(browser, GURL(
bartfab (slow) 2014/04/16 12:22:42 Nit: Use the |learn_more_url| constructed above in
Jun Mukai 2014/04/16 18:00:59 Done.
145 chrome::kEnhancedPlaybackNotificationLearnMoreURL));
146 }
133 } 147 }
134 148
135 } // namespace attestation 149 } // namespace attestation
136 } // namespace chromeos 150 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/attestation/platform_verification_dialog.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698