OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/extensions/bookmark_app_confirmation_view.h" | 5 #include "chrome/browser/ui/views/extensions/bookmark_app_confirmation_view.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "chrome/browser/ui/views/harmony/layout_delegate.h" |
11 #include "chrome/grit/generated_resources.h" | 12 #include "chrome/grit/generated_resources.h" |
12 #include "components/constrained_window/constrained_window_views.h" | 13 #include "components/constrained_window/constrained_window_views.h" |
13 #include "components/strings/grit/components_strings.h" | 14 #include "components/strings/grit/components_strings.h" |
14 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
15 #include "extensions/common/constants.h" | 16 #include "extensions/common/constants.h" |
16 #include "ui/accessibility/ax_node_data.h" | 17 #include "ui/accessibility/ax_node_data.h" |
17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
19 #include "ui/gfx/image/image_skia.h" | 20 #include "ui/gfx/image/image_skia.h" |
20 #include "ui/gfx/image/image_skia_source.h" | 21 #include "ui/gfx/image/image_skia_source.h" |
21 #include "ui/views/controls/button/checkbox.h" | 22 #include "ui/views/controls/button/checkbox.h" |
22 #include "ui/views/controls/image_view.h" | 23 #include "ui/views/controls/image_view.h" |
23 #include "ui/views/controls/textfield/textfield.h" | 24 #include "ui/views/controls/textfield/textfield.h" |
24 #include "ui/views/layout/box_layout.h" | 25 #include "ui/views/layout/box_layout.h" |
25 #include "ui/views/layout/layout_constants.h" | |
26 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
27 #include "ui/views/window/dialog_client_view.h" | 27 #include "ui/views/window/dialog_client_view.h" |
28 | 28 |
29 namespace { | 29 namespace { |
30 | 30 |
31 // Minimum width of the the bubble. | 31 // Minimum width of the the bubble. |
32 const int kMinBubbleWidth = 300; | 32 const int kMinBubbleWidth = 300; |
33 // Size of the icon. | 33 // Size of the icon. |
34 const int kIconSize = extension_misc::EXTENSION_ICON_MEDIUM; | 34 const int kIconSize = extension_misc::EXTENSION_ICON_MEDIUM; |
35 | 35 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 ->Show(); | 67 ->Show(); |
68 } | 68 } |
69 | 69 |
70 BookmarkAppConfirmationView::BookmarkAppConfirmationView( | 70 BookmarkAppConfirmationView::BookmarkAppConfirmationView( |
71 const WebApplicationInfo& web_app_info, | 71 const WebApplicationInfo& web_app_info, |
72 const BrowserWindow::ShowBookmarkAppBubbleCallback& callback) | 72 const BrowserWindow::ShowBookmarkAppBubbleCallback& callback) |
73 : web_app_info_(web_app_info), | 73 : web_app_info_(web_app_info), |
74 callback_(callback), | 74 callback_(callback), |
75 open_as_window_checkbox_(nullptr), | 75 open_as_window_checkbox_(nullptr), |
76 title_tf_(nullptr) { | 76 title_tf_(nullptr) { |
| 77 LayoutDelegate* layout_delegate = LayoutDelegate::Get(); |
| 78 // Align the contents with the dialog buttons. |
77 views::BoxLayout* layout = new views::BoxLayout( | 79 views::BoxLayout* layout = new views::BoxLayout( |
78 views::BoxLayout::kHorizontal, views::kButtonHEdgeMarginNew, | 80 views::BoxLayout::kHorizontal, |
79 views::kButtonHEdgeMarginNew, views::kButtonHEdgeMarginNew); | 81 layout_delegate->GetMetric(LayoutDelegate::Metric::DIALOG_BUTTON_MARGIN), |
| 82 layout_delegate->GetMetric(LayoutDelegate::Metric::PANEL_CONTENT_MARGIN), |
| 83 layout_delegate->GetMetric( |
| 84 LayoutDelegate::Metric::UNRELATED_CONTROL_HORIZONTAL_SPACING)); |
80 layout->set_cross_axis_alignment( | 85 layout->set_cross_axis_alignment( |
81 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); | 86 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); |
82 SetLayoutManager(layout); | 87 SetLayoutManager(layout); |
83 | 88 |
84 views::ImageView* icon_image_view = new views::ImageView(); | 89 views::ImageView* icon_image_view = new views::ImageView(); |
85 gfx::Size image_size(kIconSize, kIconSize); | 90 gfx::Size image_size(kIconSize, kIconSize); |
86 gfx::ImageSkia image(new WebAppInfoImageSource(kIconSize, web_app_info_), | 91 gfx::ImageSkia image(new WebAppInfoImageSource(kIconSize, web_app_info_), |
87 image_size); | 92 image_size); |
88 icon_image_view->SetImageSize(image_size); | 93 icon_image_view->SetImageSize(image_size); |
89 icon_image_view->SetImage(image); | 94 icon_image_view->SetImage(image); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 const base::string16& new_contents) { | 168 const base::string16& new_contents) { |
164 DCHECK_EQ(title_tf_, sender); | 169 DCHECK_EQ(title_tf_, sender); |
165 GetDialogClientView()->UpdateDialogButtons(); | 170 GetDialogClientView()->UpdateDialogButtons(); |
166 } | 171 } |
167 | 172 |
168 base::string16 BookmarkAppConfirmationView::GetTrimmedTitle() const { | 173 base::string16 BookmarkAppConfirmationView::GetTrimmedTitle() const { |
169 base::string16 title(title_tf_->text()); | 174 base::string16 title(title_tf_->text()); |
170 base::TrimWhitespace(title, base::TRIM_ALL, &title); | 175 base::TrimWhitespace(title, base::TRIM_ALL, &title); |
171 return title; | 176 return title; |
172 } | 177 } |
OLD | NEW |