Adding a dialog that warns about possible UI-oddities of after teleporting...

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
parent eb9114cd
......@@ -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
......
......@@ -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(
......
......@@ -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) {}
......@@ -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_
......@@ -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();
}
}
// 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
// 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_
......@@ -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)
......
......@@ -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())
......
......@@ -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',
......
......@@ -865,6 +865,11 @@ const char kRAConsentFirstTime[] = "settings.privacy.ra_consent";
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[] =
......
......@@ -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[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment