Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/ui/views/chrome_cleaner_dialog_win.h" | 5 #include "chrome/browser/ui/views/chrome_cleaner_dialog_win.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_dialog_cont roller_win.h" | 8 #include "chrome/browser/safe_browsing/chrome_cleaner/chrome_cleaner_dialog_cont roller_win.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_dialogs.h" | 10 #include "chrome/browser/ui/browser_dialogs.h" |
| 11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 12 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | |
| 12 #include "components/constrained_window/constrained_window_views.h" | 13 #include "components/constrained_window/constrained_window_views.h" |
| 13 #include "ui/base/ui_base_types.h" | 14 #include "ui/base/ui_base_types.h" |
| 14 #include "ui/events/event.h" | 15 #include "ui/events/event.h" |
| 15 #include "ui/gfx/native_widget_types.h" | 16 #include "ui/gfx/native_widget_types.h" |
| 16 #include "ui/gfx/text_constants.h" | 17 #include "ui/gfx/text_constants.h" |
| 17 #include "ui/views/controls/button/md_text_button.h" | 18 #include "ui/views/controls/button/md_text_button.h" |
| 18 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
| 19 #include "ui/views/layout/box_layout.h" | 20 #include "ui/views/layout/box_layout.h" |
| 20 #include "ui/views/layout/layout_constants.h" | |
| 21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| 22 | 22 |
| 23 namespace chrome { | 23 namespace chrome { |
| 24 | 24 |
| 25 void ShowChromeCleanerPrompt( | 25 void ShowChromeCleanerPrompt( |
| 26 Browser* browser, | 26 Browser* browser, |
| 27 safe_browsing::ChromeCleanerDialogController* controller) { | 27 safe_browsing::ChromeCleanerDialogController* controller) { |
| 28 ChromeCleanerDialog* dialog = new ChromeCleanerDialog(controller); | 28 ChromeCleanerDialog* dialog = new ChromeCleanerDialog(controller); |
| 29 dialog->Show(browser); | 29 dialog->Show(browser); |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace chrome | 32 } // namespace chrome |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 constexpr int kDialogWidth = 448; | 35 constexpr int kDialogWidth = 448; |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 //////////////////////////////////////////////////////////////////////////////// | 38 //////////////////////////////////////////////////////////////////////////////// |
| 39 // ChromeCleanerDialog | 39 // ChromeCleanerDialog |
| 40 | 40 |
| 41 ChromeCleanerDialog::ChromeCleanerDialog( | 41 ChromeCleanerDialog::ChromeCleanerDialog( |
| 42 safe_browsing::ChromeCleanerDialogController* controller) | 42 safe_browsing::ChromeCleanerDialogController* controller) |
| 43 : browser_(nullptr), controller_(controller) { | 43 : browser_(nullptr), controller_(controller) { |
| 44 DCHECK(controller_); | 44 DCHECK(controller_); |
| 45 | 45 |
| 46 gfx::Insets dialog_insets = ChromeLayoutProvider::Get()->GetInsetsMetric( | |
| 47 views::INSETS_DIALOG_CONTENTS); | |
|
Peter Kasting
2017/06/06 03:34:33
For this file, wait on https://chromium-review.goo
ananta
2017/06/06 03:44:56
Sure reverted this change
| |
| 46 SetLayoutManager(new views::BoxLayout( | 48 SetLayoutManager(new views::BoxLayout( |
| 47 /*orientation=*/views::BoxLayout::kVertical, | 49 /*orientation=*/views::BoxLayout::kVertical, |
| 48 /*inside_border_horizontal_spacing=*/views::kButtonHEdgeMarginNew, | 50 /*inside_border_horizontal_spacing=*/dialog_insets.left(), |
| 49 /*inside_border_vertical_spacing=*/views::kPanelVertMargin, | 51 /*inside_border_vertical_spacing=*/dialog_insets.top(), |
| 50 /*between_child_spacing=*/0)); | 52 /*between_child_spacing=*/0)); |
| 51 views::Label* label = new views::Label(controller_->GetMainText()); | 53 views::Label* label = new views::Label(controller_->GetMainText()); |
| 52 label->SetMultiLine(true); | 54 label->SetMultiLine(true); |
| 53 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 55 label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
| 54 AddChildView(label); | 56 AddChildView(label); |
| 55 } | 57 } |
| 56 | 58 |
| 57 ChromeCleanerDialog::~ChromeCleanerDialog() { | 59 ChromeCleanerDialog::~ChromeCleanerDialog() { |
| 58 // Make sure the controller is correctly notified in case the dialog widget is | 60 // Make sure the controller is correctly notified in case the dialog widget is |
| 59 // closed by some other means than the dialog buttons. | 61 // closed by some other means than the dialog buttons. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 DCHECK(browser_); | 146 DCHECK(browser_); |
| 145 | 147 |
| 146 // TODO(alito): Navigate to the webui version of the Chrome Cleaner UI when | 148 // TODO(alito): Navigate to the webui version of the Chrome Cleaner UI when |
| 147 // that is implemented. | 149 // that is implemented. |
| 148 if (controller_) { | 150 if (controller_) { |
| 149 controller_->DetailsButtonClicked(); | 151 controller_->DetailsButtonClicked(); |
| 150 controller_ = nullptr; | 152 controller_ = nullptr; |
| 151 } | 153 } |
| 152 GetWidget()->Close(); | 154 GetWidget()->Close(); |
| 153 } | 155 } |
| OLD | NEW |