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

Unified Diff: chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc

Issue 58813002: Upon activation on mixed mode, we only show and use apps of the current user. Furthermore we should… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed Created 7 years, 1 month 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
Index: chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
diff --git a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
index cbb15ec1c2556042a4c620a7705cc309806b9cfb..5fa426463c16806f94e0cd4f57d7a2a90165406f 100644
--- a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
+++ b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
@@ -31,6 +31,8 @@
#if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/login/default_pinned_apps_field_trial.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/browser/ui/ash/multi_user_window_manager.h"
#endif
using extensions::Extension;
@@ -40,6 +42,29 @@ namespace {
// The time delta between clicks in which clicks to launch V2 apps are ignored.
const int kClickSuppressionInMS = 1000;
+// Check if a browser can be used for activation. This addresses a special use
+// case in the M31 multi profile mode where a user activates a V1 app which only
+// exists yet on another users desktop, but he expects to get only his own app
+// items and not the ones from other users through activation.
+// TODO(skuhne): Remove this function and replace the call with
+// launcher_controller()->IsBrowserFromActiveUser(browser) once this experiment
+// goes away.
+bool CanBrowserBeUsedForDirectActivation(Browser* browser,
+ ChromeLauncherController* launcher) {
+#if defined(OS_CHROMEOS)
+ // If running in any multi user mode, check that the browser belongs to the
+ // active user.
+ if (chrome::MultiUserWindowManager::GetMultiProfileMode() ==
+ chrome::MultiUserWindowManager::MULTI_PROFILE_MODE_OFF)
+ return true;
+ chromeos::UserManager* manager = chromeos::UserManager::Get();
+ return manager->GetActiveUser() ==
+ manager->GetUserByProfile(browser->profile()->GetOriginalProfile());
+#else
+ return launcher->IsBrowserFromActiveUser(browser);
+#endif
+}
+
} // namespace
// Item controller for an app shortcut. Shortcuts track app and launcher ids,
@@ -101,7 +126,7 @@ void AppShortcutLauncherItemController::Launch(ash::LaunchSource source,
launcher_controller()->LaunchApp(app_id(), source, event_flags);
}
-void AppShortcutLauncherItemController::Activate(ash::LaunchSource source) {
+bool AppShortcutLauncherItemController::Activate(ash::LaunchSource source) {
content::WebContents* content = GetLRUApplication();
if (!content) {
if (IsV2App()) {
@@ -112,12 +137,13 @@ void AppShortcutLauncherItemController::Activate(ash::LaunchSource source) {
// detect if an app was started we suppress any further clicks within a
// special time out.
if (!AllowNextLaunchAttempt())
- return;
+ return false;
}
Launch(source, ui::EF_NONE);
- return;
+ return true;
}
ActivateContent(content);
+ return false;
}
void AppShortcutLauncherItemController::Close() {
@@ -190,7 +216,7 @@ AppShortcutLauncherItemController::GetRunningApplications() {
return items;
}
-void AppShortcutLauncherItemController::ItemSelected(const ui::Event& event) {
+bool AppShortcutLauncherItemController::ItemSelected(const ui::Event& event) {
#if defined(OS_CHROMEOS)
if (!app_id().empty())
chromeos::default_pinned_apps_field_trial::RecordShelfAppClick(app_id());
@@ -199,9 +225,9 @@ void AppShortcutLauncherItemController::ItemSelected(const ui::Event& event) {
// activate the next item in line if an item of our list is already active.
if (event.type() == ui::ET_KEY_RELEASED) {
if (AdvanceToNextApp())
- return;
+ return false;
}
- Activate(ash::LAUNCH_FROM_UNKNOWN);
+ return Activate(ash::LAUNCH_FROM_UNKNOWN);
}
base::string16 AppShortcutLauncherItemController::GetTitle() {
@@ -250,7 +276,7 @@ content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() {
it = ash_browser_list->begin_last_active();
it != ash_browser_list->end_last_active(); ++it) {
Browser* browser = *it;
- if (!launcher_controller()->IsBrowserFromActiveUser(browser))
+ if (!CanBrowserBeUsedForDirectActivation(browser, launcher_controller()))
continue;
TabStripModel* tab_strip = browser->tab_strip_model();
// We start to enumerate from the active index.
@@ -268,7 +294,7 @@ content::WebContents* AppShortcutLauncherItemController::GetLRUApplication() {
for (BrowserList::const_iterator it = ash_browser_list->begin();
it != ash_browser_list->end(); ++it) {
Browser* browser = *it;
- if (!launcher_controller()->IsBrowserFromActiveUser(browser))
+ if (!CanBrowserBeUsedForDirectActivation(browser, launcher_controller()))
continue;
TabStripModel* tab_strip = browser->tab_strip_model();
for (int index = 0; index < tab_strip->count(); index++) {

Powered by Google App Engine
This is Rietveld 408576698