diff options
-rw-r--r-- | apps/shell/app_shell.gyp | 8 | ||||
-rw-r--r-- | apps/shell/browser/shell_browser_main_parts.cc | 13 | ||||
-rw-r--r-- | apps/shell/browser/shell_browser_main_parts.h | 1 | ||||
-rw-r--r-- | apps/shell/browser/shell_desktop_controller.cc | 21 | ||||
-rw-r--r-- | apps/shell/browser/shell_desktop_controller.h | 14 | ||||
-rw-r--r-- | ash/shell.cc | 4 | ||||
-rw-r--r-- | ash/shell.h | 4 | ||||
-rw-r--r-- | ui/chromeos/ui_chromeos.gyp | 4 | ||||
-rw-r--r-- | ui/chromeos/user_activity_power_manager_notifier.cc (renamed from ui/chromeos/user_activity_notifier.cc) | 9 | ||||
-rw-r--r-- | ui/chromeos/user_activity_power_manager_notifier.h (renamed from ui/chromeos/user_activity_notifier.h) | 15 |
10 files changed, 71 insertions, 22 deletions
diff --git a/apps/shell/app_shell.gyp b/apps/shell/app_shell.gyp index b4e31a0..b8f394a 100644 --- a/apps/shell/app_shell.gyp +++ b/apps/shell/app_shell.gyp @@ -77,6 +77,7 @@ '<(DEPTH)/extensions/extensions.gyp:extensions_renderer', '<(DEPTH)/skia/skia.gyp:skia', '<(DEPTH)/third_party/WebKit/public/blink.gyp:blink', + '<(DEPTH)/ui/wm/wm.gyp:wm', '<(DEPTH)/ui/wm/wm.gyp:wm_test_support', '<(DEPTH)/v8/tools/gyp/v8.gyp:v8', ], @@ -122,6 +123,13 @@ 'renderer/shell_extensions_renderer_client.cc', 'renderer/shell_extensions_renderer_client.h', ], + 'conditions': [ + ['chromeos==1', { + 'dependencies': [ + '<(DEPTH)/ui/chromeos/ui_chromeos.gyp:ui_chromeos', + ], + }], + ], }, { 'target_name': 'app_shell', diff --git a/apps/shell/browser/shell_browser_main_parts.cc b/apps/shell/browser/shell_browser_main_parts.cc index 9ce8a1c..c886b74 100644 --- a/apps/shell/browser/shell_browser_main_parts.cc +++ b/apps/shell/browser/shell_browser_main_parts.cc @@ -23,6 +23,10 @@ #include "ui/aura/window_tree_host.h" #include "ui/base/resource/resource_bundle.h" +#if defined(OS_CHROMEOS) +#include "chromeos/dbus/dbus_thread_manager.h" +#endif + using content::BrowserContext; using extensions::Extension; using extensions::ExtensionSystem; @@ -55,6 +59,9 @@ void ShellBrowserMainParts::PreMainMessageLoopStart() { } void ShellBrowserMainParts::PostMainMessageLoopStart() { +#if defined(OS_CHROMEOS) + chromeos::DBusThreadManager::Initialize(); +#endif } void ShellBrowserMainParts::PreEarlyInitialization() { @@ -135,6 +142,12 @@ void ShellBrowserMainParts::PostMainMessageLoopRun() { desktop_controller_.reset(); } +void ShellBrowserMainParts::PostDestroyThreads() { +#if defined(OS_CHROMEOS) + chromeos::DBusThreadManager::Shutdown(); +#endif +} + void ShellBrowserMainParts::OnHostCloseRequested( const aura::WindowTreeHost* host) { desktop_controller_->CloseAppWindow(); diff --git a/apps/shell/browser/shell_browser_main_parts.h b/apps/shell/browser/shell_browser_main_parts.h index f5082e1..8ae3fe4 100644 --- a/apps/shell/browser/shell_browser_main_parts.h +++ b/apps/shell/browser/shell_browser_main_parts.h @@ -61,6 +61,7 @@ class ShellBrowserMainParts : public content::BrowserMainParts, virtual void PreMainMessageLoopRun() OVERRIDE; virtual bool MainMessageLoopRun(int* result_code) OVERRIDE; virtual void PostMainMessageLoopRun() OVERRIDE; + virtual void PostDestroyThreads() OVERRIDE; // aura::WindowTreeHostObserver overrides: virtual void OnHostCloseRequested(const aura::WindowTreeHost* host) OVERRIDE; diff --git a/apps/shell/browser/shell_desktop_controller.cc b/apps/shell/browser/shell_desktop_controller.cc index d369b5b..cc287c9 100644 --- a/apps/shell/browser/shell_desktop_controller.cc +++ b/apps/shell/browser/shell_desktop_controller.cc @@ -10,11 +10,14 @@ #include "ui/aura/test/test_screen.h" #include "ui/aura/window.h" #include "ui/aura/window_event_dispatcher.h" +#include "ui/aura/window_tree_host.h" #include "ui/base/ime/input_method_initializer.h" #include "ui/gfx/screen.h" +#include "ui/wm/core/user_activity_detector.h" #include "ui/wm/test/wm_test_helper.h" #if defined(OS_CHROMEOS) +#include "ui/chromeos/user_activity_power_manager_notifier.h" #include "ui/display/types/chromeos/display_mode.h" #include "ui/display/types/chromeos/display_snapshot.h" #endif @@ -69,6 +72,14 @@ ShellDesktopController::ShellDesktopController() { #endif CreateRootWindow(); + user_activity_detector_.reset(new wm::UserActivityDetector); + GetWindowTreeHost()->event_processor()->GetRootTarget()->AddPreTargetHandler( + user_activity_detector_.get()); +#if defined(OS_CHROMEOS) + user_activity_notifier_.reset( + new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get())); +#endif + g_instance = this; } @@ -76,6 +87,8 @@ ShellDesktopController::~ShellDesktopController() { // The app window must be explicitly closed before desktop teardown. DCHECK(!app_window_); g_instance = NULL; + GetWindowTreeHost()->event_processor()->GetRootTarget() + ->RemovePreTargetHandler(user_activity_detector_.get()); DestroyRootWindow(); aura::Env::DeleteInstance(); } @@ -108,7 +121,7 @@ aura::WindowTreeHost* ShellDesktopController::GetWindowTreeHost() { #if defined(OS_CHROMEOS) void ShellDesktopController::OnDisplayModeChanged( - const std::vector<ui::DisplayConfigurator::DisplayState>& outputs) { + const std::vector<ui::DisplayConfigurator::DisplayState>& displays) { gfx::Size size = GetPrimaryDisplaySize(); if (!size.IsEmpty()) wm_test_helper_->host()->UpdateRootWindowSize(size); @@ -143,11 +156,11 @@ void ShellDesktopController::DestroyRootWindow() { gfx::Size ShellDesktopController::GetPrimaryDisplaySize() { #if defined(OS_CHROMEOS) - const std::vector<ui::DisplayConfigurator::DisplayState>& states = + const std::vector<ui::DisplayConfigurator::DisplayState>& displays = display_configurator_->cached_displays(); - if (states.empty()) + if (displays.empty()) return gfx::Size(); - const ui::DisplayMode* mode = states[0].display->current_mode(); + const ui::DisplayMode* mode = displays[0].display->current_mode(); return mode ? mode->size() : gfx::Size(); #else return gfx::Size(); diff --git a/apps/shell/browser/shell_desktop_controller.h b/apps/shell/browser/shell_desktop_controller.h index 02b0a34..643f671 100644 --- a/apps/shell/browser/shell_desktop_controller.h +++ b/apps/shell/browser/shell_desktop_controller.h @@ -24,7 +24,14 @@ namespace content { class BrowserContext; } +#if defined(OS_CHROMEOS) +namespace ui { +class UserActivityPowerManagerNotifier; +} +#endif + namespace wm { +class UserActivityDetector; class WMTestHelper; } @@ -60,7 +67,7 @@ class ShellDesktopController #if defined(OS_CHROMEOS) // ui::DisplayConfigurator::Observer overrides. virtual void OnDisplayModeChanged(const std::vector< - ui::DisplayConfigurator::DisplayState>& outputs) OVERRIDE; + ui::DisplayConfigurator::DisplayState>& displays) OVERRIDE; #endif private: @@ -83,6 +90,11 @@ class ShellDesktopController scoped_ptr<aura::TestScreen> test_screen_; + scoped_ptr<wm::UserActivityDetector> user_activity_detector_; +#if defined(OS_CHROMEOS) + scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_; +#endif + // The desktop supports a single app window. scoped_ptr<ShellAppWindow> app_window_; diff --git a/ash/shell.cc b/ash/shell.cc index 6891419..2c0277f 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -132,7 +132,7 @@ #include "ash/system/chromeos/session/logout_confirmation_controller.h" #include "base/bind_helpers.h" #include "base/sys_info.h" -#include "ui/chromeos/user_activity_notifier.h" +#include "ui/chromeos/user_activity_power_manager_notifier.h" #include "ui/display/chromeos/display_configurator.h" #endif // defined(OS_CHROMEOS) @@ -1001,7 +1001,7 @@ void Shell::Init() { power_event_observer_.reset(new PowerEventObserver()); user_activity_notifier_.reset( - new ui::UserActivityNotifier(user_activity_detector_.get())); + new ui::UserActivityPowerManagerNotifier(user_activity_detector_.get())); video_activity_notifier_.reset( new VideoActivityNotifier(video_detector_.get())); bluetooth_notification_controller_.reset(new BluetoothNotificationController); diff --git a/ash/shell.h b/ash/shell.h index 56af8d1..90746c8 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -51,7 +51,7 @@ class Rect; namespace ui { class DisplayConfigurator; class Layer; -class UserActivityNotifier; +class UserActivityPowerManagerNotifier; } namespace views { class NonClientFrameView; @@ -689,7 +689,7 @@ class ASH_EXPORT Shell : public SystemModalContainerEventFilterDelegate, #if defined(OS_CHROMEOS) scoped_ptr<PowerEventObserver> power_event_observer_; - scoped_ptr<ui::UserActivityNotifier> user_activity_notifier_; + scoped_ptr<ui::UserActivityPowerManagerNotifier> user_activity_notifier_; scoped_ptr<VideoActivityNotifier> video_activity_notifier_; scoped_ptr<StickyKeysController> sticky_keys_controller_; scoped_ptr<ResolutionNotificationController> diff --git a/ui/chromeos/ui_chromeos.gyp b/ui/chromeos/ui_chromeos.gyp index e276880..7f7362e 100644 --- a/ui/chromeos/ui_chromeos.gyp +++ b/ui/chromeos/ui_chromeos.gyp @@ -19,8 +19,8 @@ 'UI_CHROMEOS_IMPLEMENTATION', ], 'sources': [ - 'user_activity_notifier.cc', - 'user_activity_notifier.h', + 'user_activity_power_manager_notifier.cc', + 'user_activity_power_manager_notifier.h', ], }, ], diff --git a/ui/chromeos/user_activity_notifier.cc b/ui/chromeos/user_activity_power_manager_notifier.cc index 53f3129..7952b59 100644 --- a/ui/chromeos/user_activity_notifier.cc +++ b/ui/chromeos/user_activity_power_manager_notifier.cc @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "ui/chromeos/user_activity_notifier.h" +#include "ui/chromeos/user_activity_power_manager_notifier.h" #include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/power_manager_client.h" @@ -41,16 +41,17 @@ power_manager::UserActivityType GetUserActivityTypeForEvent( } // namespace -UserActivityNotifier::UserActivityNotifier(::wm::UserActivityDetector* detector) +UserActivityPowerManagerNotifier::UserActivityPowerManagerNotifier( + ::wm::UserActivityDetector* detector) : detector_(detector) { detector_->AddObserver(this); } -UserActivityNotifier::~UserActivityNotifier() { +UserActivityPowerManagerNotifier::~UserActivityPowerManagerNotifier() { detector_->RemoveObserver(this); } -void UserActivityNotifier::OnUserActivity(const Event* event) { +void UserActivityPowerManagerNotifier::OnUserActivity(const Event* event) { base::TimeTicks now = base::TimeTicks::Now(); // InSeconds() truncates rather than rounding, so it's fine for this // comparison. diff --git a/ui/chromeos/user_activity_notifier.h b/ui/chromeos/user_activity_power_manager_notifier.h index dab5955..483f1b5 100644 --- a/ui/chromeos/user_activity_notifier.h +++ b/ui/chromeos/user_activity_power_manager_notifier.h @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef UI_CHROMEOS_USER_ACTIVITY_NOTIFIER_H_ -#define UI_CHROMEOS_USER_ACTIVITY_NOTIFIER_H_ +#ifndef UI_CHROMEOS_USER_ACTIVITY_POWER_MANAGER_NOTIFIER_H_ +#define UI_CHROMEOS_USER_ACTIVITY_POWER_MANAGER_NOTIFIER_H_ #include "base/basictypes.h" #include "base/compiler_specific.h" @@ -18,11 +18,12 @@ class UserActivityDetector; namespace ui { // Notifies the power manager when the user is active. -class UI_CHROMEOS_EXPORT UserActivityNotifier +class UI_CHROMEOS_EXPORT UserActivityPowerManagerNotifier : public ::wm::UserActivityObserver { public: - explicit UserActivityNotifier(::wm::UserActivityDetector* detector); - virtual ~UserActivityNotifier(); + explicit UserActivityPowerManagerNotifier( + ::wm::UserActivityDetector* detector); + virtual ~UserActivityPowerManagerNotifier(); // UserActivityObserver implementation. virtual void OnUserActivity(const Event* event) OVERRIDE; @@ -33,9 +34,9 @@ class UI_CHROMEOS_EXPORT UserActivityNotifier // Last time that the power manager was notified. base::TimeTicks last_notify_time_; - DISALLOW_COPY_AND_ASSIGN(UserActivityNotifier); + DISALLOW_COPY_AND_ASSIGN(UserActivityPowerManagerNotifier); }; } // namespace ui -#endif // UI_CHROMEOS_USER_ACTIVITY_NOTIFIER_H_ +#endif // UI_CHROMEOS_USER_ACTIVITY_POWER_MANAGER_NOTIFIER_H_ |