| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser_dialogs.h" | 11 #include "chrome/browser/ui/browser_dialogs.h" |
| 12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 13 #include "chrome/browser/ui/browser_navigator.h" | 13 #include "chrome/browser/ui/browser_navigator.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "chrome/browser/ui/singleton_tabs.h" | 15 #include "chrome/browser/ui/singleton_tabs.h" |
| 16 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 16 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 17 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
| 18 #include "components/constrained_window/constrained_window_views.h" | 19 #include "components/constrained_window/constrained_window_views.h" |
| 19 #include "components/strings/grit/components_strings.h" | 20 #include "components/strings/grit/components_strings.h" |
| 20 #include "content/public/browser/navigation_handle.h" | 21 #include "content/public/browser/navigation_handle.h" |
| 21 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 22 #include "extensions/browser/extension_registry.h" | 23 #include "extensions/browser/extension_registry.h" |
| 23 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
| 24 #include "ui/aura/window.h" | 25 #include "ui/aura/window.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 26 #include "ui/base/page_transition_types.h" | 27 #include "ui/base/page_transition_types.h" |
| 27 #include "ui/views/border.h" | 28 #include "ui/views/border.h" |
| 28 #include "ui/views/controls/styled_label.h" | 29 #include "ui/views/controls/styled_label.h" |
| 29 #include "ui/views/layout/fill_layout.h" | 30 #include "ui/views/layout/fill_layout.h" |
| 30 #include "ui/views/layout/layout_constants.h" | |
| 31 #include "ui/views/widget/widget.h" | 31 #include "ui/views/widget/widget.h" |
| 32 #include "ui/views/window/dialog_delegate.h" | 32 #include "ui/views/window/dialog_delegate.h" |
| 33 | 33 |
| 34 namespace chromeos { | 34 namespace chromeos { |
| 35 namespace attestation { | 35 namespace attestation { |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 const int kDialogMaxWidthInPixel = 400; | 39 const int kDialogMaxWidthInPixel = 400; |
| 40 | 40 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 PlatformVerificationDialog::PlatformVerificationDialog( | 70 PlatformVerificationDialog::PlatformVerificationDialog( |
| 71 content::WebContents* web_contents, | 71 content::WebContents* web_contents, |
| 72 const base::string16& domain, | 72 const base::string16& domain, |
| 73 const ConsentCallback& callback) | 73 const ConsentCallback& callback) |
| 74 : content::WebContentsObserver(web_contents), | 74 : content::WebContentsObserver(web_contents), |
| 75 domain_(domain), | 75 domain_(domain), |
| 76 callback_(callback) { | 76 callback_(callback) { |
| 77 SetLayoutManager(new views::FillLayout()); | 77 SetLayoutManager(new views::FillLayout()); |
| 78 SetBorder(views::CreateEmptyBorder(0, views::kButtonHEdgeMarginNew, 0, | 78 |
| 79 views::kButtonHEdgeMarginNew)); | 79 gfx::Insets dialog_insets = ChromeLayoutProvider::Get()->GetInsetsMetric( |
| 80 views::INSETS_DIALOG_CONTENTS); |
| 81 SetBorder(views::CreateEmptyBorder(0, dialog_insets.left(), 0, |
| 82 dialog_insets.right())); |
| 80 const base::string16 learn_more = l10n_util::GetStringUTF16(IDS_LEARN_MORE); | 83 const base::string16 learn_more = l10n_util::GetStringUTF16(IDS_LEARN_MORE); |
| 81 std::vector<size_t> offsets; | 84 std::vector<size_t> offsets; |
| 82 base::string16 headline = l10n_util::GetStringFUTF16( | 85 base::string16 headline = l10n_util::GetStringFUTF16( |
| 83 IDS_PLATFORM_VERIFICATION_DIALOG_HEADLINE, domain_, learn_more, &offsets); | 86 IDS_PLATFORM_VERIFICATION_DIALOG_HEADLINE, domain_, learn_more, &offsets); |
| 84 views::StyledLabel* headline_label = new views::StyledLabel(headline, this); | 87 views::StyledLabel* headline_label = new views::StyledLabel(headline, this); |
| 85 headline_label->AddStyleRange( | 88 headline_label->AddStyleRange( |
| 86 gfx::Range(offsets[1], offsets[1] + learn_more.size()), | 89 gfx::Range(offsets[1], offsets[1] + learn_more.size()), |
| 87 views::StyledLabel::RangeStyleInfo::CreateForLink()); | 90 views::StyledLabel::RangeStyleInfo::CreateForLink()); |
| 88 AddChildView(headline_label); | 91 AddChildView(headline_label); |
| 89 chrome::RecordDialogCreation(chrome::DialogIdentifier::PLATFORM_VERIFICATION); | 92 chrome::RecordDialogCreation(chrome::DialogIdentifier::PLATFORM_VERIFICATION); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 navigation_handle->IsSameDocument()) | 161 navigation_handle->IsSameDocument()) |
| 159 return; | 162 return; |
| 160 | 163 |
| 161 views::Widget* widget = GetWidget(); | 164 views::Widget* widget = GetWidget(); |
| 162 if (widget) | 165 if (widget) |
| 163 widget->Close(); | 166 widget->Close(); |
| 164 } | 167 } |
| 165 | 168 |
| 166 } // namespace attestation | 169 } // namespace attestation |
| 167 } // namespace chromeos | 170 } // namespace chromeos |
| OLD | NEW |