diff options
-rw-r--r-- | ash/ash.gyp | 2 | ||||
-rw-r--r-- | ash/ash_strings.grd | 3 | ||||
-rw-r--r-- | ash/resources/ash_resources.grd | 1 | ||||
-rw-r--r-- | ash/system/chromeos/tray_tracing.cc | 112 | ||||
-rw-r--r-- | ash/system/chromeos/tray_tracing.h | 57 | ||||
-rw-r--r-- | ash/system/tray/system_tray.cc | 2 | ||||
-rw-r--r-- | ash/system/tray/system_tray_delegate.h | 3 | ||||
-rw-r--r-- | ash/system/tray/system_tray_notifier.cc | 15 | ||||
-rw-r--r-- | ash/system/tray/system_tray_notifier.h | 6 | ||||
-rw-r--r-- | ash/system/tray/test_system_tray_delegate.cc | 3 | ||||
-rw-r--r-- | ash/system/tray/test_system_tray_delegate.h | 1 | ||||
-rw-r--r-- | chrome/browser/chromeos/system/ash_system_tray_delegate.cc | 19 | ||||
-rw-r--r-- | chrome/browser/ui/chrome_pages.cc | 6 | ||||
-rw-r--r-- | chrome/browser/ui/chrome_pages.h | 1 |
14 files changed, 231 insertions, 0 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index 33d729e..7a3f1be 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -260,6 +260,8 @@ 'system/chromeos/settings/tray_settings.h', 'system/chromeos/tray_display.cc', 'system/chromeos/tray_display.h', + 'system/chromeos/tray_tracing.cc', + 'system/chromeos/tray_tracing.h', 'system/date/clock_observer.h', 'system/date/date_view.cc', 'system/date/date_view.h', diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd index 7bb2b9f..2d75802 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd @@ -285,6 +285,9 @@ Press Ctrl+Alt+Z to disable. <message name="IDS_ASH_STATUS_TRAY_BLUETOOTH_DISCOVERING" desc="The label used in the tray popup to show bluetooth is discovering devices."> Scanning for devices... </message> + <message name="IDS_ASH_STATUS_TRAY_TRACING" desc="The status tray item indicating that performance tracing is running."> + Performance tracing enabled + </message> <message name="IDS_ASH_STATUS_TRAY_UPDATE" desc="The label used in the tray popup to notify that the user should restart to get system updates."> Restart to update diff --git a/ash/resources/ash_resources.grd b/ash/resources/ash_resources.grd index f7a0bd3..166fe5f 100644 --- a/ash/resources/ash_resources.grd +++ b/ash/resources/ash_resources.grd @@ -159,6 +159,7 @@ <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_SHUTDOWN" file="cros/status/status_shutdown.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER" file="cros/status/status_shutdown_hover.png" /> <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_SMS" file="cros/status/status_sms.png" /> + <structure type="chrome_scaled_image" name="IDR_AURA_UBER_TRAY_TRACING" file="cros/status/status_tracing.png" /> <!-- ChromeOS specific icons --> <if expr="pp_ifdef('chromeos')"> diff --git a/ash/system/chromeos/tray_tracing.cc b/ash/system/chromeos/tray_tracing.cc new file mode 100644 index 0000000..b6a8cf1 --- /dev/null +++ b/ash/system/chromeos/tray_tracing.cc @@ -0,0 +1,112 @@ +// 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/chromeos/tray_tracing.h" + +#include "ash/system/tray/actionable_view.h" +#include "ash/system/tray/fixed_sized_image_view.h" +#include "ash/system/tray/system_tray.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 "grit/ash_resources.h" +#include "grit/ash_strings.h" +#include "ui/base/l10n/l10n_util.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/image/image.h" +#include "ui/views/controls/image_view.h" +#include "ui/views/controls/label.h" +#include "ui/views/layout/box_layout.h" + +namespace ash { +namespace internal { + +namespace tray { + +class DefaultTracingView : public ash::internal::ActionableView { + public: + DefaultTracingView() { + SetLayoutManager(new views::BoxLayout( + views::BoxLayout::kHorizontal, + ash::kTrayPopupPaddingHorizontal, 0, + ash::kTrayPopupPaddingBetweenItems)); + + ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); + image_ = + new ash::internal::FixedSizedImageView(0, ash::kTrayPopupItemHeight); + image_->SetImage( + bundle.GetImageNamed(IDR_AURA_UBER_TRAY_TRACING).ToImageSkia()); + AddChildView(image_); + + label_ = new views::Label(); + label_->SetMultiLine(true); + label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); + label_->SetText(bundle.GetLocalizedString(IDS_ASH_STATUS_TRAY_TRACING)); + AddChildView(label_); + } + + virtual ~DefaultTracingView() {} + + private: + // Overridden from ActionableView. + virtual bool PerformAction(const ui::Event& event) OVERRIDE { + ash::Shell::GetInstance()->system_tray_delegate()->ShowChromeSlow(); + return true; + } + + views::ImageView* image_; + views::Label* label_; + + DISALLOW_COPY_AND_ASSIGN(DefaultTracingView); +}; + +} // namespace tray + +//////////////////////////////////////////////////////////////////////////////// +// ash::internal::TrayTracing + +TrayTracing::TrayTracing(SystemTray* system_tray) + : TrayImageItem(system_tray, IDR_AURA_UBER_TRAY_TRACING), + default_(NULL) { + DCHECK(Shell::GetInstance()->delegate()); + DCHECK(system_tray); + Shell::GetInstance()->system_tray_notifier()->AddTracingObserver(this); +} + +TrayTracing::~TrayTracing() { + Shell::GetInstance()->system_tray_notifier()->RemoveTracingObserver(this); +} + +void TrayTracing::SetTrayIconVisible(bool visible) { + if (tray_view()) + tray_view()->SetVisible(visible); +} + +bool TrayTracing::GetInitialVisibility() { + return false; +} + +views::View* TrayTracing::CreateDefaultView(user::LoginStatus status) { + CHECK(default_ == NULL); + default_ = new tray::DefaultTracingView(); + return default_; +} + +views::View* TrayTracing::CreateDetailedView(user::LoginStatus status) { + return NULL; +} + +void TrayTracing::DestroyDefaultView() { + default_ = NULL; +} + +void TrayTracing::DestroyDetailedView() { +} + +void TrayTracing::OnTracingModeChanged(bool value) { + SetTrayIconVisible(value); +} + +} // namespace internal +} // namespace ash diff --git a/ash/system/chromeos/tray_tracing.h b/ash/system/chromeos/tray_tracing.h new file mode 100644 index 0000000..f9491e1 --- /dev/null +++ b/ash/system/chromeos/tray_tracing.h @@ -0,0 +1,57 @@ +// 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_TRAY_TRACING_H_ +#define ASH_SYSTEM_TRAY_TRACING_H_ + +#include "ash/ash_export.h" +#include "ash/system/tray/tray_image_item.h" + +namespace views { +class View; +} + +namespace ash { + +class ASH_EXPORT TracingObserver { + public: + virtual ~TracingObserver() {} + + // Notifies when tracing mode changes. + virtual void OnTracingModeChanged(bool value) = 0; +}; + +namespace internal { + +// This is the item that displays when users enable performance tracing at +// chrome://slow. It alerts them that this mode is running, and provides an +// easy way to open the page to disable it. +class TrayTracing : public TrayImageItem, + public TracingObserver { + public: + explicit TrayTracing(SystemTray* system_tray); + virtual ~TrayTracing(); + + private: + void SetTrayIconVisible(bool visible); + + // Overridden from TrayImageItem. + virtual bool GetInitialVisibility() OVERRIDE; + virtual views::View* CreateDefaultView(user::LoginStatus status) OVERRIDE; + virtual views::View* CreateDetailedView(user::LoginStatus status) OVERRIDE; + virtual void DestroyDefaultView() OVERRIDE; + virtual void DestroyDetailedView() OVERRIDE; + + // Overridden from TracingObserver. + virtual void OnTracingModeChanged(bool value) OVERRIDE; + + views::View* default_; + + DISALLOW_COPY_AND_ASSIGN(TrayTracing); +}; + +} // namespace internal +} // namespace ash + +#endif // ASH_SYSTEM_TRAY_TRACING_H_ diff --git a/ash/system/tray/system_tray.cc b/ash/system/tray/system_tray.cc index c93efc9..122253f 100644 --- a/ash/system/tray/system_tray.cc +++ b/ash/system/tray/system_tray.cc @@ -11,6 +11,7 @@ #include "ash/shell_window_ids.h" #include "ash/system/bluetooth/tray_bluetooth.h" #include "ash/system/brightness/tray_brightness.h" +#include "ash/system/chromeos/tray_tracing.h" #include "ash/system/date/tray_date.h" #include "ash/system/drive/tray_drive.h" #include "ash/system/ime/tray_ime.h" @@ -167,6 +168,7 @@ void SystemTray::CreateItems(SystemTrayDelegate* delegate) { tray_accessibility_ = new internal::TrayAccessibility(this); AddTrayItem(tray_accessibility_); #if defined(OS_CHROMEOS) + AddTrayItem(new internal::TrayTracing(this)); AddTrayItem( new internal::TrayPower(this, message_center::MessageCenter::Get())); #endif diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h index d6f3c3d..0dcc07d 100644 --- a/ash/system/tray/system_tray_delegate.h +++ b/ash/system/tray/system_tray_delegate.h @@ -169,6 +169,9 @@ class SystemTrayDelegate { // Shows settings related to multiple displays. virtual void ShowDisplaySettings() = 0; + // Shows the page that lets you disable performance tracing. + virtual void ShowChromeSlow() = 0; + // Returns true if the notification for the display configuration change // should appear. virtual bool ShouldShowDisplayNotification() = 0; diff --git a/ash/system/tray/system_tray_notifier.cc b/ash/system/tray/system_tray_notifier.cc index f726a8f..73f6195 100644 --- a/ash/system/tray/system_tray_notifier.cc +++ b/ash/system/tray/system_tray_notifier.cc @@ -106,6 +106,14 @@ void SystemTrayNotifier::RemoveSessionLengthLimitObserver( session_length_limit_observers_.RemoveObserver(observer); } +void SystemTrayNotifier::AddTracingObserver(TracingObserver* observer) { + tracing_observers_.AddObserver(observer); +} + +void SystemTrayNotifier::RemoveTracingObserver(TracingObserver* observer) { + tracing_observers_.RemoveObserver(observer); +} + void SystemTrayNotifier::AddUpdateObserver(UpdateObserver* observer) { update_observers_.AddObserver(observer); } @@ -179,6 +187,13 @@ void SystemTrayNotifier::NotifyAccessibilityModeChanged( OnAccessibilityModeChanged(notify)); } +void SystemTrayNotifier::NotifyTracingModeChanged(bool value) { + FOR_EACH_OBSERVER( + TracingObserver, + tracing_observers_, + OnTracingModeChanged(value)); +} + void SystemTrayNotifier::NotifyRefreshBluetooth() { FOR_EACH_OBSERVER(BluetoothObserver, bluetooth_observers_, diff --git a/ash/system/tray/system_tray_notifier.h b/ash/system/tray/system_tray_notifier.h index 5546be0..86210b4 100644 --- a/ash/system/tray/system_tray_notifier.h +++ b/ash/system/tray/system_tray_notifier.h @@ -14,6 +14,7 @@ #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" #include "ash/system/ime/ime_observer.h" @@ -74,6 +75,9 @@ public: void AddSessionLengthLimitObserver(SessionLengthLimitObserver* observer); void RemoveSessionLengthLimitObserver(SessionLengthLimitObserver* observer); + void AddTracingObserver(TracingObserver* observer); + void RemoveTracingObserver(TracingObserver* observer); + void AddUpdateObserver(UpdateObserver* observer); void RemoveUpdateObserver(UpdateObserver* observer); @@ -99,6 +103,7 @@ public: void NotifyAccessibilityModeChanged( AccessibilityNotificationVisibility notify); + void NotifyTracingModeChanged(bool value); void NotifyRefreshBluetooth(); void NotifyBluetoothDiscoveringChanged(); void NotifyBrightnessChanged(double level, bool user_initialted); @@ -151,6 +156,7 @@ public: ObserverList<LocaleObserver> locale_observers_; ObserverList<LogoutButtonObserver> logout_button_observers_; ObserverList<SessionLengthLimitObserver> session_length_limit_observers_; + ObserverList<TracingObserver> tracing_observers_; ObserverList<UpdateObserver> update_observers_; ObserverList<UserObserver> user_observers_; #if defined(OS_CHROMEOS) diff --git a/ash/system/tray/test_system_tray_delegate.cc b/ash/system/tray/test_system_tray_delegate.cc index d516a76..c3a2bfc 100644 --- a/ash/system/tray/test_system_tray_delegate.cc +++ b/ash/system/tray/test_system_tray_delegate.cc @@ -127,6 +127,9 @@ void TestSystemTrayDelegate::ShowBluetoothSettings() { void TestSystemTrayDelegate::ShowDisplaySettings() { } +void TestSystemTrayDelegate::ShowChromeSlow() { +} + bool TestSystemTrayDelegate::ShouldShowDisplayNotification() { return should_show_display_notification_; } diff --git a/ash/system/tray/test_system_tray_delegate.h b/ash/system/tray/test_system_tray_delegate.h index 3b4ede7..4dc847d 100644 --- a/ash/system/tray/test_system_tray_delegate.h +++ b/ash/system/tray/test_system_tray_delegate.h @@ -42,6 +42,7 @@ class TestSystemTrayDelegate : public SystemTrayDelegate { virtual void ShowNetworkSettings(const std::string& service_path) OVERRIDE; virtual void ShowBluetoothSettings() OVERRIDE; virtual void ShowDisplaySettings() OVERRIDE; + virtual void ShowChromeSlow() OVERRIDE; virtual bool ShouldShowDisplayNotification() OVERRIDE; virtual void ShowDriveSettings() OVERRIDE; virtual void ShowIMESettings() OVERRIDE; diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc index 1810a55e..eb0b9a7 100644 --- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc +++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc @@ -72,6 +72,7 @@ #include "chrome/browser/chromeos/system/timezone_settings.h" #include "chrome/browser/chromeos/system_key_event_listener.h" #include "chrome/browser/drive/drive_service_interface.h" +#include "chrome/browser/feedback/tracing_manager.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/policy/browser_policy_connector.h" @@ -503,6 +504,10 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, kDisplaySettingsSubPageName); } + virtual void ShowChromeSlow() OVERRIDE { + chrome::ShowSlow(GetAppropriateBrowser()); + } + virtual bool ShouldShowDisplayNotification() OVERRIDE { // Packaged app is not counted as 'last active', so if a browser opening the // display settings is in background of a packaged app, it will return true. @@ -928,9 +933,14 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, base::Bind(&SystemTrayDelegate::OnAccessibilityModeChanged, base::Unretained(this), ash::A11Y_NOTIFICATION_NONE)); + user_pref_registrar_->Add( + prefs::kPerformanceTracingEnabled, + base::Bind(&SystemTrayDelegate::UpdatePerformanceTracing, + base::Unretained(this))); UpdateClockType(); UpdateShowLogoutButtonInTray(); + UpdatePerformanceTracing(); search_key_mapped_to_ = profile->GetPrefs()->GetInteger(prefs::kLanguageRemapSearchKeyTo); } @@ -1147,6 +1157,15 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate, GetSystemTrayNotifier()->NotifyAccessibilityModeChanged(notify); } + void UpdatePerformanceTracing() { + if (!user_pref_registrar_) + return; + bool value = + user_pref_registrar_->prefs()->GetBoolean( + prefs::kPerformanceTracingEnabled); + GetSystemTrayNotifier()->NotifyTracingModeChanged(value); + } + // Overridden from InputMethodManager::Observer. virtual void InputMethodChanged( input_method::InputMethodManager* manager, bool show_message) OVERRIDE { diff --git a/chrome/browser/ui/chrome_pages.cc b/chrome/browser/ui/chrome_pages.cc index a9caa99..34d9b6b 100644 --- a/chrome/browser/ui/chrome_pages.cc +++ b/chrome/browser/ui/chrome_pages.cc @@ -147,6 +147,12 @@ void ShowPolicy(Browser* browser) { ShowSingletonTab(browser, GURL(kChromeUIPolicyURL)); } +void ShowSlow(Browser* browser) { +#if defined(OS_CHROMEOS) + ShowSingletonTab(browser, GURL(kChromeUISlowURL)); +#endif +} + void ShowSettings(Browser* browser) { content::RecordAction(UserMetricsAction("ShowOptions")); ShowSettingsSubPage(browser, std::string()); diff --git a/chrome/browser/ui/chrome_pages.h b/chrome/browser/ui/chrome_pages.h index d4174fa..792fb6d 100644 --- a/chrome/browser/ui/chrome_pages.h +++ b/chrome/browser/ui/chrome_pages.h @@ -45,6 +45,7 @@ void ShowFeedbackPage(Browser* browser, void ShowHelp(Browser* browser, HelpSource source); void ShowPolicy(Browser* browser); +void ShowSlow(Browser* browser); // Various things that open in a settings UI. void ShowSettings(Browser* browser); |