#include "ash/system/bluetooth/bluetooth_observer.h"
#include "ash/system/chromeos/session/logout_button_observer.h"
#include "ash/system/date/clock_observer.h"
-#include "ash/system/drive/drive_observer.h"
#include "ash/system/ime/ime_observer.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_delegate.h"
#include "chrome/browser/chromeos/accessibility/magnification_manager.h"
#include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h"
#include "chrome/browser/chromeos/charger_replace/charger_replacement_dialog.h"
-#include "chrome/browser/chromeos/drive/drive_integration_service.h"
-#include "chrome/browser/chromeos/drive/job_list.h"
#include "chrome/browser/chromeos/enrollment_dialog_view.h"
#include "chrome/browser/chromeos/events/system_key_event_listener.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/login/ui/login_display_host.h"
#include "chrome/browser/chromeos/login/ui/login_display_host_impl.h"
#include "chrome/browser/chromeos/login/ui/user_adding_screen.h"
+#include "chrome/browser/chromeos/login/user_flow.h"
+#include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
#include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
-#include "chrome/browser/chromeos/login/users/user.h"
-#include "chrome/browser/chromeos/login/users/user_manager.h"
-#include "chrome/browser/chromeos/net/network_portal_detector.h"
#include "chrome/browser/chromeos/options/network_config_view.h"
#include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
#include "chrome/browser/chromeos/profiles/multiprofiles_intro_dialog.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/set_time_dialog.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
#include "chrome/browser/chromeos/sim_dialog_delegate.h"
#include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h"
-#include "chrome/browser/drive/drive_service_interface.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "chromeos/ime/ime_keyboard.h"
#include "chromeos/ime/input_method_manager.h"
#include "chromeos/login/login_state.h"
+#include "chromeos/network/portal_detector/network_portal_detector.h"
#include "components/google/core/browser/google_util.h"
#include "components/policy/core/common/cloud/cloud_policy_store.h"
+#include "components/user_manager/user.h"
+#include "components/user_manager/user_manager.h"
+#include "components/user_manager/user_type.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/user_metrics.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/time_format.h"
-using drive::DriveIntegrationService;
-using drive::DriveIntegrationServiceFactory;
-
namespace chromeos {
namespace {
const char kDisplaySettingsSubPageName[] = "display";
const char kDisplayOverscanSettingsSubPageName[] = "displayOverscan";
-// The URL for the Google Drive settings page.
-const char kDriveSettingsPageURL[] = "https://drive.google.com";
-
void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime,
const input_method::InputMethodUtil& util,
ash::IMEInfo* info) {
gfx::NativeWindow GetNativeWindowByStatus(ash::user::LoginStatus login_status,
bool session_started) {
+ bool isUserAddingRunning = ash::Shell::GetInstance()
+ ->session_state_delegate()
+ ->IsInSecondaryLoginScreen();
+
int container_id =
(!session_started || login_status == ash::user::LOGGED_IN_NONE ||
- login_status == ash::user::LOGGED_IN_LOCKED)
+ login_status == ash::user::LOGGED_IN_LOCKED || isUserAddingRunning)
? ash::kShellWindowId_LockSystemModalContainer
: ash::kShellWindowId_SystemModalContainer;
return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
container_id);
}
-// Converts drive::JobInfo to ash::DriveOperationStatus.
-// If the job is not of type that ash tray is interested, returns false.
-bool ConvertToDriveOperationStatus(const drive::JobInfo& info,
- ash::DriveOperationStatus* status) {
- if (info.job_type == drive::TYPE_DOWNLOAD_FILE) {
- status->type = ash::DriveOperationStatus::OPERATION_DOWNLOAD;
- } else if (info.job_type == drive::TYPE_UPLOAD_NEW_FILE ||
- info.job_type == drive::TYPE_UPLOAD_EXISTING_FILE) {
- status->type = ash::DriveOperationStatus::OPERATION_UPLOAD;
- } else {
- return false;
- }
-
- if (info.state == drive::STATE_NONE)
- status->state = ash::DriveOperationStatus::OPERATION_NOT_STARTED;
- else
- status->state = ash::DriveOperationStatus::OPERATION_IN_PROGRESS;
-
- status->id = info.job_id;
- status->file_path = info.file_path;
- status->progress = info.num_total_bytes == 0 ? 0.0 :
- static_cast<double>(info.num_completed_bytes) /
- static_cast<double>(info.num_total_bytes);
- return true;
-}
-
-// Converts drive::JobInfo that has finished in |error| state
-// to ash::DriveOperationStatus.
-// If the job is not of type that ash tray is interested, returns false.
-bool ConvertToFinishedDriveOperationStatus(const drive::JobInfo& info,
- drive::FileError error,
- ash::DriveOperationStatus* status) {
- if (!ConvertToDriveOperationStatus(info, status))
- return false;
- status->state = (error == drive::FILE_ERROR_OK)
- ? ash::DriveOperationStatus::OPERATION_COMPLETED
- : ash::DriveOperationStatus::OPERATION_FAILED;
- return true;
-}
-
-// Converts a list of drive::JobInfo to a list of ash::DriveOperationStatusList.
-ash::DriveOperationStatusList ConvertToDriveStatusList(
- const std::vector<drive::JobInfo>& list) {
- ash::DriveOperationStatusList results;
- for (size_t i = 0; i < list.size(); ++i) {
- ash::DriveOperationStatus status;
- if (ConvertToDriveOperationStatus(list[i], &status))
- results.push_back(status);
- }
- return results;
-}
-
void BluetoothPowerFailure() {
// TODO(sad): Show an error bubble?
}
BrowserList::RemoveObserver(this);
StopObservingAppWindowRegistry();
- // Stop observing Drive operations.
- UnobserveDriveUpdates();
-
policy::BrowserPolicyConnectorChromeOS* connector =
g_browser_process->platform_part()->browser_policy_connector_chromeos();
policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
return ash::user::LOGGED_IN_RETAIL_MODE;
case LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT:
return ash::user::LOGGED_IN_PUBLIC;
- case LoginState::LOGGED_IN_USER_LOCALLY_MANAGED:
- return ash::user::LOGGED_IN_LOCALLY_MANAGED;
+ case LoginState::LOGGED_IN_USER_SUPERVISED:
+ return ash::user::LOGGED_IN_SUPERVISED;
case LoginState::LOGGED_IN_USER_KIOSK_APP:
return ash::user::LOGGED_IN_KIOSK_APP;
}
base::UTF8ToUTF16(GetEnterpriseDomain()));
}
-const std::string SystemTrayDelegateChromeOS::GetLocallyManagedUserManager()
- const {
- if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED)
+const std::string SystemTrayDelegateChromeOS::GetSupervisedUserManager() const {
+ if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED)
return std::string();
- return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayEmail(
- chromeos::UserManager::Get()->GetActiveUser()->email());
+ return ChromeUserManager::Get()
+ ->GetSupervisedUserManager()
+ ->GetManagerDisplayEmail(
+ user_manager::UserManager::Get()->GetActiveUser()->email());
}
const base::string16
-SystemTrayDelegateChromeOS::GetLocallyManagedUserManagerName() const {
- if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED)
+SystemTrayDelegateChromeOS::GetSupervisedUserManagerName() const {
+ if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED)
return base::string16();
- return UserManager::Get()->GetSupervisedUserManager()->GetManagerDisplayName(
- chromeos::UserManager::Get()->GetActiveUser()->email());
+ return ChromeUserManager::Get()
+ ->GetSupervisedUserManager()
+ ->GetManagerDisplayName(
+ user_manager::UserManager::Get()->GetActiveUser()->email());
}
-const base::string16 SystemTrayDelegateChromeOS::GetLocallyManagedUserMessage()
+const base::string16 SystemTrayDelegateChromeOS::GetSupervisedUserMessage()
const {
- if (GetUserLoginStatus() != ash::user::LOGGED_IN_LOCALLY_MANAGED)
+ if (GetUserLoginStatus() != ash::user::LOGGED_IN_SUPERVISED)
return base::string16();
return l10n_util::GetStringFUTF16(
- IDS_USER_IS_LOCALLY_MANAGED_BY_NOTICE,
- base::UTF8ToUTF16(GetLocallyManagedUserManager()));
+ IDS_USER_IS_SUPERVISED_BY_NOTICE,
+ base::UTF8ToUTF16(GetSupervisedUserManager()));
}
bool SystemTrayDelegateChromeOS::SystemShouldUpgrade() const {
}
bool SystemTrayDelegateChromeOS::ShouldShowSettings() {
- return UserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings();
+ return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() &&
+ !ash::Shell::GetInstance()
+ ->session_state_delegate()
+ ->IsInSecondaryLoginScreen();
}
void SystemTrayDelegateChromeOS::ShowDateSettings() {
void SystemTrayDelegateChromeOS::ShowNetworkSettings(
const std::string& service_path) {
- if (!LoginState::Get()->IsUserLoggedIn())
+ bool userAddingRunning = ash::Shell::GetInstance()
+ ->session_state_delegate()
+ ->IsInSecondaryLoginScreen();
+
+ if (!LoginState::Get()->IsUserLoggedIn() || userAddingRunning)
return;
ShowNetworkSettingsPage(service_path);
}
visible_url != display_overscan_url);
}
-void SystemTrayDelegateChromeOS::ShowDriveSettings() {
- // TODO(tengs): Open the drive-specific settings page once we put it in.
- // For now just show Google Drive main page.
- chrome::ScopedTabbedBrowserDisplayer displayer(
- ProfileManager::GetActiveUserProfile(), chrome::HOST_DESKTOP_TYPE_ASH);
- chrome::ShowSingletonTabOverwritingNTP(
- displayer.browser(),
- chrome::GetSingletonTabNavigateParams(displayer.browser(),
- GURL(kDriveSettingsPageURL)));
-}
-
void SystemTrayDelegateChromeOS::ShowIMESettings() {
content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog"));
ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage);
chrome::ShowPolicy(displayer.browser());
}
-void SystemTrayDelegateChromeOS::ShowLocallyManagedUserInfo() {
+void SystemTrayDelegateChromeOS::ShowSupervisedUserInfo() {
// TODO(antrim): find out what should we show in this case.
// http://crbug.com/229762
}
void SystemTrayDelegateChromeOS::ShowEnterpriseInfo() {
ash::user::LoginStatus status = GetUserLoginStatus();
+ bool userAddingRunning = ash::Shell::GetInstance()
+ ->session_state_delegate()
+ ->IsInSecondaryLoginScreen();
+
if (status == ash::user::LOGGED_IN_NONE ||
- status == ash::user::LOGGED_IN_LOCKED) {
+ status == ash::user::LOGGED_IN_LOCKED || userAddingRunning) {
scoped_refptr<chromeos::HelpAppLauncher> help_app(
new chromeos::HelpAppLauncher(GetNativeWindow()));
help_app->ShowHelpTopic(chromeos::HelpAppLauncher::HELP_ENTERPRISE);
return;
// Only regular users could add other users to current session.
- if (UserManager::Get()->GetActiveUser()->GetType() !=
- User::USER_TYPE_REGULAR) {
+ if (user_manager::UserManager::Get()->GetActiveUser()->GetType() !=
+ user_manager::USER_TYPE_REGULAR) {
return;
}
- if (static_cast<int>(UserManager::Get()->GetLoggedInUsers().size()) >=
+ if (static_cast<int>(
+ user_manager::UserManager::Get()->GetLoggedInUsers().size()) >=
shell->session_state_delegate()->GetMaximumNumberOfLoggedInUsers())
return;
// Launch sign in screen to add another user to current session.
- if (UserManager::Get()->GetUsersAdmittedForMultiProfile().size()) {
+ if (user_manager::UserManager::Get()
+ ->GetUsersAdmittedForMultiProfile()
+ .size()) {
// Don't show dialog if any logged in user in multi-profiles session
// dismissed it.
bool show_intro = true;
- const UserList logged_in_users = UserManager::Get()->GetLoggedInUsers();
- for (UserList::const_iterator it = logged_in_users.begin();
+ const user_manager::UserList logged_in_users =
+ user_manager::UserManager::Get()->GetLoggedInUsers();
+ for (user_manager::UserList::const_iterator it = logged_in_users.begin();
it != logged_in_users.end();
++it) {
show_intro &= !multi_user_util::GetProfileFromUserID(
input_method::InputMethodManager::Get()->ActivateInputMethodMenuItem(key);
}
-void SystemTrayDelegateChromeOS::CancelDriveOperation(int32 operation_id) {
- DriveIntegrationService* integration_service = FindDriveIntegrationService();
- if (!integration_service)
- return;
-
- integration_service->job_list()->CancelJob(operation_id);
-}
-
-void SystemTrayDelegateChromeOS::GetDriveOperationStatusList(
- ash::DriveOperationStatusList* list) {
- DriveIntegrationService* integration_service = FindDriveIntegrationService();
- if (!integration_service)
- return;
-
- *list = ConvertToDriveStatusList(
- integration_service->job_list()->GetJobInfoList());
-}
-
void SystemTrayDelegateChromeOS::ShowNetworkConfigure(
const std::string& network_id,
gfx::NativeWindow parent_window) {
GetSystemTrayNotifier()->NotifyUserUpdate();
}
-bool SystemTrayDelegateChromeOS::IsNetworkBehindCaptivePortal(
- const std::string& service_path) const {
- NetworkPortalDetector::CaptivePortalState state =
- NetworkPortalDetector::Get()->GetCaptivePortalState(service_path);
- return state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL;
-}
-
bool SystemTrayDelegateChromeOS::IsSearchKeyMappedToCapsLock() {
return search_key_mapped_to_ == input_method::kCapsLockKey;
}
SystemTrayDelegateChromeOS::GetUserAccountsDelegate(
const std::string& user_id) {
if (!accounts_delegates_.contains(user_id)) {
- const User* user = UserManager::Get()->FindUser(user_id);
- Profile* user_profile = UserManager::Get()->GetProfileByUser(user);
+ const user_manager::User* user =
+ user_manager::UserManager::Get()->FindUser(user_id);
+ Profile* user_profile = ProfileHelper::Get()->GetProfileByUserUnsafe(user);
CHECK(user_profile);
accounts_delegates_.set(
user_id,
}
void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) {
- // Stop observing the Drive integration status and the AppWindowRegistry of
- // the current |user_profile_|.
- UnobserveDriveUpdates();
+ // Stop observing the AppWindowRegistry of the current |user_profile_|.
StopObservingAppWindowRegistry();
user_profile_ = profile;
- // Start observing the Drive integration status and the AppWindowRegistry of
- // the newly set |user_profile_|.
- ObserveDriveUpdates();
+ // Start observing the AppWindowRegistry of the newly set |user_profile_|.
apps::AppWindowRegistry::Get(user_profile_)->AddObserver(this);
PrefService* prefs = profile->GetPrefs();
return true;
}
-void SystemTrayDelegateChromeOS::ObserveDriveUpdates() {
- DriveIntegrationService* integration_service = FindDriveIntegrationService();
- if (integration_service)
- integration_service->job_list()->AddObserver(this);
-}
-
-void SystemTrayDelegateChromeOS::UnobserveDriveUpdates() {
- DriveIntegrationService* integration_service = FindDriveIntegrationService();
- if (integration_service)
- integration_service->job_list()->RemoveObserver(this);
-}
-
bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const {
return ShouldUse24HourClock();
}
GetSystemTrayNotifier()->NotifyDateFormatChanged();
// This also works for enterprise-managed devices because they never have
// local owner.
- if (chromeos::UserManager::Get()->IsCurrentUserOwner())
+ if (user_manager::UserManager::Get()->IsCurrentUserOwner())
CrosSettings::Get()->SetBoolean(kSystemUse24HourClock, use_24_hour_clock);
}
// method, as LoggedInStateChanged() is also called before the logged-in
// user's profile has actually been loaded (http://crbug.com/317745). The
// system tray's time format is updated at login via SetProfile().
- if (chromeos::UserManager::Get()->IsCurrentUserOwner()) {
+ if (user_manager::UserManager::Get()->IsCurrentUserOwner()) {
CrosSettings::Get()->SetBoolean(kSystemUse24HourClock,
ShouldUse24HourClock());
}
GetSystemTrayNotifier()->NotifyAudioActiveInputNodeChanged();
}
-// drive::JobListObserver overrides.
-void SystemTrayDelegateChromeOS::OnJobAdded(const drive::JobInfo& job_info) {
- OnJobUpdated(job_info);
-}
-
-void SystemTrayDelegateChromeOS::OnJobDone(const drive::JobInfo& job_info,
- drive::FileError error) {
- ash::DriveOperationStatus status;
- if (ConvertToFinishedDriveOperationStatus(job_info, error, &status))
- GetSystemTrayNotifier()->NotifyDriveJobUpdated(status);
-}
-
-void SystemTrayDelegateChromeOS::OnJobUpdated(const drive::JobInfo& job_info) {
- ash::DriveOperationStatus status;
- if (ConvertToDriveOperationStatus(job_info, &status))
- GetSystemTrayNotifier()->NotifyDriveJobUpdated(status);
-}
-
-DriveIntegrationService*
-SystemTrayDelegateChromeOS::FindDriveIntegrationService() {
- return user_profile_
- ? DriveIntegrationServiceFactory::FindForProfile(user_profile_)
- : NULL;
-}
-
// Overridden from BluetoothAdapter::Observer.
void SystemTrayDelegateChromeOS::AdapterPresentChanged(
device::BluetoothAdapter* adapter,