summaryrefslogtreecommitdiff
path: root/chromium/ash/system
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ash/system')
-rw-r--r--chromium/ash/system/chromeos/network/network_connect.cc36
-rw-r--r--chromium/ash/system/chromeos/network/network_connect.h2
-rw-r--r--chromium/ash/system/chromeos/network/network_icon.cc5
-rw-r--r--chromium/ash/system/chromeos/network/network_state_notifier.cc8
-rw-r--r--chromium/ash/system/chromeos/network/network_state_notifier_unittest.cc5
-rw-r--r--chromium/ash/system/chromeos/network/sms_observer.h26
-rw-r--r--chromium/ash/system/chromeos/network/tray_sms.cc47
-rw-r--r--chromium/ash/system/chromeos/network/tray_sms.h11
-rw-r--r--chromium/ash/system/chromeos/settings/tray_settings.cc3
-rw-r--r--chromium/ash/system/logout_button/logout_button_tray.cc158
-rw-r--r--chromium/ash/system/logout_button/logout_button_tray.h62
-rw-r--r--chromium/ash/system/logout_button/tray_logout_button.cc168
-rw-r--r--chromium/ash/system/logout_button/tray_logout_button.h44
-rw-r--r--chromium/ash/system/status_area_widget.cc16
-rw-r--r--chromium/ash/system/status_area_widget.h5
-rw-r--r--chromium/ash/system/tray/system_tray.cc2
-rw-r--r--chromium/ash/system/tray/system_tray.h1
-rw-r--r--chromium/ash/system/tray/system_tray_delegate.h13
-rw-r--r--chromium/ash/system/tray/system_tray_notifier.cc13
-rw-r--r--chromium/ash/system/tray/system_tray_notifier.h7
-rw-r--r--chromium/ash/system/tray/test_system_tray_delegate.cc13
-rw-r--r--chromium/ash/system/tray/test_system_tray_delegate.h5
-rw-r--r--chromium/ash/system/tray/tray_background_view.h3
-rw-r--r--chromium/ash/system/tray/tray_constants.cc9
-rw-r--r--chromium/ash/system/tray/tray_constants.h4
-rw-r--r--chromium/ash/system/tray/tray_image_item.cc22
-rw-r--r--chromium/ash/system/tray/tray_image_item.h3
-rw-r--r--chromium/ash/system/user/tray_user.cc29
-rw-r--r--chromium/ash/system/web_notification/web_notification_tray.cc75
-rw-r--r--chromium/ash/system/web_notification/web_notification_tray.h1
-rw-r--r--chromium/ash/system/web_notification/web_notification_tray_unittest.cc119
31 files changed, 409 insertions, 506 deletions
diff --git a/chromium/ash/system/chromeos/network/network_connect.cc b/chromium/ash/system/chromeos/network/network_connect.cc
index 3aca1622223..d733a01fa64 100644
--- a/chromium/ash/system/chromeos/network/network_connect.cc
+++ b/chromium/ash/system/chromeos/network/network_connect.cc
@@ -66,7 +66,8 @@ void OnConnectFailed(const std::string& service_path,
if (error_name == NetworkConnectionHandler::kErrorConnectCanceled)
return;
- if (error_name == NetworkConnectionHandler::kErrorPassphraseRequired ||
+ if (error_name == flimflam::kErrorBadPassphrase ||
+ error_name == NetworkConnectionHandler::kErrorPassphraseRequired ||
error_name == NetworkConnectionHandler::kErrorConfigurationRequired ||
error_name == NetworkConnectionHandler::kErrorAuthenticationRequired) {
ash::Shell::GetInstance()->system_tray_delegate()->ConfigureNetwork(
@@ -96,7 +97,7 @@ void OnConnectFailed(const std::string& service_path,
ShowErrorNotification(error_name, service_path);
// Show a configure dialog for ConnectFailed errors.
- if (error_name != NetworkConnectionHandler::kErrorConnectFailed)
+ if (error_name != flimflam::kErrorConnectFailed)
return;
// If Shill reports an InProgress error, don't try to configure the network.
@@ -137,11 +138,10 @@ void CallConnectToNetwork(const std::string& service_path,
}
void OnActivateFailed(const std::string& service_path,
- const std::string& error_name,
+ const std::string& error_name,
scoped_ptr<base::DictionaryValue> error_data) {
NET_LOG_ERROR("Unable to activate network", service_path);
- ShowErrorNotification(
- NetworkConnectionHandler::kErrorActivateFailed, service_path);
+ ShowErrorNotification(network_connect::kErrorActivateFailed, service_path);
}
void OnActivateSucceeded(const std::string& service_path) {
@@ -246,6 +246,8 @@ void ConfigureSetProfileSucceeded(
namespace network_connect {
+const char kErrorActivateFailed[] = "activate-failed";
+
void ConnectToNetwork(const std::string& service_path,
gfx::NativeWindow owning_window) {
const bool check_error_state = true;
@@ -254,25 +256,27 @@ void ConnectToNetwork(const std::string& service_path,
void ActivateCellular(const std::string& service_path) {
NET_LOG_USER("ActivateCellular", service_path);
+ const NetworkState* cellular =
+ NetworkHandler::Get()->network_state_handler()->
+ GetNetworkState(service_path);
+ if (!cellular || cellular->type() != flimflam::kTypeCellular) {
+ NET_LOG_ERROR("ActivateCellular with no Service", service_path);
+ return;
+ }
const DeviceState* cellular_device =
NetworkHandler::Get()->network_state_handler()->
- GetDeviceStateByType(flimflam::kTypeCellular);
+ GetDeviceState(cellular->device_path());
if (!cellular_device) {
NET_LOG_ERROR("ActivateCellular with no Device", service_path);
return;
}
if (!IsDirectActivatedCarrier(cellular_device->carrier())) {
// For non direct activation, show the mobile setup dialog which can be
- // used to activate the network.
- ash::Shell::GetInstance()->system_tray_delegate()->ShowMobileSetup(
- service_path);
- return;
- }
- const NetworkState* cellular =
- NetworkHandler::Get()->network_state_handler()->
- GetNetworkState(service_path);
- if (!cellular || cellular->type() != flimflam::kTypeCellular) {
- NET_LOG_ERROR("ActivateCellular with no Service", service_path);
+ // used to activate the network. Only show the dialog, if an account
+ // management URL is available.
+ if (!cellular->payment_url().empty())
+ ash::Shell::GetInstance()->system_tray_delegate()->ShowMobileSetup(
+ service_path);
return;
}
if (cellular->activation_state() == flimflam::kActivationStateActivated) {
diff --git a/chromium/ash/system/chromeos/network/network_connect.h b/chromium/ash/system/chromeos/network/network_connect.h
index 65c430d073e..06656ce0548 100644
--- a/chromium/ash/system/chromeos/network/network_connect.h
+++ b/chromium/ash/system/chromeos/network/network_connect.h
@@ -18,6 +18,8 @@ class DictionaryValue;
namespace ash {
namespace network_connect {
+ASH_EXPORT extern const char kErrorActivateFailed[];
+
// Requests a network connection and handles any errors and notifications.
// |owning_window| is used to parent any UI on failure (e.g. for certificate
// enrollment). If NULL, the default window will be used.
diff --git a/chromium/ash/system/chromeos/network/network_icon.cc b/chromium/ash/system/chromeos/network/network_icon.cc
index efe7e07afc4..bd32a9f8b16 100644
--- a/chromium/ash/system/chromeos/network/network_icon.cc
+++ b/chromium/ash/system/chromeos/network/network_icon.cc
@@ -620,8 +620,9 @@ void NetworkIconImpl::GetBadges(const NetworkState* network, Badges* badges) {
// For networks that are always in roaming don't show roaming badge.
const DeviceState* device =
handler->GetDeviceState(network->device_path());
- DCHECK(device);
- if (!device->provider_requires_roaming()) {
+ LOG_IF(WARNING, !device) << "Could not find device state for "
+ << network->device_path();
+ if (!device || !device->provider_requires_roaming()) {
badges->bottom_right = rb.GetImageSkiaNamed(
IconTypeIsDark(icon_type_) ?
IDR_AURA_UBER_TRAY_NETWORK_ROAMING_DARK :
diff --git a/chromium/ash/system/chromeos/network/network_state_notifier.cc b/chromium/ash/system/chromeos/network/network_state_notifier.cc
index 1c971a32a44..47940d5f746 100644
--- a/chromium/ash/system/chromeos/network/network_state_notifier.cc
+++ b/chromium/ash/system/chromeos/network/network_state_notifier.cc
@@ -35,7 +35,7 @@ string16 GetConnectErrorString(const std::string& error_name) {
if (error_name == NetworkConnectionHandler::kErrorConfigureFailed)
return l10n_util::GetStringUTF16(
IDS_CHROMEOS_NETWORK_ERROR_CONFIGURE_FAILED);
- if (error_name == NetworkConnectionHandler::kErrorActivateFailed)
+ if (error_name == ash::network_connect::kErrorActivateFailed)
return l10n_util::GetStringUTF16(
IDS_CHROMEOS_NETWORK_ERROR_ACTIVATION_FAILED);
return string16();
@@ -71,7 +71,7 @@ void NetworkStateNotifier::NetworkListChanged() {
// case a connect attempt fails because a network is no longer visible.
if (!connect_failed_network_.empty()) {
ShowNetworkConnectError(
- NetworkConnectionHandler::kErrorConnectFailed, connect_failed_network_);
+ flimflam::kErrorConnectFailed, connect_failed_network_);
}
}
@@ -92,7 +92,7 @@ void NetworkStateNotifier::NetworkPropertiesUpdated(
// property has been set.
if (network->path() == connect_failed_network_ && !network->error().empty()) {
ShowNetworkConnectError(
- NetworkConnectionHandler::kErrorConnectFailed, connect_failed_network_);
+ flimflam::kErrorConnectFailed, connect_failed_network_);
}
// Trigger "Out of credits" notification if the cellular network is the most
// recent default network (i.e. we have not switched to another network).
@@ -141,7 +141,7 @@ void NetworkStateNotifier::ShowNetworkConnectError(
const std::string& service_path) {
const NetworkState* network = NetworkHandler::Get()->network_state_handler()->
GetNetworkState(service_path);
- if (error_name == NetworkConnectionHandler::kErrorConnectFailed &&
+ if (error_name == flimflam::kErrorConnectFailed &&
service_path != connect_failed_network_) {
// Shill may not have set the Error property yet. First request an update
// and wait for either the update to complete or the network list to be
diff --git a/chromium/ash/system/chromeos/network/network_state_notifier_unittest.cc b/chromium/ash/system/chromeos/network/network_state_notifier_unittest.cc
index d8d036ad653..6e2069deb65 100644
--- a/chromium/ash/system/chromeos/network/network_state_notifier_unittest.cc
+++ b/chromium/ash/system/chromeos/network/network_state_notifier_unittest.cc
@@ -14,6 +14,7 @@
#include "chromeos/dbus/dbus_thread_manager.h"
#include "chromeos/dbus/shill_device_client.h"
#include "chromeos/dbus/shill_service_client.h"
+#include "chromeos/network/network_connection_handler.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
namespace {
@@ -26,6 +27,8 @@ ash::SystemTray* GetSystemTray() {
} // namespace
using chromeos::DBusThreadManager;
+using chromeos::NetworkHandler;
+using chromeos::NetworkConnectionHandler;
using chromeos::ShillDeviceClient;
using chromeos::ShillServiceClient;
@@ -40,12 +43,14 @@ class NetworkStateNotifierTest : public AshTestBase {
virtual void SetUp() OVERRIDE {
DBusThreadManager::InitializeWithStub();
SetupDefaultShillState();
+ NetworkHandler::Initialize();
RunAllPendingInMessageLoop();
AshTestBase::SetUp();
}
virtual void TearDown() OVERRIDE {
AshTestBase::TearDown();
+ NetworkHandler::Shutdown();
DBusThreadManager::Shutdown();
}
diff --git a/chromium/ash/system/chromeos/network/sms_observer.h b/chromium/ash/system/chromeos/network/sms_observer.h
new file mode 100644
index 00000000000..bc5496780d1
--- /dev/null
+++ b/chromium/ash/system/chromeos/network/sms_observer.h
@@ -0,0 +1,26 @@
+// 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_CHROMEOS_NETWORK_SMS_OBSERVER_H
+#define ASH_SYSTEM_CHROMEOS_NETWORK_SMS_OBSERVER_H
+
+namespace base {
+class DictionaryValue;
+}
+
+namespace ash {
+
+const char kSmsNumberKey[] = "number";
+const char kSmsTextKey[] = "text";
+
+class SmsObserver {
+ public:
+ virtual ~SmsObserver() {}
+
+ virtual void AddMessage(const base::DictionaryValue& message) = 0;
+};
+
+} // namespace ash
+
+#endif // ASH_SYSTEM_CHROMEOS_NETWORK_SMS_OBSERVER_H
diff --git a/chromium/ash/system/chromeos/network/tray_sms.cc b/chromium/ash/system/chromeos/network/tray_sms.cc
index 008129faa5f..982a5643181 100644
--- a/chromium/ash/system/chromeos/network/tray_sms.cc
+++ b/chromium/ash/system/chromeos/network/tray_sms.cc
@@ -16,8 +16,6 @@
#include "ash/system/tray/tray_notification_view.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
-#include "chromeos/network/network_event_log.h"
-#include "chromeos/network/network_handler.h"
#include "grit/ash_resources.h"
#include "grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
@@ -37,15 +35,12 @@ const int kMessageListMinHeight = 200;
// Top/bottom padding of the text items.
const int kPaddingVertical = 10;
-const char kSmsNumberKey[] = "number";
-const char kSmsTextKey[] = "text";
-
bool GetMessageFromDictionary(const base::DictionaryValue* message,
std::string* number,
std::string* text) {
- if (!message->GetStringWithoutPathExpansion(kSmsNumberKey, number))
+ if (!message->GetStringWithoutPathExpansion(ash::kSmsNumberKey, number))
return false;
- if (!message->GetStringWithoutPathExpansion(kSmsTextKey, text))
+ if (!message->GetStringWithoutPathExpansion(ash::kSmsTextKey, text))
return false;
return true;
}
@@ -286,14 +281,11 @@ TraySms::TraySms(SystemTray* system_tray)
default_(NULL),
detailed_(NULL),
notification_(NULL) {
- // TODO(armansito): SMS could be a special case for cellular that requires a
- // user (perhaps the owner) to be logged in. If that is the case, then an
- // additional check should be done before subscribing for SMS notifications.
- chromeos::NetworkHandler::Get()->network_sms_handler()->AddObserver(this);
+ Shell::GetInstance()->system_tray_notifier()->AddSmsObserver(this);
}
TraySms::~TraySms() {
- chromeos::NetworkHandler::Get()->network_sms_handler()->RemoveObserver(this);
+ Shell::GetInstance()->system_tray_notifier()->RemoveSmsObserver(this);
}
views::View* TraySms::CreateDefaultView(user::LoginStatus status) {
@@ -335,35 +327,8 @@ void TraySms::DestroyNotificationView() {
notification_ = NULL;
}
-void TraySms::MessageReceived(const base::DictionaryValue& message) {
-
- std::string message_text;
- if (!message.GetStringWithoutPathExpansion(
- chromeos::NetworkSmsHandler::kTextKey, &message_text)) {
- NET_LOG_ERROR("SMS message contains no content.", "");
- return;
- }
- // TODO(armansito): A message might be due to a special "Message Waiting"
- // state that the message is in. Once SMS handling moves to shill, such
- // messages should be filtered there so that this check becomes unnecessary.
- if (message_text.empty()) {
- NET_LOG_DEBUG("SMS has empty content text. Ignoring.", "");
- return;
- }
- std::string message_number;
- if (!message.GetStringWithoutPathExpansion(
- chromeos::NetworkSmsHandler::kNumberKey, &message_number)) {
- NET_LOG_DEBUG("SMS contains no number. Ignoring.", "");
- return;
- }
-
- NET_LOG_DEBUG("Received SMS from: " + message_number + " with text: " +
- message_text, "");
-
- base::DictionaryValue* dict = new base::DictionaryValue();
- dict->SetString(kSmsNumberKey, message_number);
- dict->SetString(kSmsTextKey, message_text);
- messages_.Append(dict);
+void TraySms::AddMessage(const base::DictionaryValue& message) {
+ messages_.Append(message.DeepCopy());
Update(true);
}
diff --git a/chromium/ash/system/chromeos/network/tray_sms.h b/chromium/ash/system/chromeos/network/tray_sms.h
index 5a79360052a..7fc334b7ebd 100644
--- a/chromium/ash/system/chromeos/network/tray_sms.h
+++ b/chromium/ash/system/chromeos/network/tray_sms.h
@@ -7,15 +7,15 @@
#include <string>
+#include "ash/system/chromeos/network/sms_observer.h"
#include "ash/system/tray/system_tray_item.h"
#include "base/values.h"
-#include "chromeos/network/network_sms_handler.h"
namespace ash {
namespace internal {
class TraySms : public SystemTrayItem,
- public chromeos::NetworkSmsHandler::Observer {
+ public SmsObserver {
public:
explicit TraySms(SystemTray* system_tray);
virtual ~TraySms();
@@ -29,8 +29,8 @@ class TraySms : public SystemTrayItem,
virtual void DestroyDetailedView() OVERRIDE;
virtual void DestroyNotificationView() OVERRIDE;
- // Overridden from chromeos::NetworkSmsHandler::Observer.
- virtual void MessageReceived(const base::DictionaryValue& message) OVERRIDE;
+ // Overridden from SmsObserver.
+ virtual void AddMessage(const base::DictionaryValue& message) OVERRIDE;
protected:
class SmsDefaultView;
@@ -45,8 +45,7 @@ class TraySms : public SystemTrayItem,
// Removes message at |index| from message list.
void RemoveMessage(size_t index);
- // Called when sms messages have changed (through
- // chromeos::NetworkSmsHandler::Observer).
+ // Called when sms messages have changed (by tray::SmsObserver).
void Update(bool notify);
base::ListValue& messages() { return messages_; }
diff --git a/chromium/ash/system/chromeos/settings/tray_settings.cc b/chromium/ash/system/chromeos/settings/tray_settings.cc
index 8153aeae81e..8868b7cf50d 100644
--- a/chromium/ash/system/chromeos/settings/tray_settings.cc
+++ b/chromium/ash/system/chromeos/settings/tray_settings.cc
@@ -142,6 +142,9 @@ views::View* TraySettings::CreateDefaultView(user::LoginStatus status) {
!PowerStatus::Get()->IsBatteryPresent())
return NULL;
+ if (!ash::Shell::GetInstance()->system_tray_delegate()->ShouldShowSettings())
+ return NULL;
+
CHECK(default_view_ == NULL);
default_view_ = new tray::SettingsDefaultView(status);
return default_view_;
diff --git a/chromium/ash/system/logout_button/logout_button_tray.cc b/chromium/ash/system/logout_button/logout_button_tray.cc
deleted file mode 100644
index f62921f1a08..00000000000
--- a/chromium/ash/system/logout_button/logout_button_tray.cc
+++ /dev/null
@@ -1,158 +0,0 @@
-// Copyright 2013 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/logout_button/logout_button_tray.h"
-
-#include "ash/shelf/shelf_types.h"
-#include "ash/shell.h"
-#include "ash/system/status_area_widget.h"
-#include "ash/system/tray/system_tray_delegate.h"
-#include "ash/system/tray/system_tray_notifier.h"
-#include "ash/system/tray/tray_constants.h"
-#include "ash/system/tray/tray_utils.h"
-#include "base/logging.h"
-#include "grit/ash_resources.h"
-#include "third_party/skia/include/core/SkColor.h"
-#include "ui/base/events/event.h"
-#include "ui/gfx/font.h"
-#include "ui/gfx/insets.h"
-#include "ui/gfx/size.h"
-#include "ui/views/bubble/tray_bubble_view.h"
-#include "ui/views/controls/button/label_button.h"
-#include "ui/views/controls/button/label_button_border.h"
-#include "ui/views/painter.h"
-
-namespace ash {
-
-namespace internal {
-
-namespace {
-
-const int kLogoutButtonHorizontalExtraPadding = 7;
-
-const int kLogoutButtonNormalImages[] = {
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_TOP_LEFT,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_TOP,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_TOP_RIGHT,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_LEFT,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_CENTER,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_RIGHT,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_BOTTOM_LEFT,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_BOTTOM,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_BOTTOM_RIGHT
-};
-
-const int kLogoutButtonPushedImages[] = {
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_TOP_LEFT,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_TOP,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_TOP_RIGHT,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_LEFT,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_CENTER,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_RIGHT,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_BOTTOM_LEFT,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_BOTTOM,
- IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_BOTTOM_RIGHT
-};
-
-class LogoutButton : public views::LabelButton {
- public:
- LogoutButton(views::ButtonListener* listener);
- virtual ~LogoutButton();
-
- private:
- DISALLOW_COPY_AND_ASSIGN(LogoutButton);
-};
-
-} // namespace
-
-LogoutButton::LogoutButton(views::ButtonListener* listener)
- : views::LabelButton(listener, base::string16()) {
- SetupLabelForTray(label());
- SetFont(GetFont().DeriveFont(0, gfx::Font::NORMAL));
- for (size_t state = 0; state < views::Button::STATE_COUNT; ++state)
- SetTextColor(static_cast<views::Button::ButtonState>(state), SK_ColorWHITE);
-
- views::LabelButtonBorder* border =
- new views::LabelButtonBorder(views::Button::STYLE_TEXTBUTTON);
- border->SetPainter(false, views::Button::STATE_NORMAL,
- views::Painter::CreateImageGridPainter(kLogoutButtonNormalImages));
- border->SetPainter(false, views::Button::STATE_HOVERED,
- views::Painter::CreateImageGridPainter(kLogoutButtonNormalImages));
- border->SetPainter(false, views::Button::STATE_PRESSED,
- views::Painter::CreateImageGridPainter(kLogoutButtonPushedImages));
- gfx::Insets insets = border->GetInsets();
- insets += gfx::Insets(0, kLogoutButtonHorizontalExtraPadding,
- 0, kLogoutButtonHorizontalExtraPadding);
- border->set_insets(insets);
- set_border(border);
- set_animate_on_state_change(false);
-
- set_min_size(gfx::Size(0, GetShelfItemHeight()));
-}
-
-LogoutButton::~LogoutButton() {
-}
-
-LogoutButtonTray::LogoutButtonTray(StatusAreaWidget* status_area_widget)
- : TrayBackgroundView(status_area_widget),
- button_(NULL),
- login_status_(user::LOGGED_IN_NONE),
- show_logout_button_in_tray_(false) {
- button_ = new LogoutButton(this);
- tray_container()->AddChildView(button_);
- tray_container()->set_border(NULL);
- Shell::GetInstance()->system_tray_notifier()->AddLogoutButtonObserver(this);
-}
-
-LogoutButtonTray::~LogoutButtonTray() {
- Shell::GetInstance()->system_tray_notifier()->
- RemoveLogoutButtonObserver(this);
-}
-
-void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) {
- TrayBackgroundView::SetShelfAlignment(alignment);
- tray_container()->set_border(NULL);
-}
-
-base::string16 LogoutButtonTray::GetAccessibleNameForTray() {
- return button_->GetText();
-}
-
-void LogoutButtonTray::HideBubbleWithView(
- const views::TrayBubbleView* bubble_view) {
-}
-
-bool LogoutButtonTray::ClickedOutsideBubble() {
- return false;
-}
-
-void LogoutButtonTray::OnShowLogoutButtonInTrayChanged(bool show) {
- show_logout_button_in_tray_ = show;
- UpdateVisibility();
-}
-
-void LogoutButtonTray::ButtonPressed(views::Button* sender,
- const ui::Event& event) {
- DCHECK_EQ(sender, button_);
- Shell::GetInstance()->system_tray_delegate()->SignOut();
-}
-
-void LogoutButtonTray::UpdateAfterLoginStatusChange(
- user::LoginStatus login_status) {
- login_status_ = login_status;
- const base::string16 title =
- GetLocalizedSignOutStringForStatus(login_status, false);
- button_->SetText(title);
- button_->SetAccessibleName(title);
- UpdateVisibility();
-}
-
-void LogoutButtonTray::UpdateVisibility() {
- SetVisible(show_logout_button_in_tray_ &&
- login_status_ != user::LOGGED_IN_NONE &&
- login_status_ != user::LOGGED_IN_LOCKED);
-}
-
-} // namespace internal
-} // namespace ash
diff --git a/chromium/ash/system/logout_button/logout_button_tray.h b/chromium/ash/system/logout_button/logout_button_tray.h
deleted file mode 100644
index 5683e5e2654..00000000000
--- a/chromium/ash/system/logout_button/logout_button_tray.h
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2013 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_LOGOUT_BUTTON_LOGOUT_BUTTON_TRAY_H_
-#define ASH_SYSTEM_LOGOUT_BUTTON_LOGOUT_BUTTON_TRAY_H_
-
-#include "ash/system/logout_button/logout_button_observer.h"
-#include "ash/system/tray/tray_background_view.h"
-#include "ash/system/user/login_status.h"
-#include "base/basictypes.h"
-#include "base/compiler_specific.h"
-#include "ui/views/controls/button/button.h"
-
-namespace views {
-class LabelButton;
-}
-
-namespace ash {
-namespace internal {
-
-class StatusAreaWidget;
-
-// Adds a logout button to the launcher's status area if enabled by the
-// kShowLogoutButtonInTray pref.
-class LogoutButtonTray : public TrayBackgroundView,
- public LogoutButtonObserver,
- public views::ButtonListener {
- public:
- explicit LogoutButtonTray(StatusAreaWidget* status_area_widget);
- virtual ~LogoutButtonTray();
-
- // TrayBackgroundView:
- virtual void SetShelfAlignment(ShelfAlignment alignment) OVERRIDE;
- virtual base::string16 GetAccessibleNameForTray() OVERRIDE;
- virtual void HideBubbleWithView(
- const views::TrayBubbleView* bubble_view) OVERRIDE;
- virtual bool ClickedOutsideBubble() OVERRIDE;
-
- // LogoutButtonObserver:
- virtual void OnShowLogoutButtonInTrayChanged(bool show) OVERRIDE;
-
- // views::ButtonListener:
- virtual void ButtonPressed(views::Button* sender,
- const ui::Event& event) OVERRIDE;
-
- void UpdateAfterLoginStatusChange(user::LoginStatus login_status);
-
- private:
- void UpdateVisibility();
-
- views::LabelButton* button_; // Not owned.
- user::LoginStatus login_status_;
- bool show_logout_button_in_tray_;
-
- DISALLOW_COPY_AND_ASSIGN(LogoutButtonTray);
-};
-
-} // namespace internal
-} // namespace ash
-
-#endif // ASH_SYSTEM_LOGOUT_BUTTON_LOGOUT_BUTTON_TRAY_H_
diff --git a/chromium/ash/system/logout_button/tray_logout_button.cc b/chromium/ash/system/logout_button/tray_logout_button.cc
new file mode 100644
index 00000000000..102329c9a22
--- /dev/null
+++ b/chromium/ash/system/logout_button/tray_logout_button.cc
@@ -0,0 +1,168 @@
+// 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/logout_button/tray_logout_button.h"
+
+#include <cstddef>
+
+#include "ash/shell.h"
+#include "ash/system/tray/system_tray_delegate.h"
+#include "ash/system/tray/system_tray_notifier.h"
+#include "ash/system/tray/tray_constants.h"
+#include "ash/system/user/login_status.h"
+#include "base/logging.h"
+#include "base/strings/string16.h"
+#include "grit/ash_resources.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/views/border.h"
+#include "ui/views/controls/button/button.h"
+#include "ui/views/controls/button/custom_button.h"
+#include "ui/views/controls/button/label_button.h"
+#include "ui/views/controls/button/label_button_border.h"
+#include "ui/views/layout/box_layout.h"
+#include "ui/views/view.h"
+
+namespace {
+
+const int kLogoutButtonNormalImages[] = {
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_TOP_LEFT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_TOP,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_TOP_RIGHT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_LEFT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_CENTER,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_RIGHT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_BOTTOM_LEFT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_BOTTOM,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_NORMAL_BOTTOM_RIGHT
+};
+const int kLogoutButtonHotImages[] = {
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_HOT_TOP_LEFT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_HOT_TOP,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_HOT_TOP_RIGHT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_HOT_LEFT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_HOT_CENTER,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_HOT_RIGHT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_HOT_BOTTOM_LEFT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_HOT_BOTTOM,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_HOT_BOTTOM_RIGHT
+};
+const int kLogoutButtonPushedImages[] = {
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_TOP_LEFT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_TOP,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_TOP_RIGHT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_LEFT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_CENTER,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_RIGHT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_BOTTOM_LEFT,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_BOTTOM,
+ IDR_AURA_UBER_TRAY_LOGOUT_BUTTON_PUSHED_BOTTOM_RIGHT
+};
+
+} // namespace
+
+namespace ash {
+namespace internal {
+
+namespace tray {
+
+class LogoutButton : public views::View,
+ public views::ButtonListener {
+ public:
+ LogoutButton(user::LoginStatus status) : button_(NULL),
+ login_status_(user::LOGGED_IN_NONE),
+ show_logout_button_in_tray_(false) {
+ views::BoxLayout* layout = new views::BoxLayout(
+ views::BoxLayout::kHorizontal, 0, 0, 0);
+ layout->set_spread_blank_space(true);
+ SetLayoutManager(layout);
+ set_border(views::Border::CreateEmptyBorder(
+ 0, kTrayLabelItemHorizontalPaddingBottomAlignment, 0, 0));
+
+ button_ = new views::LabelButton(this, base::string16());
+ for (size_t state = 0; state < views::Button::STATE_COUNT; ++state) {
+ button_->SetTextColor(
+ static_cast<views::Button::ButtonState>(state), SK_ColorWHITE);
+ }
+ button_->SetFont(button_->GetFont().DeriveFont(1));
+ views::LabelButtonBorder* border =
+ new views::LabelButtonBorder(views::Button::STYLE_TEXTBUTTON);
+ border->SetPainter(false, views::Button::STATE_NORMAL,
+ views::Painter::CreateImageGridPainter(kLogoutButtonNormalImages));
+ border->SetPainter(false, views::Button::STATE_HOVERED,
+ views::Painter::CreateImageGridPainter(kLogoutButtonHotImages));
+ border->SetPainter(false, views::Button::STATE_PRESSED,
+ views::Painter::CreateImageGridPainter(kLogoutButtonPushedImages));
+ button_->set_border(border);
+ AddChildView(button_);
+ OnLoginStatusChanged(status);
+ }
+
+ void OnLoginStatusChanged(user::LoginStatus status) {
+ login_status_ = status;
+ const base::string16 title = GetLocalizedSignOutStringForStatus(
+ login_status_, false);
+ button_->SetText(title);
+ button_->SetAccessibleName(title);
+ UpdateVisibility();
+ }
+
+ void OnShowLogoutButtonInTrayChanged(bool show) {
+ show_logout_button_in_tray_ = show;
+ UpdateVisibility();
+ }
+
+ // Overridden from views::ButtonListener.
+ virtual void ButtonPressed(views::Button* sender,
+ const ui::Event& event) OVERRIDE {
+ DCHECK_EQ(sender, button_);
+ Shell::GetInstance()->system_tray_delegate()->SignOut();
+ }
+
+ private:
+ void UpdateVisibility() {
+ SetVisible(show_logout_button_in_tray_ &&
+ login_status_ != user::LOGGED_IN_NONE &&
+ login_status_ != user::LOGGED_IN_LOCKED);
+ }
+
+ views::LabelButton* button_;
+ user::LoginStatus login_status_;
+ bool show_logout_button_in_tray_;
+
+ DISALLOW_COPY_AND_ASSIGN(LogoutButton);
+};
+
+} // namespace tray
+
+TrayLogoutButton::TrayLogoutButton(SystemTray* system_tray)
+ : SystemTrayItem(system_tray),
+ logout_button_(NULL) {
+ Shell::GetInstance()->system_tray_notifier()->AddLogoutButtonObserver(this);
+}
+
+TrayLogoutButton::~TrayLogoutButton() {
+ Shell::GetInstance()->system_tray_notifier()->
+ RemoveLogoutButtonObserver(this);
+}
+
+views::View* TrayLogoutButton::CreateTrayView(user::LoginStatus status) {
+ CHECK(logout_button_ == NULL);
+ logout_button_ = new tray::LogoutButton(status);
+ return logout_button_;
+}
+
+void TrayLogoutButton::DestroyTrayView() {
+ logout_button_ = NULL;
+}
+
+void TrayLogoutButton::UpdateAfterLoginStatusChange(user::LoginStatus status) {
+ logout_button_->OnLoginStatusChanged(status);
+}
+
+void TrayLogoutButton::OnShowLogoutButtonInTrayChanged(bool show) {
+ logout_button_->OnShowLogoutButtonInTrayChanged(show);
+}
+
+} // namespace internal
+} // namespace ash
diff --git a/chromium/ash/system/logout_button/tray_logout_button.h b/chromium/ash/system/logout_button/tray_logout_button.h
new file mode 100644
index 00000000000..50ca9f9c2c1
--- /dev/null
+++ b/chromium/ash/system/logout_button/tray_logout_button.h
@@ -0,0 +1,44 @@
+// 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_LOGOUT_BUTTON_TRAY_LOGOUT_BUTTON_H_
+#define ASH_SYSTEM_LOGOUT_BUTTON_TRAY_LOGOUT_BUTTON_H_
+
+#include "ash/system/logout_button/logout_button_observer.h"
+#include "ash/system/tray/system_tray_item.h"
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+
+namespace ash {
+namespace internal {
+
+namespace tray {
+class LogoutButton;
+}
+
+// Adds a logout button to the system tray if enabled by the
+// kShowLogoutButtonInTray pref.
+class TrayLogoutButton : public SystemTrayItem, public LogoutButtonObserver {
+ public:
+ explicit TrayLogoutButton(SystemTray* system_tray);
+ virtual ~TrayLogoutButton();
+
+ // Overridden from SystemTrayItem.
+ virtual views::View* CreateTrayView(user::LoginStatus status) OVERRIDE;
+ virtual void DestroyTrayView() OVERRIDE;
+ virtual void UpdateAfterLoginStatusChange(user::LoginStatus status) OVERRIDE;
+
+ // Overridden from LogoutButtonObserver.
+ virtual void OnShowLogoutButtonInTrayChanged(bool show) OVERRIDE;
+
+ private:
+ tray::LogoutButton* logout_button_;
+
+ DISALLOW_COPY_AND_ASSIGN(TrayLogoutButton);
+};
+
+} // namespace internal
+} // namespace ash
+
+#endif // ASH_SYSTEM_LOGOUT_BUTTON_TRAY_LOGOUT_BUTTON_H_
diff --git a/chromium/ash/system/status_area_widget.cc b/chromium/ash/system/status_area_widget.cc
index ed31ba286fd..147251c6f52 100644
--- a/chromium/ash/system/status_area_widget.cc
+++ b/chromium/ash/system/status_area_widget.cc
@@ -11,7 +11,6 @@
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
#include "ash/system/bluetooth/bluetooth_observer.h"
-#include "ash/system/logout_button/logout_button_tray.h"
#include "ash/system/status_area_widget_delegate.h"
#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/system_tray_delegate.h"
@@ -31,7 +30,6 @@ StatusAreaWidget::StatusAreaWidget(aura::Window* status_container)
: status_area_widget_delegate_(new internal::StatusAreaWidgetDelegate),
system_tray_(NULL),
web_notification_tray_(NULL),
- logout_button_tray_(NULL),
login_status_(user::LOGGED_IN_NONE) {
views::Widget::InitParams params(
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
@@ -50,7 +48,6 @@ StatusAreaWidget::~StatusAreaWidget() {
void StatusAreaWidget::CreateTrayViews() {
AddSystemTray();
AddWebNotificationTray();
- AddLogoutButtonTray();
SystemTrayDelegate* delegate =
ash::Shell::GetInstance()->system_tray_delegate();
DCHECK(delegate);
@@ -59,8 +56,6 @@ void StatusAreaWidget::CreateTrayViews() {
system_tray_->InitializeTrayItems(delegate);
if (web_notification_tray_)
web_notification_tray_->Initialize();
- if (logout_button_tray_)
- logout_button_tray_->Initialize();
UpdateAfterLoginStatusChange(delegate->GetUserLoginStatus());
}
@@ -68,8 +63,6 @@ void StatusAreaWidget::Shutdown() {
// Destroy the trays early, causing them to be removed from the view
// hierarchy. Do not used scoped pointers since we don't want to destroy them
// in the destructor if Shutdown() is not called (e.g. in tests).
- delete logout_button_tray_;
- logout_button_tray_ = NULL;
delete web_notification_tray_;
web_notification_tray_ = NULL;
delete system_tray_;
@@ -114,19 +107,12 @@ void StatusAreaWidget::AddWebNotificationTray() {
status_area_widget_delegate_->AddTray(web_notification_tray_);
}
-void StatusAreaWidget::AddLogoutButtonTray() {
- logout_button_tray_ = new LogoutButtonTray(this);
- status_area_widget_delegate_->AddTray(logout_button_tray_);
-}
-
void StatusAreaWidget::SetShelfAlignment(ShelfAlignment alignment) {
status_area_widget_delegate_->set_alignment(alignment);
if (system_tray_)
system_tray_->SetShelfAlignment(alignment);
if (web_notification_tray_)
web_notification_tray_->SetShelfAlignment(alignment);
- if (logout_button_tray_)
- logout_button_tray_->SetShelfAlignment(alignment);
status_area_widget_delegate_->UpdateLayout();
}
@@ -148,8 +134,6 @@ void StatusAreaWidget::UpdateAfterLoginStatusChange(
system_tray_->UpdateAfterLoginStatusChange(login_status);
if (web_notification_tray_)
web_notification_tray_->UpdateAfterLoginStatusChange(login_status);
- if (logout_button_tray_)
- logout_button_tray_->UpdateAfterLoginStatusChange(login_status);
}
} // namespace internal
diff --git a/chromium/ash/system/status_area_widget.h b/chromium/ash/system/status_area_widget.h
index 6a4cb2a40aa..5283535f5a0 100644
--- a/chromium/ash/system/status_area_widget.h
+++ b/chromium/ash/system/status_area_widget.h
@@ -18,7 +18,6 @@ class WebNotificationTray;
namespace internal {
-class LogoutButtonTray;
class StatusAreaWidgetDelegate;
class ASH_EXPORT StatusAreaWidget : public views::Widget {
@@ -28,7 +27,7 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget {
explicit StatusAreaWidget(aura::Window* status_container);
virtual ~StatusAreaWidget();
- // Creates the SystemTray, WebNotificationTray and LogoutButtonTray.
+ // Creates the SystemTray and the WebNotificationTray.
void CreateTrayViews();
// Destroys the system tray and web notification tray. Called before
@@ -73,13 +72,11 @@ class ASH_EXPORT StatusAreaWidget : public views::Widget {
private:
void AddSystemTray();
void AddWebNotificationTray();
- void AddLogoutButtonTray();
// Weak pointers to View classes that are parented to StatusAreaWidget:
internal::StatusAreaWidgetDelegate* status_area_widget_delegate_;
SystemTray* system_tray_;
WebNotificationTray* web_notification_tray_;
- LogoutButtonTray* logout_button_tray_;
user::LoginStatus login_status_;
DISALLOW_COPY_AND_ASSIGN(StatusAreaWidget);
diff --git a/chromium/ash/system/tray/system_tray.cc b/chromium/ash/system/tray/system_tray.cc
index 47157ea46ff..122253f9986 100644
--- a/chromium/ash/system/tray/system_tray.cc
+++ b/chromium/ash/system/tray/system_tray.cc
@@ -15,6 +15,7 @@
#include "ash/system/date/tray_date.h"
#include "ash/system/drive/tray_drive.h"
#include "ash/system/ime/tray_ime.h"
+#include "ash/system/logout_button/tray_logout_button.h"
#include "ash/system/monitor/tray_monitor.h"
#include "ash/system/session_length_limit/tray_session_length_limit.h"
#include "ash/system/status_area_widget.h"
@@ -146,6 +147,7 @@ void SystemTray::InitializeTrayItems(SystemTrayDelegate* delegate) {
void SystemTray::CreateItems(SystemTrayDelegate* delegate) {
#if !defined(OS_WIN)
AddTrayItem(new internal::TraySessionLengthLimit(this));
+ AddTrayItem(new internal::TrayLogoutButton(this));
// In multi-profile user mode we can have multiple user tiles.
ash::Shell* shell = ash::Shell::GetInstance();
int maximum_user_profiles =
diff --git a/chromium/ash/system/tray/system_tray.h b/chromium/ash/system/tray/system_tray.h
index b37a643205a..ded64750026 100644
--- a/chromium/ash/system/tray/system_tray.h
+++ b/chromium/ash/system/tray/system_tray.h
@@ -36,6 +36,7 @@ class UpdateObserver;
class UserObserver;
#if defined(OS_CHROMEOS)
class NetworkObserver;
+class SmsObserver;
#endif
class SystemTrayItem;
diff --git a/chromium/ash/system/tray/system_tray_delegate.h b/chromium/ash/system/tray/system_tray_delegate.h
index a66726b8232..0742ad147ad 100644
--- a/chromium/ash/system/tray/system_tray_delegate.h
+++ b/chromium/ash/system/tray/system_tray_delegate.h
@@ -156,6 +156,9 @@ class SystemTrayDelegate {
// Shows settings.
virtual void ShowSettings() = 0;
+ // Returns true if settings menu item should appear.
+ virtual bool ShouldShowSettings() = 0;
+
// Shows the settings related to date, timezone etc.
virtual void ShowDateSettings() = 0;
@@ -288,6 +291,16 @@ class SystemTrayDelegate {
// Returns whether bluetooth is enabled.
virtual bool GetBluetoothEnabled() = 0;
+ // Retrieves information about the carrier and locale specific |setup_url|.
+ // If none of the carrier info/setup URL cannot be retrieved, returns false.
+ // Note: |setup_url| is returned when carrier is not defined (no SIM card).
+ virtual bool GetCellularCarrierInfo(std::string* carrier_id,
+ std::string* topup_url,
+ std::string* setup_url) = 0;
+
+ // Opens the cellular network specific URL.
+ virtual void ShowCellularURL(const std::string& url) = 0;
+
// Shows UI for changing proxy settings.
virtual void ChangeProxySettings() = 0;
diff --git a/chromium/ash/system/tray/system_tray_notifier.cc b/chromium/ash/system/tray/system_tray_notifier.cc
index fcdb2d6d5bc..73f619586fd 100644
--- a/chromium/ash/system/tray/system_tray_notifier.cc
+++ b/chromium/ash/system/tray/system_tray_notifier.cc
@@ -140,6 +140,14 @@ void SystemTrayNotifier::RemoveNetworkObserver(NetworkObserver* observer) {
network_observers_.RemoveObserver(observer);
}
+void SystemTrayNotifier::AddSmsObserver(SmsObserver* observer) {
+ sms_observers_.AddObserver(observer);
+}
+
+void SystemTrayNotifier::RemoveSmsObserver(SmsObserver* observer) {
+ sms_observers_.RemoveObserver(observer);
+}
+
void SystemTrayNotifier::AddEnterpriseDomainObserver(
EnterpriseDomainObserver* observer) {
enterprise_domain_observers_.AddObserver(observer);
@@ -318,6 +326,11 @@ void SystemTrayNotifier::NotifyRequestToggleWifi() {
RequestToggleWifi());
}
+void SystemTrayNotifier::NotifyAddSmsMessage(
+ const base::DictionaryValue& message) {
+ FOR_EACH_OBSERVER(SmsObserver, sms_observers_, AddMessage(message));
+}
+
void SystemTrayNotifier::NotifyEnterpriseDomainChanged() {
FOR_EACH_OBSERVER(EnterpriseDomainObserver, enterprise_domain_observers_,
OnEnterpriseDomainChanged());
diff --git a/chromium/ash/system/tray/system_tray_notifier.h b/chromium/ash/system/tray/system_tray_notifier.h
index 2ae739fe9e3..86210b4d343 100644
--- a/chromium/ash/system/tray/system_tray_notifier.h
+++ b/chromium/ash/system/tray/system_tray_notifier.h
@@ -13,6 +13,7 @@
#include "ash/system/brightness/brightness_observer.h"
#include "ash/system/chromeos/enterprise/enterprise_domain_observer.h"
#include "ash/system/chromeos/network/network_observer.h"
+#include "ash/system/chromeos/network/sms_observer.h"
#include "ash/system/chromeos/tray_tracing.h"
#include "ash/system/date/clock_observer.h"
#include "ash/system/drive/drive_observer.h"
@@ -28,6 +29,7 @@
#if defined(OS_CHROMEOS)
#include "ash/system/chromeos/network/network_observer.h"
+#include "ash/system/chromeos/network/sms_observer.h"
#include "ash/system/chromeos/screen_security/screen_capture_observer.h"
#include "ash/system/chromeos/screen_security/screen_share_observer.h"
#endif
@@ -86,6 +88,9 @@ public:
void AddNetworkObserver(NetworkObserver* observer);
void RemoveNetworkObserver(NetworkObserver* observer);
+ void AddSmsObserver(SmsObserver* observer);
+ void RemoveSmsObserver(SmsObserver* observer);
+
void AddEnterpriseDomainObserver(EnterpriseDomainObserver* observer);
void RemoveEnterpriseDomainObserver(EnterpriseDomainObserver* observer);
@@ -126,6 +131,7 @@ public:
const std::vector<base::string16>& links);
void NotifyClearNetworkMessage(NetworkObserver::MessageType message_type);
void NotifyRequestToggleWifi();
+ void NotifyAddSmsMessage(const base::DictionaryValue& message);
void NotifyEnterpriseDomainChanged();
void NotifyScreenCaptureStart(const base::Closure& stop_callback,
const base::string16& sharing_app_name);
@@ -155,6 +161,7 @@ public:
ObserverList<UserObserver> user_observers_;
#if defined(OS_CHROMEOS)
ObserverList<NetworkObserver> network_observers_;
+ ObserverList<SmsObserver> sms_observers_;
ObserverList<EnterpriseDomainObserver> enterprise_domain_observers_;
ObserverList<ScreenCaptureObserver> screen_capture_observers_;
ObserverList<ScreenShareObserver> screen_share_observers_;
diff --git a/chromium/ash/system/tray/test_system_tray_delegate.cc b/chromium/ash/system/tray/test_system_tray_delegate.cc
index 44b21fa8ff9..d7a3a551584 100644
--- a/chromium/ash/system/tray/test_system_tray_delegate.cc
+++ b/chromium/ash/system/tray/test_system_tray_delegate.cc
@@ -114,6 +114,10 @@ base::HourClockType TestSystemTrayDelegate::GetHourClockType() const {
void TestSystemTrayDelegate::ShowSettings() {
}
+bool TestSystemTrayDelegate::ShouldShowSettings() {
+ return true;
+}
+
void TestSystemTrayDelegate::ShowDateSettings() {
}
@@ -254,6 +258,15 @@ bool TestSystemTrayDelegate::GetBluetoothEnabled() {
return bluetooth_enabled_;
}
+bool TestSystemTrayDelegate::GetCellularCarrierInfo(std::string* carrier_id,
+ std::string* topup_url,
+ std::string* setup_url) {
+ return false;
+}
+
+void TestSystemTrayDelegate::ShowCellularURL(const std::string& url) {
+}
+
void TestSystemTrayDelegate::ChangeProxySettings() {
}
diff --git a/chromium/ash/system/tray/test_system_tray_delegate.h b/chromium/ash/system/tray/test_system_tray_delegate.h
index 9be9c8ac652..68bb593b843 100644
--- a/chromium/ash/system/tray/test_system_tray_delegate.h
+++ b/chromium/ash/system/tray/test_system_tray_delegate.h
@@ -38,6 +38,7 @@ class TestSystemTrayDelegate : public SystemTrayDelegate {
virtual bool SystemShouldUpgrade() const OVERRIDE;
virtual base::HourClockType GetHourClockType() const OVERRIDE;
virtual void ShowSettings() OVERRIDE;
+ virtual bool ShouldShowSettings() OVERRIDE;
virtual void ShowDateSettings() OVERRIDE;
virtual void ShowNetworkSettings(const std::string& service_path) OVERRIDE;
virtual void ShowBluetoothSettings() OVERRIDE;
@@ -83,6 +84,10 @@ class TestSystemTrayDelegate : public SystemTrayDelegate {
virtual void ShowOtherCellular() OVERRIDE;
virtual bool GetBluetoothAvailable() OVERRIDE;
virtual bool GetBluetoothEnabled() OVERRIDE;
+ virtual bool GetCellularCarrierInfo(std::string* carrier_id,
+ std::string* topup_url,
+ std::string* setup_url) OVERRIDE;
+ virtual void ShowCellularURL(const std::string& url) OVERRIDE;
virtual void ChangeProxySettings() OVERRIDE;
virtual VolumeControlDelegate* GetVolumeControlDelegate() const OVERRIDE;
virtual void SetVolumeControlDelegate(
diff --git a/chromium/ash/system/tray/tray_background_view.h b/chromium/ash/system/tray/tray_background_view.h
index b0f28067f61..4d57d5bab22 100644
--- a/chromium/ash/system/tray/tray_background_view.h
+++ b/chromium/ash/system/tray/tray_background_view.h
@@ -19,8 +19,7 @@ class StatusAreaWidget;
class TrayEventFilter;
class TrayBackground;
-// Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray,
-// LogoutButtonTray.
+// Base class for children of StatusAreaWidget: SystemTray, WebNotificationTray.
// This class handles setting and animating the background when the Launcher
// his shown/hidden. It also inherits from ActionableView so that the tray
// items can override PerformAction when clicked on.
diff --git a/chromium/ash/system/tray/tray_constants.cc b/chromium/ash/system/tray/tray_constants.cc
index 6d4b2e6b90d..6d108c8d029 100644
--- a/chromium/ash/system/tray/tray_constants.cc
+++ b/chromium/ash/system/tray/tray_constants.cc
@@ -67,17 +67,12 @@ const int kTrayNotificationContentsWidth = kTrayPopupMinWidth -
(kTrayPopupPaddingHorizontal / 2) * 3);
const int kTraySpacing = 8;
const int kAlternateTraySpacing = 4;
-const int kShelfItemHeight = 31;
-const int kAlternateShelfItemHeight = 38;
+// Returns kTraySpacing or kAlternateTraySpacing as applicable
+// (Determined by ash::switches::UseAlternateShelfLayout).
int GetTraySpacing() {
return ash::switches::UseAlternateShelfLayout() ?
kAlternateTraySpacing : kTraySpacing;
}
-int GetShelfItemHeight() {
- return ash::switches::UseAlternateShelfLayout() ?
- kAlternateShelfItemHeight : kShelfItemHeight;
-}
-
} // namespace ash
diff --git a/chromium/ash/system/tray/tray_constants.h b/chromium/ash/system/tray/tray_constants.h
index 50b2210bca0..480d5d54a35 100644
--- a/chromium/ash/system/tray/tray_constants.h
+++ b/chromium/ash/system/tray/tray_constants.h
@@ -66,10 +66,6 @@ extern const int kTrayNotificationContentsWidth;
// (Determined by ash::switches::UseAlternateShelfLayout).
int GetTraySpacing();
-// Returns kShelfItemHeight or kAlternateShelfItemHeight as applicable
-// (Determined by ash::switches::UseAlternateShelfLayout).
-int GetShelfItemHeight();
-
} // namespace ash
#endif // ASH_SYSTEM_TRAY_TRAY_CONSTANTS_H_
diff --git a/chromium/ash/system/tray/tray_image_item.cc b/chromium/ash/system/tray/tray_image_item.cc
index 7c5e216c942..d4ff9040ade 100644
--- a/chromium/ash/system/tray/tray_image_item.cc
+++ b/chromium/ash/system/tray/tray_image_item.cc
@@ -4,13 +4,12 @@
#include "ash/system/tray/tray_image_item.h"
-#include "ash/system/tray/system_tray.h"
#include "ash/system/tray/tray_item_view.h"
#include "ash/system/tray/tray_utils.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/image/image.h"
#include "ui/views/controls/image_view.h"
-#include "ui/views/layout/box_layout.h"
+#include "ui/views/layout/fill_layout.h"
namespace ash {
namespace internal {
@@ -42,7 +41,6 @@ views::View* TrayImageItem::CreateTrayView(user::LoginStatus status) {
tray_view_->image_view()->SetImage(ui::ResourceBundle::GetSharedInstance().
GetImageNamed(resource_id_).ToImageSkia());
tray_view_->SetVisible(GetInitialVisibility());
- SetItemAlignment(system_tray()->shelf_alignment());
return tray_view_;
}
@@ -59,7 +57,6 @@ void TrayImageItem::UpdateAfterLoginStatusChange(user::LoginStatus status) {
void TrayImageItem::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
SetTrayImageItemBorder(tray_view_, alignment);
- SetItemAlignment(alignment);
}
void TrayImageItem::DestroyTrayView() {
@@ -72,22 +69,5 @@ void TrayImageItem::DestroyDefaultView() {
void TrayImageItem::DestroyDetailedView() {
}
-void TrayImageItem::SetItemAlignment(ShelfAlignment alignment) {
- // Center the item dependent on the orientation of the shelf.
- views::BoxLayout::Orientation layout = views::BoxLayout::kHorizontal;
- switch (alignment) {
- case ash::SHELF_ALIGNMENT_BOTTOM:
- case ash::SHELF_ALIGNMENT_TOP:
- layout = views::BoxLayout::kHorizontal;
- break;
- case ash::SHELF_ALIGNMENT_LEFT:
- case ash::SHELF_ALIGNMENT_RIGHT:
- layout = views::BoxLayout::kVertical;
- break;
- }
- tray_view_->SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0));
- tray_view_->Layout();
-}
-
} // namespace internal
} // namespace ash
diff --git a/chromium/ash/system/tray/tray_image_item.h b/chromium/ash/system/tray/tray_image_item.h
index 6dea5c8372f..ebaf30e14a0 100644
--- a/chromium/ash/system/tray/tray_image_item.h
+++ b/chromium/ash/system/tray/tray_image_item.h
@@ -41,9 +41,6 @@ class TrayImageItem : public SystemTrayItem {
ShelfAlignment alignment) OVERRIDE;
private:
- // Set the alignment of the image depending on the shelf alignment.
- void SetItemAlignment(ShelfAlignment alignment);
-
int resource_id_;
TrayItemView* tray_view_;
diff --git a/chromium/ash/system/user/tray_user.cc b/chromium/ash/system/user/tray_user.cc
index 94a85ea07a5..2ab24a8b8a4 100644
--- a/chromium/ash/system/user/tray_user.cc
+++ b/chromium/ash/system/user/tray_user.cc
@@ -10,9 +10,7 @@
#include "ash/ash_switches.h"
#include "ash/popup_message.h"
-#include "ash/root_window_controller.h"
#include "ash/session_state_delegate.h"
-#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/system/tray/system_tray.h"
@@ -1172,7 +1170,7 @@ void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) {
need_label = true;
break;
case user::LOGGED_IN_GUEST:
- need_label = true;
+ need_avatar = true;
break;
case user::LOGGED_IN_RETAIL_MODE:
case user::LOGGED_IN_KIOSK_APP:
@@ -1202,8 +1200,6 @@ void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) {
if (status == user::LOGGED_IN_LOCALLY_MANAGED) {
label_->SetText(
bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_LOCALLY_MANAGED_LABEL));
- } else if (status == user::LOGGED_IN_GUEST) {
- label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_GUEST_LABEL));
}
if (avatar_ && ash::switches::UseAlternateShelfLayout()) {
@@ -1214,12 +1210,6 @@ void TrayUser::UpdateAfterLoginStatusChange(user::LoginStatus status) {
avatar_->set_border(NULL);
}
UpdateAvatarImage(status);
-
- // Update layout after setting label_ and avatar_ with new login status.
- if (Shell::GetPrimaryRootWindowController()->shelf())
- UpdateAfterShelfAlignmentChange(
- Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()->
- GetAlignment());
}
void TrayUser::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
@@ -1286,10 +1276,19 @@ void TrayUser::UpdateAvatarImage(user::LoginStatus status) {
int icon_size = ash::switches::UseAlternateShelfLayout() ?
kUserIconLargeSize : kUserIconSize;
- avatar_->SetImage(
- ash::Shell::GetInstance()->session_state_delegate()->GetUserImage(
- multiprofile_index_),
- gfx::Size(icon_size, icon_size));
+ if (status == user::LOGGED_IN_GUEST) {
+ int image_name = ash::switches::UseAlternateShelfLayout() ?
+ IDR_AURA_UBER_TRAY_GUEST_ICON_LARGE :
+ IDR_AURA_UBER_TRAY_GUEST_ICON;
+ avatar_->SetImage(*ui::ResourceBundle::GetSharedInstance().
+ GetImageNamed(image_name).ToImageSkia(),
+ gfx::Size(icon_size, icon_size));
+ } else {
+ avatar_->SetImage(
+ ash::Shell::GetInstance()->session_state_delegate()->GetUserImage(
+ multiprofile_index_),
+ gfx::Size(icon_size, icon_size));
+ }
}
} // namespace internal
diff --git a/chromium/ash/system/web_notification/web_notification_tray.cc b/chromium/ash/system/web_notification/web_notification_tray.cc
index e6bd4925e3e..2a6e2deadca 100644
--- a/chromium/ash/system/web_notification/web_notification_tray.cc
+++ b/chromium/ash/system/web_notification/web_notification_tray.cc
@@ -58,6 +58,10 @@ namespace ash {
namespace internal {
namespace {
+const int kWebNotificationIconSize = 31;
+// Height of the art assets used in alternate shelf layout,
+// see ash/ash_switches.h:UseAlternateShelfLayout.
+const int kWebNotificationAlternateSize = 38;
const SkColor kWebNotificationColorNoUnread = SkColorSetA(SK_ColorWHITE, 128);
const SkColor kWebNotificationColorWithUnread = SK_ColorWHITE;
@@ -106,15 +110,6 @@ WorkAreaObserver::~WorkAreaObserver() {
void WorkAreaObserver::SetSystemTrayHeight(int height) {
system_tray_height_ = height;
-
- // If the shelf is shown during auto-hide state, the distance from the edge
- // should be reduced by the height of shelf's shown height.
- if (shelf_->visibility_state() == SHELF_AUTO_HIDE &&
- shelf_->auto_hide_state() == SHELF_AUTO_HIDE_SHOWN) {
- system_tray_height_ -= ShelfLayoutManager::GetPreferredShelfSize() -
- ShelfLayoutManager::kAutoHideSize;
- }
-
if (system_tray_height_ > 0 && ash::switches::UseAlternateShelfLayout())
system_tray_height_ += message_center::kMarginBetweenItems;
@@ -132,23 +127,43 @@ void WorkAreaObserver::OnAutoHideStateChanged(ShelfAutoHideState new_state) {
shelf_->shelf_widget()->GetNativeView());
gfx::Rect work_area = display.work_area();
int width = 0;
- if ((shelf_->visibility_state() == SHELF_AUTO_HIDE) &&
- new_state == SHELF_AUTO_HIDE_SHOWN) {
- // Since the work_area is already reduced by kAutoHideSize, the inset width
- // should be just the difference.
- width = ShelfLayoutManager::GetPreferredShelfSize() -
- ShelfLayoutManager::kAutoHideSize;
+ if (shelf_->auto_hide_behavior() != SHELF_AUTO_HIDE_BEHAVIOR_NEVER) {
+ width = (new_state == SHELF_AUTO_HIDE_HIDDEN) ?
+ ShelfLayoutManager::kAutoHideSize :
+ ShelfLayoutManager::GetPreferredShelfSize();
}
- work_area.Inset(shelf_->SelectValueForShelfAlignment(
- gfx::Insets(0, 0, width, 0),
- gfx::Insets(0, width, 0, 0),
- gfx::Insets(0, 0, 0, width),
- gfx::Insets(width, 0, 0, 0)));
- if (system_tray_height_ > 0) {
- work_area.set_height(
- std::max(0, work_area.height() - system_tray_height_));
- if (shelf_->GetAlignment() == SHELF_ALIGNMENT_TOP)
- work_area.set_y(work_area.y() + system_tray_height_);
+ switch (shelf_->GetAlignment()) {
+ case SHELF_ALIGNMENT_BOTTOM:
+ work_area.Inset(0, 0, 0, width);
+ if (system_tray_height_ > 0) {
+ work_area.set_height(
+ std::max(0, work_area.height() - system_tray_height_));
+ }
+ break;
+ case SHELF_ALIGNMENT_LEFT:
+ work_area.Inset(width, 0, 0, 0);
+ // Popups appear on the left bottom only when UI is RTL.
+ if (base::i18n::IsRTL() && system_tray_height_ > 0) {
+ work_area.set_height(
+ std::max(0, work_area.height() - system_tray_height_));
+ }
+ break;
+ case SHELF_ALIGNMENT_RIGHT:
+ work_area.Inset(0, 0, width, 0);
+ // Popups appear on the right bottom only when UI isn't RTL.
+ if (!base::i18n::IsRTL() && system_tray_height_ > 0) {
+ work_area.set_height(
+ std::max(0, work_area.height() - system_tray_height_));
+ }
+ break;
+ case SHELF_ALIGNMENT_TOP:
+ work_area.Inset(0, width, 0, 0);
+ if (system_tray_height_ > 0) {
+ work_area.set_y(work_area.y() + system_tray_height_);
+ work_area.set_height(
+ std::max(0, work_area.height() - system_tray_height_));
+ }
+ break;
}
collection_->SetDisplayInfo(work_area, display.bounds());
}
@@ -226,12 +241,10 @@ class WebNotificationButton : public views::CustomButton {
protected:
// Overridden from views::ImageButton:
virtual gfx::Size GetPreferredSize() OVERRIDE {
- const int notification_item_size = GetShelfItemHeight();
- return gfx::Size(notification_item_size, notification_item_size);
- }
-
- virtual int GetHeightForWidth(int width) OVERRIDE {
- return GetPreferredSize().height();
+ if (ash::switches::UseAlternateShelfLayout())
+ return gfx::Size(kWebNotificationAlternateSize,
+ kWebNotificationAlternateSize);
+ return gfx::Size(kWebNotificationIconSize, kWebNotificationIconSize);
}
private:
diff --git a/chromium/ash/system/web_notification/web_notification_tray.h b/chromium/ash/system/web_notification/web_notification_tray.h
index 1fb9c4d3fbc..d8b2fd3a02a 100644
--- a/chromium/ash/system/web_notification/web_notification_tray.h
+++ b/chromium/ash/system/web_notification/web_notification_tray.h
@@ -124,7 +124,6 @@ class ASH_EXPORT WebNotificationTray
FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, ManyPopupNotifications);
FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, PopupShownOnBothDisplays);
FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, PopupAndSystemTray);
- FRIEND_TEST_ALL_PREFIXES(WebNotificationTrayTest, PopupAndAutoHideShelf);
void UpdateTrayContent();
diff --git a/chromium/ash/system/web_notification/web_notification_tray_unittest.cc b/chromium/ash/system/web_notification/web_notification_tray_unittest.cc
index 5b67b7d72b4..026500f1798 100644
--- a/chromium/ash/system/web_notification/web_notification_tray_unittest.cc
+++ b/chromium/ash/system/web_notification/web_notification_tray_unittest.cc
@@ -16,14 +16,8 @@
#include "ash/system/tray/system_tray_item.h"
#include "ash/system/tray/test_system_tray_delegate.h"
#include "ash/test/ash_test_base.h"
-#include "ash/wm/window_properties.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
-#include "ui/aura/client/aura_constants.h"
-#include "ui/aura/test/event_generator.h"
-#include "ui/aura/window.h"
-#include "ui/gfx/display.h"
-#include "ui/gfx/screen.h"
#include "ui/message_center/message_center_style.h"
#include "ui/message_center/message_center_tray.h"
#include "ui/message_center/message_center_util.h"
@@ -150,10 +144,6 @@ class WebNotificationTrayTest : public test::AshTestBase {
return tray->popup_collection_->work_area_;
}
- bool IsPopupVisible() {
- return GetTray()->IsPopupVisible();
- }
-
private:
DISALLOW_COPY_AND_ASSIGN(WebNotificationTrayTest);
};
@@ -304,12 +294,8 @@ TEST_F(WebNotificationTrayTest, MAYBE_PopupShownOnBothDisplays) {
// RootWindow's bound can be bigger than gfx::Display's work area so that
// openingsystem tray doesn't affect at all the work area of popups.
#define MAYBE_PopupAndSystemTray PopupAndSystemTray
-#define MAYBE_PopupAndAutoHideShelf PopupAndAutoHideShelf
-#define MAYBE_PopupAndFullscreen PopupAndFullscreen
#else
#define MAYBE_PopupAndSystemTray DISABLED_PopupAndSystemTray
-#define MAYBE_PopupAndAutoHideShelf DISABLED_PopupAndAutoHideShelf
-#define MAYBE_PopupAndFullscreen DISABLED_PopupAndFullscreen
#endif
TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTray) {
@@ -346,115 +332,22 @@ TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTray) {
EXPECT_LT(work_area_with_tray_notificaiton.size().GetArea(),
work_area_with_notification.size().GetArea());
- // Close the system tray notifications.
+ // Close the notifications.
GetSystemTray()->HideNotificationView(test_item);
EXPECT_TRUE(GetTray()->IsPopupVisible());
EXPECT_EQ(work_area.ToString(), GetPopupWorkArea().ToString());
}
-TEST_F(WebNotificationTrayTest, MAYBE_PopupAndAutoHideShelf) {
+TEST_F(WebNotificationTrayTest, PopupAndSystemTrayAlignment) {
+ Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager()->
+ SetAlignment(SHELF_ALIGNMENT_LEFT);
AddNotification("test_id");
- EXPECT_TRUE(GetTray()->IsPopupVisible());
gfx::Rect work_area = GetPopupWorkArea();
- // Shelf's auto-hide state won't be HIDDEN unless window exists.
- scoped_ptr<aura::Window> window(
- CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
- internal::ShelfLayoutManager* shelf =
- Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
-
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
- gfx::Rect work_area_auto_hidden = GetPopupWorkArea();
- EXPECT_LT(work_area.size().GetArea(), work_area_auto_hidden.size().GetArea());
-
- // Close the window, which shows the shelf.
- window.reset();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
- gfx::Rect work_area_auto_shown = GetPopupWorkArea();
- EXPECT_EQ(work_area.ToString(), work_area_auto_shown.ToString());
-
- // Create the system tray during auto-hide.
- window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
- TestItem* test_item = new TestItem;
- GetSystemTray()->AddTrayItem(test_item);
+ // System tray is created, but the work area is not affected since the tray
+ // appears at the left-bottom while the popups appear at the right bottom.
GetSystemTray()->ShowDefaultView(BUBBLE_CREATE_NEW);
-
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
- EXPECT_TRUE(GetTray()->IsPopupVisible());
- gfx::Rect work_area_with_tray = GetPopupWorkArea();
- EXPECT_GT(work_area_auto_shown.size().GetArea(),
- work_area_with_tray.size().GetArea());
-
- // Create tray notification.
- GetSystemTray()->ShowNotificationView(test_item);
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
- gfx::Rect work_area_with_tray_notification = GetPopupWorkArea();
- EXPECT_GT(work_area_with_tray.size().GetArea(),
- work_area_with_tray_notification.size().GetArea());
-
- // Close the system tray.
- GetSystemTray()->ClickedOutsideBubble();
- shelf->UpdateAutoHideState();
- RunAllPendingInMessageLoop();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
- gfx::Rect work_area_hidden_with_tray_notification = GetPopupWorkArea();
- EXPECT_LT(work_area_with_tray_notification.size().GetArea(),
- work_area_hidden_with_tray_notification.size().GetArea());
- EXPECT_GT(work_area_auto_hidden.size().GetArea(),
- work_area_hidden_with_tray_notification.size().GetArea());
-
- // Close the window again, which shows the shelf.
- window.reset();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
- gfx::Rect work_area_shown_with_tray_notification = GetPopupWorkArea();
- EXPECT_GT(work_area_hidden_with_tray_notification.size().GetArea(),
- work_area_shown_with_tray_notification.size().GetArea());
- EXPECT_GT(work_area_auto_shown.size().GetArea(),
- work_area_shown_with_tray_notification.size().GetArea());
-}
-
-TEST_F(WebNotificationTrayTest, MAYBE_PopupAndFullscreen) {
- AddNotification("test_id");
- EXPECT_TRUE(IsPopupVisible());
- gfx::Rect work_area = GetPopupWorkArea();
-
- // Checks the work area for normal auto-hidden state.
- scoped_ptr<aura::Window> window(
- CreateTestWindowInShellWithBounds(gfx::Rect(1, 2, 3, 4)));
- internal::ShelfLayoutManager* shelf =
- Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
- gfx::Rect work_area_auto_hidden = GetPopupWorkArea();
- shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
-
- // Make the window to use immersive mode.
- window->SetProperty(internal::kFullscreenUsesMinimalChromeKey, true);
- window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
- RunAllPendingInMessageLoop();
-
- // The work area for auto-hidden status of fullscreen is a bit larger
- // since it doesn't even have the 3-pixel width.
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
- gfx::Rect work_area_fullscreen_hidden = GetPopupWorkArea();
- EXPECT_EQ(work_area_auto_hidden.ToString(),
- work_area_fullscreen_hidden.ToString());
-
- // Move the mouse cursor at the bottom, which shows the shelf.
- aura::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
- gfx::Point bottom_right =
- Shell::GetScreen()->GetPrimaryDisplay().bounds().bottom_right();
- bottom_right.Offset(-1, -1);
- generator.MoveMouseTo(bottom_right);
- shelf->UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
EXPECT_EQ(work_area.ToString(), GetPopupWorkArea().ToString());
-
- generator.MoveMouseTo(work_area.CenterPoint());
- shelf->UpdateAutoHideStateNow();
- EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->auto_hide_state());
- EXPECT_EQ(work_area_auto_hidden.ToString(), GetPopupWorkArea().ToString());
}
TEST_F(WebNotificationTrayTest, MAYBE_PopupAndSystemTrayMultiDisplay) {