Commit 932a4e28 authored by zelidrag@chromium.org's avatar zelidrag@chromium.org

Created uber tray UI for monitoring ongoing WebDrive sync operations

BUG=chromium-os:30075
TEST=none

Review URL: https://chromiumcodereview.appspot.com/10214013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134774 0039d316-1c4b-4281-b951-d872f2087c98
parent 2b9c8770
...@@ -134,6 +134,9 @@ ...@@ -134,6 +134,9 @@
'system/date/date_view.h', 'system/date/date_view.h',
'system/date/tray_date.cc', 'system/date/tray_date.cc',
'system/date/tray_date.h', 'system/date/tray_date.h',
'system/drive/drive_observer.h',
'system/drive/tray_drive.cc',
'system/drive/tray_drive.h',
'system/ime/ime_observer.h', 'system/ime/ime_observer.h',
'system/ime/tray_ime.cc', 'system/ime/tray_ime.cc',
'system/ime/tray_ime.h', 'system/ime/tray_ime.h',
...@@ -149,6 +152,7 @@ ...@@ -149,6 +152,7 @@
'system/settings/tray_settings.h', 'system/settings/tray_settings.h',
'system/tray/system_tray.cc', 'system/tray/system_tray.cc',
'system/tray/system_tray.h', 'system/tray/system_tray.h',
'system/tray/system_tray_delegate.cc',
'system/tray/system_tray_delegate.h', 'system/tray/system_tray_delegate.h',
'system/tray/system_tray_item.cc', 'system/tray/system_tray_item.cc',
'system/tray/system_tray_item.h', 'system/tray/system_tray_item.h',
......
...@@ -282,6 +282,15 @@ This file contains the strings for ash. ...@@ -282,6 +282,15 @@ This file contains the strings for ash.
<message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_ADD_DEVICE" desc="The label used in the tray popup to add a bluetooth device."> <message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_ADD_DEVICE" desc="The label used in the tray popup to add a bluetooth device.">
Add device... Add device...
</message> </message>
<message name="IDS_ASH_STATUS_TRAY_DRIVE_SYNCING" desc="The label in the tray to indicate onoing file sync operations.">
Syncing <ph name="count">$1<ex>3</ex></ph> file(s)
</message>
<message name="IDS_ASH_STATUS_TRAY_DRIVE" desc="The label used for Google Drive tray details header.">
Google Drive
</message>
<message name="IDS_ASH_STATUS_TRAY_DRIVE_SETTINGS" desc="The label used for Google Drive settings entry.">
Google Drive settings...
</message>
<message name="IDS_ASH_STATUS_TRAY_IME" desc="The label used as the header in the IME popup."> <message name="IDS_ASH_STATUS_TRAY_IME" desc="The label used as the header in the IME popup.">
Input methods Input methods
</message> </message>
......
...@@ -309,6 +309,9 @@ class DummySystemTrayDelegate : public SystemTrayDelegate { ...@@ -309,6 +309,9 @@ class DummySystemTrayDelegate : public SystemTrayDelegate {
virtual void ShowBluetoothSettings() OVERRIDE { virtual void ShowBluetoothSettings() OVERRIDE {
} }
virtual void ShowDriveSettings() OVERRIDE {
}
virtual void ShowIMESettings() OVERRIDE { virtual void ShowIMESettings() OVERRIDE {
} }
...@@ -375,6 +378,13 @@ class DummySystemTrayDelegate : public SystemTrayDelegate { ...@@ -375,6 +378,13 @@ class DummySystemTrayDelegate : public SystemTrayDelegate {
virtual void ActivateIMEProperty(const std::string& key) OVERRIDE { virtual void ActivateIMEProperty(const std::string& key) OVERRIDE {
} }
virtual void CancelDriveOperation(const FilePath&) OVERRIDE {
}
virtual void GetDriveOperationStatusList(
ash::DriveOperationStatusList*) OVERRIDE {
}
virtual void GetMostRelevantNetworkIcon(NetworkIconInfo* info, virtual void GetMostRelevantNetworkIcon(NetworkIconInfo* info,
bool large) OVERRIDE { bool large) OVERRIDE {
} }
......
// Copyright (c) 2012 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 ASH_SYSTEM_DRIVE_DRIVE_OBSERVER_H_
#define ASH_SYSTEM_DRIVE_DRIVE_OBSERVER_H_
#pragma once
#include "ash/system/tray/system_tray_delegate.h"
namespace ash {
class DriveObserver {
public:
virtual void OnDriveRefresh(const DriveOperationStatusList& list) = 0;
protected:
virtual ~DriveObserver() {}
};
} // namespace ash
#endif // ASH_SYSTEM_DRIVE_DRIVE_OBSERVER_H_
This diff is collapsed.
// Copyright (c) 2012 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 ASH_SYSTEM_DRIVE_TRAY_DRIVE_H_
#define ASH_SYSTEM_DRIVE_TRAY_DRIVE_H_
#pragma once
#include "ash/system/drive/drive_observer.h"
#include "ash/system/tray/tray_image_item.h"
#include "base/memory/scoped_ptr.h"
namespace views {
class Label;
}
namespace ash {
namespace internal {
namespace tray {
class DriveTrayView;
class DriveDefaultView;
class DriveDetailedView;
}
class TrayDrive : public TrayImageItem,
public DriveObserver {
public:
TrayDrive();
virtual ~TrayDrive();
private:
// Overridden from TrayImageItem.
virtual bool GetInitialVisibility() OVERRIDE;
// Overridden from SystemTrayItem.
virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE;
virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE;
virtual void DestroyDefaultView() OVERRIDE;
virtual void DestroyDetailedView() OVERRIDE;
virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE;
// Overridden from DriveObserver.
virtual void OnDriveRefresh(const DriveOperationStatusList& list) OVERRIDE;
// Delayed re-check of the status after encounter operation depleted list.
void OnStatusCheck();
void UpdateTrayIcon(bool show);
tray::DriveDefaultView* default_;
tray::DriveDetailedView* detailed_;
DISALLOW_COPY_AND_ASSIGN(TrayDrive);
};
} // namespace internal
} // namespace ash
#endif // ASH_SYSTEM_DRIVE_TRAY_DRIVE_H_
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "ash/system/bluetooth/tray_bluetooth.h" #include "ash/system/bluetooth/tray_bluetooth.h"
#include "ash/system/brightness/tray_brightness.h" #include "ash/system/brightness/tray_brightness.h"
#include "ash/system/date/tray_date.h" #include "ash/system/date/tray_date.h"
#include "ash/system/drive/tray_drive.h"
#include "ash/system/ime/tray_ime.h" #include "ash/system/ime/tray_ime.h"
#include "ash/system/network/tray_network.h" #include "ash/system/network/tray_network.h"
#include "ash/system/power/power_status_observer.h" #include "ash/system/power/power_status_observer.h"
...@@ -136,6 +137,10 @@ class TrayPopupItemContainer : public views::View { ...@@ -136,6 +137,10 @@ class TrayPopupItemContainer : public views::View {
PreferredSizeChanged(); PreferredSizeChanged();
} }
virtual void ChildPreferredSizeChanged(View* child) OVERRIDE {
PreferredSizeChanged();
}
virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE { virtual void OnMouseEntered(const views::MouseEvent& event) OVERRIDE {
hover_ = true; hover_ = true;
SchedulePaint(); SchedulePaint();
...@@ -605,37 +610,6 @@ void SystemTrayBubble::OnWidgetVisibilityChanged(views::Widget* widget, ...@@ -605,37 +610,6 @@ void SystemTrayBubble::OnWidgetVisibilityChanged(views::Widget* widget,
} // namespace internal } // namespace internal
// From system_tray_delegate.h
NetworkIconInfo::NetworkIconInfo()
: highlight(false),
tray_icon_visible(true) {
}
NetworkIconInfo::~NetworkIconInfo() {
}
BluetoothDeviceInfo::BluetoothDeviceInfo()
: connected(false) {
}
BluetoothDeviceInfo::~BluetoothDeviceInfo() {
}
IMEInfo::IMEInfo()
: selected(false) {
}
IMEInfo::~IMEInfo() {
}
IMEPropertyInfo::IMEPropertyInfo()
: selected(false) {
}
IMEPropertyInfo::~IMEPropertyInfo() {
}
// SystemTray // SystemTray
SystemTray::SystemTray() SystemTray::SystemTray()
...@@ -646,6 +620,7 @@ SystemTray::SystemTray() ...@@ -646,6 +620,7 @@ SystemTray::SystemTray()
brightness_observer_(NULL), brightness_observer_(NULL),
caps_lock_observer_(NULL), caps_lock_observer_(NULL),
clock_observer_(NULL), clock_observer_(NULL),
drive_observer_(NULL),
ime_observer_(NULL), ime_observer_(NULL),
network_observer_(NULL), network_observer_(NULL),
power_status_observer_(NULL), power_status_observer_(NULL),
...@@ -696,6 +671,7 @@ void SystemTray::CreateItems() { ...@@ -696,6 +671,7 @@ void SystemTray::CreateItems() {
internal::TrayAccessibility* tray_accessibility = internal::TrayAccessibility* tray_accessibility =
new internal::TrayAccessibility; new internal::TrayAccessibility;
internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock; internal::TrayCapsLock* tray_caps_lock = new internal::TrayCapsLock;
internal::TrayDrive* tray_drive = new internal::TrayDrive;
internal::TrayIME* tray_ime = new internal::TrayIME; internal::TrayIME* tray_ime = new internal::TrayIME;
internal::TrayUpdate* tray_update = new internal::TrayUpdate; internal::TrayUpdate* tray_update = new internal::TrayUpdate;
...@@ -705,6 +681,7 @@ void SystemTray::CreateItems() { ...@@ -705,6 +681,7 @@ void SystemTray::CreateItems() {
brightness_observer_ = tray_brightness; brightness_observer_ = tray_brightness;
caps_lock_observer_ = tray_caps_lock; caps_lock_observer_ = tray_caps_lock;
clock_observer_ = tray_date; clock_observer_ = tray_date;
drive_observer_ = tray_drive;
ime_observer_ = tray_ime; ime_observer_ = tray_ime;
network_observer_ = tray_network; network_observer_ = tray_network;
power_status_observer_ = tray_power; power_status_observer_ = tray_power;
...@@ -716,6 +693,7 @@ void SystemTray::CreateItems() { ...@@ -716,6 +693,7 @@ void SystemTray::CreateItems() {
AddTrayItem(tray_power); AddTrayItem(tray_power);
AddTrayItem(tray_network); AddTrayItem(tray_network);
AddTrayItem(tray_bluetooth); AddTrayItem(tray_bluetooth);
AddTrayItem(tray_drive);
AddTrayItem(tray_ime); AddTrayItem(tray_ime);
AddTrayItem(tray_volume); AddTrayItem(tray_volume);
AddTrayItem(tray_brightness); AddTrayItem(tray_brightness);
......
...@@ -26,6 +26,7 @@ class BluetoothObserver; ...@@ -26,6 +26,7 @@ class BluetoothObserver;
class BrightnessObserver; class BrightnessObserver;
class CapsLockObserver; class CapsLockObserver;
class ClockObserver; class ClockObserver;
class DriveObserver;
class IMEObserver; class IMEObserver;
class NetworkObserver; class NetworkObserver;
class PowerStatusObserver; class PowerStatusObserver;
...@@ -105,6 +106,9 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( ...@@ -105,6 +106,9 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE(
ClockObserver* clock_observer() const { ClockObserver* clock_observer() const {
return clock_observer_; return clock_observer_;
} }
DriveObserver* drive_observer() const {
return drive_observer_;
}
IMEObserver* ime_observer() const { IMEObserver* ime_observer() const {
return ime_observer_; return ime_observer_;
} }
...@@ -160,6 +164,7 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE( ...@@ -160,6 +164,7 @@ class ASH_EXPORT SystemTray : NON_EXPORTED_BASE(
BrightnessObserver* brightness_observer_; BrightnessObserver* brightness_observer_;
CapsLockObserver* caps_lock_observer_; CapsLockObserver* caps_lock_observer_;
ClockObserver* clock_observer_; ClockObserver* clock_observer_;
DriveObserver* drive_observer_;
IMEObserver* ime_observer_; IMEObserver* ime_observer_;
NetworkObserver* network_observer_; NetworkObserver* network_observer_;
PowerStatusObserver* power_status_observer_; PowerStatusObserver* power_status_observer_;
......
// Copyright (c) 2012 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 "ash/system/tray/system_tray_delegate.h"
namespace ash {
NetworkIconInfo::NetworkIconInfo()
: highlight(false),
tray_icon_visible(true) {
}
NetworkIconInfo::~NetworkIconInfo() {
}
BluetoothDeviceInfo::BluetoothDeviceInfo()
: connected(false) {
}
BluetoothDeviceInfo::~BluetoothDeviceInfo() {
}
DriveOperationStatus::DriveOperationStatus()
: progress(0.0), type(OPERATION_OTHER), state(OPERATION_NOT_STARTED) {
}
DriveOperationStatus::~DriveOperationStatus() {
}
IMEInfo::IMEInfo()
: selected(false) {
}
IMEInfo::~IMEInfo() {
}
IMEPropertyInfo::IMEPropertyInfo()
: selected(false) {
}
IMEPropertyInfo::~IMEPropertyInfo() {
}
} // namespace ash
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/system/user/login_status.h" #include "ash/system/user/login_status.h"
#include "ash/system/power/power_supply_status.h" #include "ash/system/power/power_supply_status.h"
#include "base/file_path.h"
#include "base/i18n/time_formatting.h" #include "base/i18n/time_formatting.h"
#include "base/string16.h" #include "base/string16.h"
#include "third_party/skia/include/core/SkBitmap.h" #include "third_party/skia/include/core/SkBitmap.h"
...@@ -43,6 +44,37 @@ struct ASH_EXPORT BluetoothDeviceInfo { ...@@ -43,6 +44,37 @@ struct ASH_EXPORT BluetoothDeviceInfo {
typedef std::vector<BluetoothDeviceInfo> BluetoothDeviceList; typedef std::vector<BluetoothDeviceInfo> BluetoothDeviceList;
// Structure that packs progress information of each operation.
struct ASH_EXPORT DriveOperationStatus {
enum OperationType {
OPERATION_UPLOAD,
OPERATION_DOWNLOAD,
OPERATION_OTHER,
};
enum OperationState {
OPERATION_NOT_STARTED,
OPERATION_STARTED,
OPERATION_IN_PROGRESS,
OPERATION_COMPLETED,
OPERATION_FAILED,
OPERATION_SUSPENDED,
};
DriveOperationStatus();
~DriveOperationStatus();
// File path.
FilePath file_path;
// Current operation completion progress [0.0 - 1.0].
double progress;
OperationType type;
OperationState state;
};
typedef std::vector<DriveOperationStatus> DriveOperationStatusList;
struct ASH_EXPORT IMEPropertyInfo { struct ASH_EXPORT IMEPropertyInfo {
IMEPropertyInfo(); IMEPropertyInfo();
~IMEPropertyInfo(); ~IMEPropertyInfo();
...@@ -106,6 +138,9 @@ class SystemTrayDelegate { ...@@ -106,6 +138,9 @@ class SystemTrayDelegate {
// Shows the settings related to bluetooth. // Shows the settings related to bluetooth.
virtual void ShowBluetoothSettings() = 0; virtual void ShowBluetoothSettings() = 0;
// Shows settings related to Google Drive.
virtual void ShowDriveSettings() = 0;
// Shows settings related to input methods. // Shows settings related to input methods.
virtual void ShowIMESettings() = 0; virtual void ShowIMESettings() = 0;
...@@ -166,6 +201,13 @@ class SystemTrayDelegate { ...@@ -166,6 +201,13 @@ class SystemTrayDelegate {
// Activates an IME property. // Activates an IME property.
virtual void ActivateIMEProperty(const std::string& key) = 0; virtual void ActivateIMEProperty(const std::string& key) = 0;
// Cancels ongoing drive operation.
virtual void CancelDriveOperation(const FilePath& file_path) = 0;
// Returns information about the ongoing drive operations.
virtual void GetDriveOperationStatusList(
DriveOperationStatusList* list) = 0;
// Returns information about the most relevant network. Relevance is // Returns information about the most relevant network. Relevance is
// determined by the implementor (e.g. a connecting network may be more // determined by the implementor (e.g. a connecting network may be more
// relevant over a connected network etc.) // relevant over a connected network etc.)
......
...@@ -272,11 +272,11 @@ bool GDataOperationRegistry::IsFileTransferOperation( ...@@ -272,11 +272,11 @@ bool GDataOperationRegistry::IsFileTransferOperation(
return type == OPERATION_UPLOAD || type == OPERATION_DOWNLOAD; return type == OPERATION_UPLOAD || type == OPERATION_DOWNLOAD;
} }
std::vector<GDataOperationRegistry::ProgressStatus> GDataOperationRegistry::ProgressStatusList
GDataOperationRegistry::GetProgressStatusList() { GDataOperationRegistry::GetProgressStatusList() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
std::vector<ProgressStatus> status_list; ProgressStatusList status_list;
for (OperationIDMap::const_iterator iter(&in_flight_operations_); for (OperationIDMap::const_iterator iter(&in_flight_operations_);
!iter.IsAtEnd(); !iter.IsAtEnd();
iter.Advance()) { iter.Advance()) {
......
...@@ -69,12 +69,13 @@ class GDataOperationRegistry { ...@@ -69,12 +69,13 @@ class GDataOperationRegistry {
// -1 if no expectation is available (yet). // -1 if no expectation is available (yet).
int64 progress_total; int64 progress_total;
}; };
typedef std::vector<ProgressStatus> ProgressStatusList;
// Observer interface for listening changes in the active set of operations. // Observer interface for listening changes in the active set of operations.
class Observer { class Observer {
public: public:
// Called when a GData operation started, made some progress, or finished. // Called when a GData operation started, made some progress, or finished.
virtual void OnProgressUpdate(const std::vector<ProgressStatus>& list) = 0; virtual void OnProgressUpdate(const ProgressStatusList& list) = 0;
protected: protected:
virtual ~Observer() {} virtual ~Observer() {}
}; };
...@@ -128,7 +129,7 @@ class GDataOperationRegistry { ...@@ -128,7 +129,7 @@ class GDataOperationRegistry {
bool CancelForFilePath(const FilePath& file_path); bool CancelForFilePath(const FilePath& file_path);
// Obtains the list of currently active operations. // Obtains the list of currently active operations.
std::vector<ProgressStatus> GetProgressStatusList(); ProgressStatusList GetProgressStatusList();
// Sets the observer. // Sets the observer.
void AddObserver(Observer* observer); void AddObserver(Observer* observer);
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chrome/browser/chromeos/gdata/gdata_file_system.h" #include "chrome/browser/chromeos/gdata/gdata_file_system.h"
#include "chrome/browser/chromeos/gdata/gdata_system_service.h" #include "chrome/browser/chromeos/gdata/gdata_system_service.h"
#include "chrome/browser/chromeos/login/user.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -236,6 +238,11 @@ void InsertGDataCachePathsPermissions( ...@@ -236,6 +238,11 @@ void InsertGDataCachePathsPermissions(
} }
bool IsGDataAvailable(Profile* profile) { bool IsGDataAvailable(Profile* profile) {
if (!chromeos::UserManager::Get()->IsUserLoggedIn() ||
chromeos::UserManager::Get()->IsLoggedInAsGuest() ||
chromeos::UserManager::Get()->IsLoggedInAsDemoUser())
return false;
// Do not allow GData for incognito windows / guest mode. // Do not allow GData for incognito windows / guest mode.
if (profile->IsOffTheRecord()) if (profile->IsOffTheRecord())
return false; return false;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "ash/system/bluetooth/bluetooth_observer.h" #include "ash/system/bluetooth/bluetooth_observer.h"
#include "ash/system/brightness/brightness_observer.h" #include "ash/system/brightness/brightness_observer.h"
#include "ash/system/date/clock_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/ime/ime_observer.h"
#include "ash/system/network/network_observer.h" #include "ash/system/network/network_observer.h"
#include "ash/system/power/power_status_observer.h" #include "ash/system/power/power_status_observer.h"
...@@ -21,6 +22,7 @@ ...@@ -21,6 +22,7 @@
#include "ash/system/user/user_observer.h" #include "ash/system/user/user_observer.h"
#include "base/chromeos/chromeos_version.h" #include "base/chromeos/chromeos_version.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/audio/audio_handler.h" #include "chrome/browser/chromeos/audio/audio_handler.h"
...@@ -28,6 +30,8 @@ ...@@ -28,6 +30,8 @@
#include "chrome/browser/chromeos/bluetooth/bluetooth_device.h" #include "chrome/browser/chromeos/bluetooth/bluetooth_device.h"
#include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h" #include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/gdata/gdata_system_service.h"
#include "chrome/browser/chromeos/gdata/gdata_util.h"
#include "chrome/browser/chromeos/input_method/input_method_manager.h" #include "chrome/browser/chromeos/input_method/input_method_manager.h"
#include "chrome/browser/chromeos/input_method/input_method_util.h" #include "chrome/browser/chromeos/input_method/input_method_util.h"
#include "chrome/browser/chromeos/input_method/input_method_whitelist.h" #include "chrome/browser/chromeos/input_method/input_method_whitelist.h"
...@@ -54,16 +58,26 @@ ...@@ -54,16 +58,26 @@
#include "chrome/common/url_constants.h" #include "chrome/common/url_constants.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/power_manager_client.h" #include "chromeos/dbus/power_manager_client.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_service.h" #include "content/public/browser/notification_service.h"
#include "content/public/browser/user_metrics.h" #include "content/public/browser/user_metrics.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
using gdata::GDataFileSystem;
using gdata::GDataOperationRegistry;
using gdata::GDataSystemService;
using gdata::GDataSystemServiceFactory;
namespace chromeos { namespace chromeos {
namespace { namespace {
// Time delay for rechecking gdata operation when we suspect that there will
// be no upcoming activity notifications that need to be pushed to UI.
const int kGDataOperationRecheckDelayMs = 5000;
bool ShouldShowNetworkIconInTray(const Network* network) { bool ShouldShowNetworkIconInTray(const Network* network) {
if (!network) if (!network)
return true; return true;
...@@ -90,6 +104,25 @@ void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, ...@@ -90,6 +104,25 @@ void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime,
info->short_name = util.GetInputMethodShortName(ime); info->short_name = util.GetInputMethodShortName(ime);
} }
ash::DriveOperationStatusList GetDriveStatusList(
const std::vector<GDataOperationRegistry::ProgressStatus>& list) {
ash::DriveOperationStatusList results;
for (GDataOperationRegistry::ProgressStatusList::const_iterator it =
list.begin();
it != list.end(); ++it) {
ash::DriveOperationStatus status;
status.file_path = it->file_path;
status.progress = it->progress_total == 0 ? 0.0 :
static_cast<double>(it->progress_current) /
static_cast<double>(it->progress_total);
status.type = static_cast<ash::DriveOperationStatus::OperationType>(
it->operation_type);
status.state = static_cast<ash::DriveOperationStatus::OperationState>(
it->transfer_state);
results.push_back(status);
}
return results;
}
void BluetoothPowerFailure() { void BluetoothPowerFailure() {
// TODO(sad): Show an error bubble? // TODO(sad): Show an error bubble?
...@@ -115,6 +148,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, ...@@ -115,6 +148,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
public NetworkLibrary::NetworkManagerObserver, public NetworkLibrary::NetworkManagerObserver,
public NetworkLibrary::NetworkObserver, public NetworkLibrary::NetworkObserver,
public NetworkLibrary::CellularDataPlanObserver, public NetworkLibrary::CellularDataPlanObserver,
public gdata::GDataOperationRegistry::Observer,
public content::NotificationObserver, public content::NotificationObserver,
public input_method::InputMethodManager::Observer, public input_method::InputMethodManager::Observer,
public system::TimezoneSettings::Observer, public system::TimezoneSettings::Observer,
...@@ -124,6 +158,8 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, ...@@ -124,6 +158,8 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
public: public:
explicit SystemTrayDelegate(ash::SystemTray* tray) explicit SystemTrayDelegate(ash::SystemTray* tray)
: tray_(tray), : tray_(tray),
ui_weak_ptr_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(
new base::WeakPtrFactory<SystemTrayDelegate>(this))),
network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST( network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST(
new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))), new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST( network_icon_dark_(ALLOW_THIS_IN_INITIALIZER_LIST(
...@@ -270,6 +306,10 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, ...@@ -270,6 +306,10 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
// TODO(sad): Make this work. // TODO(sad): Make this work.
} }
virtual void ShowDriveSettings() OVERRIDE {
// TODO(zelidrag): Show settings once we put them in.
}
virtual void ShowIMESettings() OVERRIDE { virtual void ShowIMESettings() OVERRIDE {
content::RecordAction( content::RecordAction(
content::UserMetricsAction("OpenLanguageOptionsDialog")); content::UserMetricsAction("OpenLanguageOptionsDialog"));
...@@ -404,6 +444,37 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, ...@@ -404,6 +444,37 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
ActivateInputMethodProperty(key); ActivateInputMethodProperty(key);
} }
virtual void CancelDriveOperation(const FilePath& file_path) OVERRIDE {
Profile* profile = ProfileManager::GetDefaultProfile();
if (!gdata::util::IsGDataAvailable(profile))
return;
GDataSystemService* system_service =
GDataSystemServiceFactory::FindForProfile(profile);
if (!system_service)
return;
system_service->file_system()->GetOperationRegistry()->CancelForFilePath(
file_path);
}
virtual void GetDriveOperationStatusList(
ash::DriveOperationStatusList* list) OVERRIDE {
Profile* profile = ProfileManager::GetDefaultProfile();
if (!gdata::util::IsGDataAvailable(profile))
return;
GDataSystemService* system_service =
GDataSystemServiceFactory::FindForProfile(profile);
if (!system_service)
return;
*list = GetDriveStatusList(
system_service->file_system()->GetOperationRegistry()->
GetProgressStatusList());
}
virtual void GetMostRelevantNetworkIcon(ash::NetworkIconInfo* info, virtual void GetMostRelevantNetworkIcon(ash::NetworkIconInfo* info,
bool dark) OVERRIDE { bool dark) OVERRIDE {
NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary(); NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
...@@ -655,6 +726,13 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, ...@@ -655,6 +726,13 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
UpdateClockType(profile->GetPrefs()); UpdateClockType(profile->GetPrefs());
search_key_mapped_to_ = search_key_mapped_to_ =
profile->GetPrefs()->GetInteger(prefs::kLanguageXkbRemapSearchKeyTo); profile->GetPrefs()->GetInteger(prefs::kLanguageXkbRemapSearchKeyTo);
if (gdata::util::IsGDataAvailable(profile)) {
GDataSystemService* system_service =
GDataSystemServiceFactory::FindForProfile(profile);
system_service->file_system()->GetOperationRegistry()->
AddObserver(this);
}
} }
void UpdateClockType(PrefService* service) { void UpdateClockType(PrefService* service) {
...@@ -695,6 +773,12 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, ...@@ -695,6 +773,12 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
observer->OnIMERefresh(); observer->OnIMERefresh();
} }
void NotifyRefreshDrive(ash::DriveOperationStatusList& list) {
ash::DriveObserver* observer = tray_->drive_observer();
if (observer)
observer->OnDriveRefresh(list);
}
void RefreshNetworkObserver(NetworkLibrary* crosnet) { void RefreshNetworkObserver(NetworkLibrary* crosnet) {
const Network* network = crosnet->active_network(); const Network* network = crosnet->active_network();
std::string new_path = network ? network->service_path() : std::string(); std::string new_path = network ? network->service_path() : std::string();
...@@ -872,6 +956,61 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, ...@@ -872,6 +956,61 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
NotifyRefreshIME(); NotifyRefreshIME();
} }
// gdata::GDataOperationRegistry::Observer overrides.
virtual void OnProgressUpdate(
const GDataOperationRegistry::ProgressStatusList& list) {
std::vector<ash::DriveOperationStatus> ui_list = GetDriveStatusList(list);
NotifyRefreshDrive(ui_list);
// If we have something to report right now (i.e. completion status only),
// we need to delayed re-check the status in few seconds to ensure we
// raise events that will let us properly clear the uber tray state.
if (list.size() > 0) {
bool has_in_progress_items = false;
for (GDataOperationRegistry::ProgressStatusList::const_iterator it =
list.begin();
it != list.end(); ++it) {
if (it->transfer_state ==
GDataOperationRegistry::OPERATION_STARTED ||
it->transfer_state ==
GDataOperationRegistry::OPERATION_IN_PROGRESS ||
it->transfer_state ==
GDataOperationRegistry::OPERATION_SUSPENDED) {
has_in_progress_items = true;
break;
}
}
if (!has_in_progress_items) {
content::BrowserThread::PostDelayedTask(
content::BrowserThread::UI,
FROM_HERE,
base::Bind(&SystemTrayDelegate::RecheckGDataOperations,
ui_weak_ptr_factory_->GetWeakPtr()),
base::TimeDelta::FromMilliseconds(kGDataOperationRecheckDelayMs));
}
}
}
// Pulls the list of ongoing drive operations and initiates status update.
// This method is needed to ensure delayed cleanup of the latest reported
// status in UI in cases when there are no new changes coming (i.e. when the
// last set of transfer operations completed).
void RecheckGDataOperations() {
Profile* profile = ProfileManager::GetDefaultProfile();
if (!gdata::util::IsGDataAvailable(profile))
return;
GDataSystemService* system_service =
GDataSystemServiceFactory::FindForProfile(profile);
if (!system_service)
return;
OnProgressUpdate(system_service->file_system()->GetOperationRegistry()->
GetProgressStatusList());
}
// Overridden from system::TimezoneSettings::Observer. // Overridden from system::TimezoneSettings::Observer.
virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE { virtual void TimezoneChanged(const icu::TimeZone& timezone) OVERRIDE {
NotifyRefreshClock(); NotifyRefreshClock();
...@@ -957,6 +1096,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, ...@@ -957,6 +1096,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
} }
ash::SystemTray* tray_; ash::SystemTray* tray_;
scoped_ptr<base::WeakPtrFactory<SystemTrayDelegate> > ui_weak_ptr_factory_;
scoped_ptr<NetworkMenuIcon> network_icon_; scoped_ptr<NetworkMenuIcon> network_icon_;
scoped_ptr<NetworkMenuIcon> network_icon_dark_; scoped_ptr<NetworkMenuIcon> network_icon_dark_;
scoped_ptr<NetworkMenu> network_menu_; scoped_ptr<NetworkMenu> network_menu_;
......
...@@ -293,6 +293,12 @@ ...@@ -293,6 +293,12 @@
<include name="IDR_AURA_UBER_TRAY_CAPS_LOCK" file="aura/status_capslock.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_CAPS_LOCK" file="aura/status_capslock.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK" file="aura/status_capslock_dark.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_CAPS_LOCK_DARK" file="aura/status_capslock_dark.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_BLUETOOTH" file="aura/status_bluetooth.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_BLUETOOTH" file="aura/status_bluetooth.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_DRIVE" file="aura/status_drive.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_DRIVE_FAILED" file="aura/status_drive_item_failed.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_DRIVE_DONE" file="aura/status_drive_item_done.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_DRIVE_CANCEL" file="aura/status_drive_item_cancel.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_DRIVE_CANCEL_HOVER" file="aura/status_drive_item_cancel_hover.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_DRIVE_LIGHT" file="aura/status_drive_light.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_IME" file="aura/status_ime.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_IME" file="aura/status_ime.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_UPDATE" file="aura/status_update.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_UPDATE" file="aura/status_update.png" type="BINDATA" />
<include name="IDR_AURA_UBER_TRAY_UPDATE_DARK" file="aura/status_update_dark.png" type="BINDATA" /> <include name="IDR_AURA_UBER_TRAY_UPDATE_DARK" file="aura/status_update_dark.png" type="BINDATA" />
......
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