diff options
author | merkulova@chromium.org <merkulova@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-30 18:01:47 +0000 |
---|---|---|
committer | merkulova@chromium.org <merkulova@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-30 18:01:47 +0000 |
commit | 0c930814186d0cb74d1ae3df03d0b0e7669b473f (patch) | |
tree | 7adbe652ddc19effe2a71f56c97c6c91dc8d4311 | |
parent | eb9114cd985248192b472ec2824c86ea9b1719fd (diff) | |
download | chromium_src-0c930814186d0cb74d1ae3df03d0b0e7669b473f.zip chromium_src-0c930814186d0cb74d1ae3df03d0b0e7669b473f.tar.gz chromium_src-0c930814186d0cb74d1ae3df03d0b0e7669b473f.tar.bz2 |
Adding a dialog that warns about possible UI-oddities of after teleporting window to another user in multi-profiles mode.
BUG=318870
TBR=pkasting@chromium.org
Review URL: https://codereview.chromium.org/148093008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247992 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/generated_resources.grd | 12 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/multi_profile_first_run_notification.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/ash/multi_user/multi_user_context_menu.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/ash/multi_user/multi_user_context_menu.h | 4 | ||||
-rw-r--r-- | chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc | 87 | ||||
-rw-r--r-- | chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.cc | 163 | ||||
-rw-r--r-- | chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.h | 17 | ||||
-rw-r--r-- | chrome/browser/ui/browser_command_controller.cc | 17 | ||||
-rw-r--r-- | chrome/browser/ui/views/apps/native_app_window_views.cc | 2 | ||||
-rw-r--r-- | chrome/chrome_browser_ui.gypi | 2 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 5 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
12 files changed, 279 insertions, 37 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index d73db55..2eb1d72 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -1205,6 +1205,18 @@ Psst! Incognito mode <ph name="SHORTCUT_KEY">$1<ex>(Ctrl+Shift+N)</ex></ph> may <message name="IDS_VISIT_DESKTOP_OF_LRU_USER" desc="The text label of the menu item which allows the user to move a window from one users desktop to another."> Move window to <ph name="USER_NAME">$1<ex>User name</ex></ph> (<ph name="USER_EMAIL">$2<ex>john@google.com</ex></ph>) </message> + <message name="IDS_VISIT_DESKTOP_WARNING_TITLE" desc="The title of the dialog which warns user about oddities which can be seen when a window gets moved to another user desktop."> + Careful, this feature may bite + </message> + <message name="IDS_VISIT_DESKTOP_WARNING_MESSAGE" desc="The message on the dialog which warns user about oddities which can be seen when a window gets moved to another user desktop."> + Moving windows to another desktop may result in unexpected behaviour. + </message> + <message name="IDS_VISIT_DESKTOP_WARNING_EXPLANATION" desc="The explanation message on the dialog which warns user about oddities which can be seen when a window gets moved to another user desktop."> + Subsequent notifications, windows and dialogs may be split between desktops. + </message> + <message name="IDS_VISIT_DESKTOP_WARNING_SHOW_DISMISS" desc="Label for checkbox dismissing show of teleportation warning dialog."> + Got it, don't show me again. + </message> </if> <message name="IDS_ACCNAME_ZOOM_PLUS2" desc="The accessible description of the Make Text Larger menu item in the merged menu"> Make Text Larger diff --git a/chrome/browser/chromeos/login/multi_profile_first_run_notification.cc b/chrome/browser/chromeos/login/multi_profile_first_run_notification.cc index 69bc537..acbe4b2 100644 --- a/chrome/browser/chromeos/login/multi_profile_first_run_notification.cc +++ b/chrome/browser/chromeos/login/multi_profile_first_run_notification.cc @@ -70,6 +70,10 @@ void MultiProfileFirstRunNotification::RegisterProfilePrefs( prefs::kMultiProfileNeverShowIntro, false, user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); + registry->RegisterBooleanPref( + prefs::kMultiProfileWarningShowDismissed, + false, + user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); } void MultiProfileFirstRunNotification::UserProfilePrepared( diff --git a/chrome/browser/ui/ash/multi_user/multi_user_context_menu.cc b/chrome/browser/ui/ash/multi_user/multi_user_context_menu.cc index fa908cd..9280a1f 100644 --- a/chrome/browser/ui/ash/multi_user/multi_user_context_menu.cc +++ b/chrome/browser/ui/ash/multi_user/multi_user_context_menu.cc @@ -10,3 +10,5 @@ scoped_ptr<ui::MenuModel> CreateMultiUserContextMenu(aura::Window* window) { scoped_ptr<ui::MenuModel> menu_model; return menu_model.Pass(); } + +void ExecuteVisitDesktopCommand(int command_id, aura::Window* window) {} diff --git a/chrome/browser/ui/ash/multi_user/multi_user_context_menu.h b/chrome/browser/ui/ash/multi_user/multi_user_context_menu.h index 3128afd..42e38b9 100644 --- a/chrome/browser/ui/ash/multi_user/multi_user_context_menu.h +++ b/chrome/browser/ui/ash/multi_user/multi_user_context_menu.h @@ -18,4 +18,8 @@ class MenuModel; // The multi user context menu factory. scoped_ptr<ui::MenuModel> CreateMultiUserContextMenu(aura::Window* window); +// Executes move of a |window| to another profile. +// |command_id| defines a user whose desktop is being visited. +void ExecuteVisitDesktopCommand(int command_id, aura::Window* window); + #endif // CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_CONTEXT_MENU_H_ diff --git a/chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc b/chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc index 2b0b7a8..58c3d7f 100644 --- a/chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc +++ b/chrome/browser/ui/ash/multi_user/multi_user_context_menu_chromeos.cc @@ -7,15 +7,26 @@ #include "ash/multi_profile_uma.h" #include "ash/session_state_delegate.h" #include "ash/shell.h" +#include "base/bind.h" +#include "base/callback.h" +#include "base/prefs/pref_service.h" #include "base/strings/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" +#include "chrome/browser/chromeos/login/user.h" +#include "chrome/browser/chromeos/login/user_manager.h" +#include "chrome/browser/profiles/profile.h" +#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" +#include "chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.h" #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" +#include "chrome/common/pref_names.h" #include "grit/generated_resources.h" #include "ui/aura/window.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/simple_menu_model.h" +namespace chromeos { + namespace { class MultiUserContextMenuChromeos : public ui::SimpleMenuModel, @@ -52,30 +63,12 @@ MultiUserContextMenuChromeos::MultiUserContextMenuChromeos(aura::Window* window) void MultiUserContextMenuChromeos::ExecuteCommand(int command_id, int event_flags) { - switch (command_id) { - case IDC_VISIT_DESKTOP_OF_LRU_USER_2: - case IDC_VISIT_DESKTOP_OF_LRU_USER_3: { - ash::MultiProfileUMA::RecordTeleportAction( - ash::MultiProfileUMA::TELEPORT_WINDOW_CAPTION_MENU); - // When running the multi user mode on Chrome OS, windows can "visit" - // another user's desktop. - const std::string& user_id = - ash::Shell::GetInstance()->session_state_delegate()->GetUserID( - IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 : 2); - chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( - window_, - user_id); - return; - } - default: - NOTREACHED(); - } + ExecuteVisitDesktopCommand(command_id, window_); } - } // namespace +} // namespace chromeos -scoped_ptr<ui::MenuModel> CreateMultiUserContextMenu( - aura::Window* window) { +scoped_ptr<ui::MenuModel> CreateMultiUserContextMenu(aura::Window* window) { scoped_ptr<ui::MenuModel> model; ash::SessionStateDelegate* delegate = ash::Shell::GetInstance()->session_state_delegate(); @@ -91,8 +84,8 @@ scoped_ptr<ui::MenuModel> CreateMultiUserContextMenu( if (user_id.empty() || !window || manager->GetWindowOwner(window).empty()) return model.Pass(); - MultiUserContextMenuChromeos* menu = - new MultiUserContextMenuChromeos(window); + chromeos::MultiUserContextMenuChromeos* menu = + new chromeos::MultiUserContextMenuChromeos(window); model.reset(menu); for (int user_index = 1; user_index < logged_in_users; ++user_index) { menu->AddItem( @@ -106,3 +99,51 @@ scoped_ptr<ui::MenuModel> CreateMultiUserContextMenu( } return model.Pass(); } + +void OnAcceptTeleportWarning( + const std::string user_id, aura::Window* window_, bool no_show_again) { + PrefService* pref = ProfileManager::GetActiveUserProfile()->GetPrefs(); + pref->SetBoolean(prefs::kMultiProfileWarningShowDismissed, no_show_again); + + ash::MultiProfileUMA::RecordTeleportAction( + ash::MultiProfileUMA::TELEPORT_WINDOW_CAPTION_MENU); + + chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser(window_, + user_id); +} + +void ExecuteVisitDesktopCommand(int command_id, aura::Window* window) { + switch (command_id) { + case IDC_VISIT_DESKTOP_OF_LRU_USER_2: + case IDC_VISIT_DESKTOP_OF_LRU_USER_3: { + // When running the multi user mode on Chrome OS, windows can "visit" + // another user's desktop. + const std::string& user_id = + ash::Shell::GetInstance()->session_state_delegate()->GetUserID( + IDC_VISIT_DESKTOP_OF_LRU_USER_2 == command_id ? 1 : 2); + base::Callback<void(bool)> on_accept = + base::Bind(&OnAcceptTeleportWarning, user_id, window); + + // Don't show warning dialog if any logged in user in multi-profiles + // session dismissed it. + const chromeos::UserList logged_in_users = + chromeos::UserManager::Get()->GetLoggedInUsers(); + for (chromeos::UserList::const_iterator it = logged_in_users.begin(); + it != logged_in_users.end(); ++it) { + if (multi_user_util::GetProfileFromUserID( + multi_user_util::GetUserIDFromEmail((*it)->email()))->GetPrefs()-> + GetBoolean(prefs::kMultiProfileWarningShowDismissed)) { + bool active_user_show_option = + ProfileManager::GetActiveUserProfile()-> + GetPrefs()->GetBoolean(prefs::kMultiProfileWarningShowDismissed); + on_accept.Run(active_user_show_option); + return; + } + } + chromeos::ShowMultiprofilesWarningDialog(on_accept); + return; + } + default: + NOTREACHED(); + } +} diff --git a/chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.cc b/chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.cc new file mode 100644 index 0000000..dea5396 --- /dev/null +++ b/chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.cc @@ -0,0 +1,163 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.h" + +#include "ash/shell.h" +#include "grit/generated_resources.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/views/controls/button/checkbox.h" +#include "ui/views/controls/label.h" +#include "ui/views/layout/grid_layout.h" +#include "ui/views/widget/widget.h" +#include "ui/views/window/dialog_delegate.h" + +namespace chromeos { + +namespace { + +// Default width/height of the dialog. +const int kDefaultWidth = 600; +const int kDefaultHeight = 250; + +const int kPaddingToMessage = 30; +const int kPaddingToCheckBox = 50; +const int kInset = 40; +const int kTopInset = 10; + +//////////////////////////////////////////////////////////////////////////////// +// Dialog for multi-profiles teleport warning. +class TeleportWarningView : public views::DialogDelegateView { + public: + TeleportWarningView(base::Callback<void(bool)> on_accept); + virtual ~TeleportWarningView(); + + static void ShowDialog(const base::Callback<void(bool)> on_accept); + + // views::DialogDelegate overrides. + virtual bool Accept() OVERRIDE; + + // views::WidgetDelegate overrides. + virtual ui::ModalType GetModalType() const OVERRIDE; + + // views::View overrides. + virtual gfx::Size GetPreferredSize() OVERRIDE; + + private: + void InitDialog(); + + scoped_ptr<views::Checkbox> no_show_checkbox_; + const base::Callback<void(bool)> on_accept_; + + DISALLOW_COPY_AND_ASSIGN(TeleportWarningView); +}; + +//////////////////////////////////////////////////////////////////////////////// +// TeleportWarningView implementation. + +TeleportWarningView::TeleportWarningView( + const base::Callback<void(bool)> on_accept) + : on_accept_(on_accept) { +} + +TeleportWarningView::~TeleportWarningView() { +} + +// static +void TeleportWarningView::ShowDialog( + const base::Callback<void(bool)> on_accept) { + TeleportWarningView* dialog_view = + new TeleportWarningView(on_accept); + views::DialogDelegate::CreateDialogWidget( + dialog_view, ash::Shell::GetTargetRootWindow(), NULL); + dialog_view->InitDialog(); + views::Widget* widget = dialog_view->GetWidget(); + DCHECK(widget); + widget->Show(); +} + +bool TeleportWarningView::Accept() { + on_accept_.Run(no_show_checkbox_->checked()); + return true; +} + +ui::ModalType TeleportWarningView::GetModalType() const { + return ui::MODAL_TYPE_SYSTEM; +} + +gfx::Size TeleportWarningView::GetPreferredSize() { + return gfx::Size(kDefaultWidth, kDefaultHeight); +} + +void TeleportWarningView::InitDialog() { + const gfx::Insets kDialogInsets(kTopInset, kInset, kInset, kInset); + + // Create the views and layout manager and set them up. + views::GridLayout* grid_layout = views::GridLayout::CreatePanel(this); + grid_layout->SetInsets(kDialogInsets); + + views::ColumnSet* column_set = grid_layout->AddColumnSet(0); + column_set->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, + views::GridLayout::USE_PREF, 0, 0); + + // Title + views::Label* title_label_ = new views::Label( + l10n_util::GetStringUTF16(IDS_VISIT_DESKTOP_WARNING_TITLE)); + title_label_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( + ui::ResourceBundle::MediumBoldFont)); + title_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); + grid_layout->StartRow(0, 0); + grid_layout->AddView(title_label_); + grid_layout->AddPaddingRow(0, kPaddingToMessage); + + // Explanation string + views::Label* label = new views::Label( + l10n_util::GetStringUTF16(IDS_VISIT_DESKTOP_WARNING_MESSAGE)); + label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( + ui::ResourceBundle::MediumFont)); + label->SetMultiLine(true); + label->SetHorizontalAlignment(gfx::ALIGN_LEFT); + label->SetAllowCharacterBreak(true); + grid_layout->StartRow(0, 0); + grid_layout->AddView(label); + + // Next explanation string + grid_layout->AddPaddingRow(0, kPaddingToMessage); + views::Label* lower_label = new views::Label( + l10n_util::GetStringUTF16(IDS_VISIT_DESKTOP_WARNING_EXPLANATION)); + lower_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( + ui::ResourceBundle::MediumFont)); + lower_label->SetMultiLine(true); + lower_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); + lower_label->SetAllowCharacterBreak(true); + grid_layout->StartRow(0, 0); + grid_layout->AddView(lower_label); + + // No-show again checkbox + grid_layout->AddPaddingRow(0, kPaddingToCheckBox); + no_show_checkbox_.reset(new views::Checkbox( + l10n_util::GetStringUTF16(IDS_VISIT_DESKTOP_WARNING_SHOW_DISMISS))); + no_show_checkbox_->SetChecked(true); + no_show_checkbox_->SetFontList( + ui::ResourceBundle::GetSharedInstance().GetFontList( + ui::ResourceBundle::MediumFont)); + grid_layout->StartRow(0, 0); + grid_layout->AddView(no_show_checkbox_.get()); + + SetLayoutManager(grid_layout); + Layout(); +} + +} // namespace + +//////////////////////////////////////////////////////////////////////////////// +// Factory function. + +void ShowMultiprofilesWarningDialog( + const base::Callback<void(bool)> on_accept) { + TeleportWarningView::ShowDialog(on_accept); +} + +} // namespace chromeos diff --git a/chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.h b/chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.h new file mode 100644 index 0000000..8d34340 --- /dev/null +++ b/chrome/browser/ui/ash/multi_user/multi_user_warning_dialog.h @@ -0,0 +1,17 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WARNING_DIALOG_H_ +#define CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WARNING_DIALOG_H_ + +#include "base/callback.h" + +namespace chromeos { + +// Creates and shows dialog with introduction. +void ShowMultiprofilesWarningDialog(const base::Callback<void(bool)> on_accept); + +} // namespace chromeos + +#endif // CHROME_BROWSER_UI_ASH_MULTI_USER_MULTI_USER_WARNING_DIALOG_H_ diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc index 425f58d..57ea06b 100644 --- a/chrome/browser/ui/browser_command_controller.cc +++ b/chrome/browser/ui/browser_command_controller.cc @@ -63,6 +63,7 @@ #include "ash/multi_profile_uma.h" #include "ash/session_state_delegate.h" #include "ash/shell.h" +#include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" #include "chrome/browser/ui/browser_commands_chromeos.h" #endif @@ -468,19 +469,9 @@ void BrowserCommandController::ExecuteCommandWithDisposition( #if defined(OS_CHROMEOS) case IDC_VISIT_DESKTOP_OF_LRU_USER_2: - case IDC_VISIT_DESKTOP_OF_LRU_USER_3: { - ash::MultiProfileUMA::RecordTeleportAction( - ash::MultiProfileUMA::TELEPORT_WINDOW_CAPTION_MENU); - // When running the multi user mode on Chrome OS, windows can "visit" - // another user's desktop. - const std::string& user_id = - ash::Shell::GetInstance()->session_state_delegate()->GetUserID( - IDC_VISIT_DESKTOP_OF_LRU_USER_2 == id ? 1 : 2); - chrome::MultiUserWindowManager::GetInstance()->ShowWindowForUser( - browser_->window()->GetNativeWindow(), - user_id); - break; - } + case IDC_VISIT_DESKTOP_OF_LRU_USER_3: + ExecuteVisitDesktopCommand(id, browser_->window()->GetNativeWindow()); + break; #endif #if defined(OS_WIN) diff --git a/chrome/browser/ui/views/apps/native_app_window_views.cc b/chrome/browser/ui/views/apps/native_app_window_views.cc index 3f3f11a..e0af3f4 100644 --- a/chrome/browser/ui/views/apps/native_app_window_views.cc +++ b/chrome/browser/ui/views/apps/native_app_window_views.cc @@ -585,7 +585,7 @@ void NativeAppWindowViews::ShowContextMenuForView( views::View* source, const gfx::Point& p, ui::MenuSourceType source_type) { -#if defined(USE_ASH) +#if defined(USE_ASH) & defined(OS_CHROMEOS) scoped_ptr<ui::MenuModel> model = CreateMultiUserContextMenu( shell_window_->GetNativeWindow()); if (!model.get()) diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 1a834ee..dda3077 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -330,6 +330,8 @@ 'browser/ui/ash/multi_user/multi_user_notification_blocker_chromeos.h', 'browser/ui/ash/multi_user/multi_user_util.cc', 'browser/ui/ash/multi_user/multi_user_util.h', + 'browser/ui/ash/multi_user/multi_user_warning_dialog.cc', + 'browser/ui/ash/multi_user/multi_user_warning_dialog.h', 'browser/ui/ash/multi_user/multi_user_window_manager.cc', 'browser/ui/ash/multi_user/multi_user_window_manager.h', 'browser/ui/ash/multi_user/multi_user_window_manager_chromeos.cc', diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 1253c2e..21bd2f5f 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -866,6 +866,11 @@ const char kMultiProfileNeverShowIntro[] = "settings.multi_profile_never_show_intro"; // A boolean pref recording whether user has dismissed the multiprofile +// teleport warning dialog show. +const char kMultiProfileWarningShowDismissed[] = + "settings.multi_profile_warning_show_dismissed"; + +// A boolean pref recording whether user has dismissed the multiprofile // notification. const char kMultiProfileNotificationDismissed[] = "settings.multi_profile_notification_dismissed"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index dbefe78..db2ac4e 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -273,6 +273,7 @@ extern const char kTouchHudProjectionEnabled[]; extern const char kOpenNetworkConfiguration[]; extern const char kRAConsentFirstTime[]; extern const char kMultiProfileNeverShowIntro[]; +extern const char kMultiProfileWarningShowDismissed[]; extern const char kMultiProfileNotificationDismissed[]; extern const char kMultiProfileUserBehavior[]; extern const char kHighQualitySpeechSynthesisLanguages[]; |