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

Unified Diff: chrome/browser/ui/views/create_application_shortcut_view.cc

Issue 2929733003: MacViews: Wire up CreateChromeApplicationShortcutView
Patch Set: rename ivar Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/create_application_shortcut_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/create_application_shortcut_view.cc
diff --git a/chrome/browser/ui/views/create_application_shortcut_view.cc b/chrome/browser/ui/views/create_application_shortcut_view.cc
index 6f8039614d08027692cd6154202d9cbeed7d7792..5667c961e68a414d20f76e2fcb291a9b26881657 100644
--- a/chrome/browser/ui/views/create_application_shortcut_view.cc
+++ b/chrome/browser/ui/views/create_application_shortcut_view.cc
@@ -16,6 +16,7 @@
#include "components/prefs/pref_service.h"
#include "extensions/common/extension.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/ui_features.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/grid_layout.h"
@@ -26,8 +27,17 @@
#include "base/win/windows_version.h"
#endif // defined(OS_WIN)
+namespace {
+
+bool IsChecked(views::Checkbox* checkbox) {
+ return checkbox && checkbox->checked();
+}
+
+} // namespace
+
namespace chrome {
+#if !defined(OS_MACOSX) || BUILDFLAG(MAC_VIEWS_BROWSER)
void ShowCreateChromeAppShortcutsDialog(
gfx::NativeWindow parent_window,
Profile* profile,
@@ -37,6 +47,7 @@ void ShowCreateChromeAppShortcutsDialog(
new CreateChromeApplicationShortcutView(profile, app, close_callback),
parent_window)->Show();
}
+#endif
} // namespace chrome
@@ -48,7 +59,7 @@ CreateChromeApplicationShortcutView::CreateChromeApplicationShortcutView(
close_callback_(close_callback),
create_shortcuts_label_(nullptr),
desktop_check_box_(nullptr),
- menu_check_box_(nullptr),
+ applications_check_box_(nullptr),
quick_launch_check_box_(nullptr),
weak_ptr_factory_(this) {
InitControls();
@@ -70,19 +81,22 @@ void CreateChromeApplicationShortcutView::InitControls() {
create_shortcuts_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
create_shortcuts_label_->SetMultiLine(true);
+ desktop_check_box_ = nullptr;
+ applications_check_box_ = nullptr;
+ quick_launch_check_box_ = nullptr;
+
+#if !defined(OS_MACOSX)
desktop_check_box_ = AddCheckbox(
l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_DESKTOP_CHKBOX),
profile_->GetPrefs()->GetBoolean(prefs::kWebAppCreateOnDesktop));
-
- menu_check_box_ = nullptr;
- quick_launch_check_box_ = nullptr;
+#endif
#if defined(OS_WIN)
base::win::Version version = base::win::GetVersion();
// Do not allow creating shortcuts on the Start Screen for Windows 8.
if (version != base::win::VERSION_WIN8 &&
version != base::win::VERSION_WIN8_1) {
- menu_check_box_ = AddCheckbox(
+ applications_check_box_ = AddCheckbox(
l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_START_MENU_CHKBOX),
profile_->GetPrefs()->GetBoolean(prefs::kWebAppCreateInAppsMenu));
}
@@ -97,9 +111,9 @@ void CreateChromeApplicationShortcutView::InitControls() {
IDS_CREATE_SHORTCUTS_QUICK_LAUNCH_BAR_CHKBOX),
profile_->GetPrefs()->GetBoolean(prefs::kWebAppCreateInQuickLaunchBar));
}
-#elif defined(OS_POSIX)
- menu_check_box_ = AddCheckbox(
- l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_MENU_CHKBOX),
+#else
+ applications_check_box_ = AddCheckbox(
+ l10n_util::GetStringUTF16(IDS_CREATE_SHORTCUTS_APPLICATIONS_CHKBOX),
profile_->GetPrefs()->GetBoolean(prefs::kWebAppCreateInAppsMenu));
#endif
@@ -123,17 +137,22 @@ void CreateChromeApplicationShortcutView::InitControls() {
layout->StartRow(0, kHeaderColumnSetId);
layout->AddView(create_shortcuts_label_);
- layout->AddPaddingRow(0, provider->GetDistanceMetric(
- views::DISTANCE_RELATED_CONTROL_VERTICAL));
- layout->StartRow(0, kTableColumnSetId);
- layout->AddView(desktop_check_box_);
-
- const int vertical_spacing =
+ int vertical_spacing =
+ provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
+ const int between_spacing =
provider->GetDistanceMetric(DISTANCE_RELATED_CONTROL_VERTICAL_SMALL);
- if (menu_check_box_ != nullptr) {
+ if (desktop_check_box_ != nullptr) {
layout->AddPaddingRow(0, vertical_spacing);
layout->StartRow(0, kTableColumnSetId);
- layout->AddView(menu_check_box_);
+ layout->AddView(desktop_check_box_);
+ vertical_spacing = between_spacing;
+ }
+
+ if (applications_check_box_ != nullptr) {
+ layout->AddPaddingRow(0, vertical_spacing);
+ layout->StartRow(0, kTableColumnSetId);
+ layout->AddView(applications_check_box_);
+ vertical_spacing = between_spacing;
}
if (quick_launch_check_box_ != nullptr) {
@@ -160,14 +179,9 @@ base::string16 CreateChromeApplicationShortcutView::GetDialogButtonLabel(
bool CreateChromeApplicationShortcutView::IsDialogButtonEnabled(
ui::DialogButton button) const {
- if (button == ui::DIALOG_BUTTON_OK)
- return desktop_check_box_->checked() ||
- ((menu_check_box_ != nullptr) &&
- menu_check_box_->checked()) ||
- ((quick_launch_check_box_ != nullptr) &&
- quick_launch_check_box_->checked());
-
- return true;
+ return button != ui::DIALOG_BUTTON_OK || IsChecked(desktop_check_box_) ||
+ IsChecked(applications_check_box_) ||
+ IsChecked(quick_launch_check_box_);
}
ui::ModalType CreateChromeApplicationShortcutView::GetModalType() const {
@@ -191,16 +205,15 @@ bool CreateChromeApplicationShortcutView::Accept() {
return false;
web_app::ShortcutLocations creation_locations;
- creation_locations.on_desktop = desktop_check_box_->checked();
- if (menu_check_box_ != nullptr && menu_check_box_->checked()) {
+ creation_locations.on_desktop = IsChecked(desktop_check_box_);
+ if (IsChecked(applications_check_box_)) {
creation_locations.applications_menu_location =
web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS;
}
#if defined(OS_WIN)
- creation_locations.in_quick_launch_bar = quick_launch_check_box_ == nullptr ?
- false : quick_launch_check_box_->checked();
-#elif defined(OS_POSIX)
+ creation_locations.in_quick_launch_bar = IsChecked(quick_launch_check_box_);
+#else
// Create shortcut in Mac dock or as Linux (gnome/kde) application launcher
// are not implemented yet.
creation_locations.in_quick_launch_bar = false;
@@ -224,9 +237,9 @@ void CreateChromeApplicationShortcutView::ButtonPressed(
if (sender == desktop_check_box_) {
profile_->GetPrefs()->SetBoolean(prefs::kWebAppCreateOnDesktop,
desktop_check_box_->checked());
- } else if (sender == menu_check_box_) {
+ } else if (sender == applications_check_box_) {
profile_->GetPrefs()->SetBoolean(prefs::kWebAppCreateInAppsMenu,
- menu_check_box_->checked());
+ applications_check_box_->checked());
} else if (sender == quick_launch_check_box_) {
profile_->GetPrefs()->SetBoolean(prefs::kWebAppCreateInQuickLaunchBar,
quick_launch_check_box_->checked());
« no previous file with comments | « chrome/browser/ui/views/create_application_shortcut_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698