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

Unified Diff: chrome/browser/background/background_mode_manager.cc

Issue 564453003: Access to Chrome via the System Tray should go through the User Manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase continued Created 6 years, 3 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/background/background_mode_manager.h ('k') | chrome/browser/browser_process_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/background/background_mode_manager.cc
diff --git a/chrome/browser/background/background_mode_manager.cc b/chrome/browser/background/background_mode_manager.cc
index 8260dac752b764e908d35d74fff8cd0beb2ec80f..a6bb71b74b4251c45c921a81c135f24c8bc420da 100644
--- a/chrome/browser/background/background_mode_manager.cc
+++ b/chrome/browser/background/background_mode_manager.cc
@@ -28,11 +28,13 @@
#include "chrome/browser/status_icons/status_tray.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
+#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/host_desktop.h"
+#include "chrome/browser/ui/user_manager.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -483,19 +485,48 @@ void BackgroundModeManager::OnProfileNameChanged(
}
}
+BackgroundModeManager::BackgroundModeData*
+BackgroundModeManager::GetBackgroundModeDataForLastProfile() const {
+ Profile* most_recent_profile = g_browser_process->profile_manager()->
+ GetLastUsedProfileAllowedByPolicy();
+ BackgroundModeInfoMap::const_iterator profile_background_data =
+ background_mode_data_.find(most_recent_profile);
+
+ if (profile_background_data == background_mode_data_.end())
+ return NULL;
+
+ // Do not permit a locked profile to be used to open a browser.
+ ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
+ if (cache.ProfileIsSigninRequiredAtIndex(cache.GetIndexOfProfileWithPath(
+ profile_background_data->first->GetPath())))
+ return NULL;
+
+ return profile_background_data->second.get();
+}
+
///////////////////////////////////////////////////////////////////////////////
// BackgroundModeManager::BackgroundModeData, StatusIconMenuModel overrides
void BackgroundModeManager::ExecuteCommand(int command_id, int event_flags) {
- // When a browser window is necessary, we use the first profile. The windows
- // opened for these commands are not profile-specific, so any profile would
- // work and the first is convenient.
- BackgroundModeData* bmd = background_mode_data_.begin()->second.get();
+ BackgroundModeData* bmd = GetBackgroundModeDataForLastProfile();
switch (command_id) {
case IDC_ABOUT:
- chrome::ShowAboutChrome(bmd->GetBrowserWindow());
+ if (bmd) {
+ chrome::ShowAboutChrome(bmd->GetBrowserWindow());
+ } else {
+ UserManager::Show(base::FilePath(),
+ profiles::USER_MANAGER_NO_TUTORIAL,
+ profiles::USER_MANAGER_SELECT_PROFILE_ABOUT_CHROME);
+ }
break;
case IDC_TASK_MANAGER:
- chrome::OpenTaskManager(bmd->GetBrowserWindow());
+ if (bmd) {
+ chrome::OpenTaskManager(bmd->GetBrowserWindow());
+ } else {
+ UserManager::Show(base::FilePath(),
+ profiles::USER_MANAGER_NO_TUTORIAL,
+ profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER);
+ }
break;
case IDC_EXIT:
content::RecordAction(UserMetricsAction("Exit"));
@@ -515,7 +546,13 @@ void BackgroundModeManager::ExecuteCommand(int command_id, int event_flags) {
break;
}
default:
- bmd->ExecuteCommand(command_id, event_flags);
+ if (bmd) {
+ bmd->ExecuteCommand(command_id, event_flags);
+ } else {
+ UserManager::Show(base::FilePath(),
+ profiles::USER_MANAGER_NO_TUTORIAL,
+ profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
+ }
break;
}
}
« no previous file with comments | « chrome/browser/background/background_mode_manager.h ('k') | chrome/browser/browser_process_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698