| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/create_application_shortcut_view.h" | 5 #include "chrome/browser/ui/views/create_application_shortcut_view.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" |
| 11 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 12 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
| 13 #include "components/constrained_window/constrained_window_views.h" | 14 #include "components/constrained_window/constrained_window_views.h" |
| 14 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
| 15 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
| 16 #include "ui/base/l10n/l10n_util.h" | 17 #include "ui/base/l10n/l10n_util.h" |
| 17 #include "ui/views/controls/button/checkbox.h" | 18 #include "ui/views/controls/button/checkbox.h" |
| 18 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
| 19 #include "ui/views/layout/grid_layout.h" | 20 #include "ui/views/layout/grid_layout.h" |
| 20 #include "ui/views/layout/layout_constants.h" | 21 #include "ui/views/layout/layout_constants.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 l10n_util::GetStringUTF16( | 92 l10n_util::GetStringUTF16( |
| 92 IDS_CREATE_SHORTCUTS_QUICK_LAUNCH_BAR_CHKBOX), | 93 IDS_CREATE_SHORTCUTS_QUICK_LAUNCH_BAR_CHKBOX), |
| 93 profile_->GetPrefs()->GetBoolean(prefs::kWebAppCreateInQuickLaunchBar)); | 94 profile_->GetPrefs()->GetBoolean(prefs::kWebAppCreateInQuickLaunchBar)); |
| 94 } | 95 } |
| 95 #elif defined(OS_POSIX) | 96 #elif defined(OS_POSIX) |
| 96 menu_check_box_ = AddCheckbox( | 97 menu_check_box_ = AddCheckbox( |
| 97 l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_MENU_CHKBOX), | 98 l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_MENU_CHKBOX), |
| 98 profile_->GetPrefs()->GetBoolean(prefs::kWebAppCreateInAppsMenu)); | 99 profile_->GetPrefs()->GetBoolean(prefs::kWebAppCreateInAppsMenu)); |
| 99 #endif | 100 #endif |
| 100 | 101 |
| 102 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
| 103 |
| 101 // Layout controls | 104 // Layout controls |
| 102 views::GridLayout* layout = views::GridLayout::CreatePanel(this); | 105 views::GridLayout* layout = views::GridLayout::CreatePanel(this); |
| 103 | 106 |
| 104 static const int kHeaderColumnSetId = 0; | 107 static const int kHeaderColumnSetId = 0; |
| 105 views::ColumnSet* column_set = layout->AddColumnSet(kHeaderColumnSetId); | 108 views::ColumnSet* column_set = layout->AddColumnSet(kHeaderColumnSetId); |
| 106 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, | 109 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::CENTER, |
| 107 100.0f, views::GridLayout::FIXED, 0, 0); | 110 100.0f, views::GridLayout::FIXED, 0, 0); |
| 108 | 111 |
| 109 static const int kTableColumnSetId = 1; | 112 static const int kTableColumnSetId = 1; |
| 110 column_set = layout->AddColumnSet(kTableColumnSetId); | 113 column_set = layout->AddColumnSet(kTableColumnSetId); |
| 111 column_set->AddPaddingColumn(0, views::kCheckboxIndent); | 114 column_set->AddPaddingColumn( |
| 115 0, provider->GetDistanceMetric(DISTANCE_SUBSECTION_HORIZONTAL_INDENT)); |
| 112 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, | 116 column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, |
| 113 100.0f, views::GridLayout::USE_PREF, 0, 0); | 117 100.0f, views::GridLayout::USE_PREF, 0, 0); |
| 114 | 118 |
| 115 layout->StartRow(0, kHeaderColumnSetId); | 119 layout->StartRow(0, kHeaderColumnSetId); |
| 116 layout->AddView(create_shortcuts_label_); | 120 layout->AddView(create_shortcuts_label_); |
| 117 | 121 |
| 118 layout->AddPaddingRow(0, views::kLabelToControlVerticalSpacing); | 122 layout->AddPaddingRow(0, views::kLabelToControlVerticalSpacing); |
| 119 layout->StartRow(0, kTableColumnSetId); | 123 layout->StartRow(0, kTableColumnSetId); |
| 120 layout->AddView(desktop_check_box_); | 124 layout->AddView(desktop_check_box_); |
| 121 | 125 |
| 126 const int vertical_spacing = |
| 127 provider->GetDistanceMetric(DISTANCE_RELATED_CONTROL_VERTICAL_SMALL); |
| 122 if (menu_check_box_ != nullptr) { | 128 if (menu_check_box_ != nullptr) { |
| 123 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); | 129 layout->AddPaddingRow(0, vertical_spacing); |
| 124 layout->StartRow(0, kTableColumnSetId); | 130 layout->StartRow(0, kTableColumnSetId); |
| 125 layout->AddView(menu_check_box_); | 131 layout->AddView(menu_check_box_); |
| 126 } | 132 } |
| 127 | 133 |
| 128 if (quick_launch_check_box_ != nullptr) { | 134 if (quick_launch_check_box_ != nullptr) { |
| 129 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); | 135 layout->AddPaddingRow(0, vertical_spacing); |
| 130 layout->StartRow(0, kTableColumnSetId); | 136 layout->StartRow(0, kTableColumnSetId); |
| 131 layout->AddView(quick_launch_check_box_); | 137 layout->AddView(quick_launch_check_box_); |
| 132 } | 138 } |
| 133 } | 139 } |
| 134 | 140 |
| 135 gfx::Size CreateChromeApplicationShortcutView::GetPreferredSize() const { | 141 gfx::Size CreateChromeApplicationShortcutView::GetPreferredSize() const { |
| 136 // TODO(evanm): should this use IDS_CREATE_SHORTCUTS_DIALOG_WIDTH_CHARS? | 142 // TODO(evanm): should this use IDS_CREATE_SHORTCUTS_DIALOG_WIDTH_CHARS? |
| 137 static const int kDialogWidth = 360; | 143 static const int kDialogWidth = 360; |
| 138 int height = GetLayoutManager()->GetPreferredHeightForWidth(this, | 144 int height = GetLayoutManager()->GetPreferredHeightForWidth(this, |
| 139 kDialogWidth); | 145 kDialogWidth); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 views::Checkbox* checkbox = new views::Checkbox(text); | 237 views::Checkbox* checkbox = new views::Checkbox(text); |
| 232 checkbox->SetChecked(checked); | 238 checkbox->SetChecked(checked); |
| 233 checkbox->set_listener(this); | 239 checkbox->set_listener(this); |
| 234 return checkbox; | 240 return checkbox; |
| 235 } | 241 } |
| 236 | 242 |
| 237 void CreateChromeApplicationShortcutView::OnAppInfoLoaded( | 243 void CreateChromeApplicationShortcutView::OnAppInfoLoaded( |
| 238 std::unique_ptr<web_app::ShortcutInfo> shortcut_info) { | 244 std::unique_ptr<web_app::ShortcutInfo> shortcut_info) { |
| 239 shortcut_info_ = std::move(shortcut_info); | 245 shortcut_info_ = std::move(shortcut_info); |
| 240 } | 246 } |
| OLD | NEW |