diff options
author | dzhioev@chromium.org <dzhioev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-17 17:56:40 +0000 |
---|---|---|
committer | dzhioev@chromium.org <dzhioev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-17 17:56:40 +0000 |
commit | 59ccadef728a9c8e317d345c22d1cecbe201aaa1 (patch) | |
tree | 0875b840b36ebb7c47154f96eecf2607ab373df3 | |
parent | 19fa62bf62e3e5f21a67502d0c6a346e1ed356bc (diff) | |
download | chromium_src-59ccadef728a9c8e317d345c22d1cecbe201aaa1.zip chromium_src-59ccadef728a9c8e317d345c22d1cecbe201aaa1.tar.gz chromium_src-59ccadef728a9c8e317d345c22d1cecbe201aaa1.tar.bz2 |
Created ash::FirstRunHelper.
FirstRunHelper is an interface providing API for manipulating and retreiving
information about Shell elements. It will be used by new first-run tutorial.
BUG=269286
Review URL: https://codereview.chromium.org/26277006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229175 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | ash/ash.gyp | 4 | ||||
-rw-r--r-- | ash/first_run/first_run_helper.cc | 13 | ||||
-rw-r--r-- | ash/first_run/first_run_helper.h | 46 | ||||
-rw-r--r-- | ash/first_run/first_run_helper_impl.cc | 49 | ||||
-rw-r--r-- | ash/first_run/first_run_helper_impl.h | 33 | ||||
-rw-r--r-- | ash/shell.cc | 11 | ||||
-rw-r--r-- | ash/shell.h | 13 | ||||
-rw-r--r-- | ash/wm/app_list_controller.h | 3 |
8 files changed, 172 insertions, 0 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp index baa8015..bbb8a8a 100644 --- a/ash/ash.gyp +++ b/ash/ash.gyp @@ -131,6 +131,10 @@ 'drag_drop/drag_image_view.cc', 'drag_drop/drag_image_view.h', 'event_rewriter_delegate.h', + 'first_run/first_run_helper.cc', + 'first_run/first_run_helper.h', + 'first_run/first_run_helper_impl.cc', + 'first_run/first_run_helper_impl.h', 'focus_cycler.cc', 'focus_cycler.h', 'high_contrast/high_contrast_controller.cc', diff --git a/ash/first_run/first_run_helper.cc b/ash/first_run/first_run_helper.cc new file mode 100644 index 0000000..684bb39 --- /dev/null +++ b/ash/first_run/first_run_helper.cc @@ -0,0 +1,13 @@ +// 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/first_run/first_run_helper.h" + +namespace ash { + +FirstRunHelper::FirstRunHelper() {} +FirstRunHelper::~FirstRunHelper() {} + +} // namespace chromeos + diff --git a/ash/first_run/first_run_helper.h b/ash/first_run/first_run_helper.h new file mode 100644 index 0000000..b1bacb6 --- /dev/null +++ b/ash/first_run/first_run_helper.h @@ -0,0 +1,46 @@ +// 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_FIRST_RUN_FIRST_RUN_HELPER_H_ +#define ASH_FIRST_RUN_FIRST_RUN_HELPER_H_ + +#include "ash/ash_export.h" +#include "base/basictypes.h" + +namespace gfx { +class Rect; +} + +namespace ash { + +// Interface used by first-run tutorial to manipulate and retreive information +// about shell elements. +// All returned coordinates are in screen coordinate system. +class ASH_EXPORT FirstRunHelper { + public: + FirstRunHelper(); + virtual ~FirstRunHelper(); + + // Opens and closes app list. + virtual void OpenAppList() = 0; + virtual void CloseAppList() = 0; + + // Returns bounding rectangle of launcher elements. + virtual gfx::Rect GetLauncherBounds() = 0; + + // Returns bounds of application list button. + virtual gfx::Rect GetAppListButtonBounds() = 0; + + // Returns bounds of application list. You must open application list before + // calling this method. + virtual gfx::Rect GetAppListBounds() = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(FirstRunHelper); +}; + +} // namespace ash + +#endif // ASH_FIRST_RUN_FIRST_RUN_HELPER_H_ + diff --git a/ash/first_run/first_run_helper_impl.cc b/ash/first_run/first_run_helper_impl.cc new file mode 100644 index 0000000..6246e12 --- /dev/null +++ b/ash/first_run/first_run_helper_impl.cc @@ -0,0 +1,49 @@ +// 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/first_run/first_run_helper_impl.h" + +#include "ash/launcher/launcher.h" +#include "ash/shell.h" +#include "base/logging.h" +#include "ui/app_list/views/app_list_view.h" +#include "ui/aura/window.h" +#include "ui/gfx/rect.h" +#include "ui/views/view.h" + +namespace ash { + +FirstRunHelperImpl::FirstRunHelperImpl() {} + +void FirstRunHelperImpl::OpenAppList() { + if (Shell::GetInstance()->GetAppListTargetVisibility()) + return; + Shell::GetInstance()->ToggleAppList(NULL); +} + +void FirstRunHelperImpl::CloseAppList() { + if (!Shell::GetInstance()->GetAppListTargetVisibility()) + return; + Shell::GetInstance()->ToggleAppList(NULL); +} + +gfx::Rect FirstRunHelperImpl::GetLauncherBounds() { + ash::Launcher* launcher = ash::Launcher::ForPrimaryDisplay(); + return launcher->GetVisibleItemsBoundsInScreen(); +} + +gfx::Rect FirstRunHelperImpl::GetAppListButtonBounds() { + ash::Launcher* launcher = ash::Launcher::ForPrimaryDisplay(); + views::View* app_button = launcher->GetAppListButtonView(); + return app_button->GetBoundsInScreen(); +} + +gfx::Rect FirstRunHelperImpl::GetAppListBounds() { + app_list::AppListView* view = Shell::GetInstance()->GetAppListView(); + CHECK(view); + return view->GetBoundsInScreen(); +} + +} // namespace ash + diff --git a/ash/first_run/first_run_helper_impl.h b/ash/first_run/first_run_helper_impl.h new file mode 100644 index 0000000..5290d59 --- /dev/null +++ b/ash/first_run/first_run_helper_impl.h @@ -0,0 +1,33 @@ +// 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_FIRST_RUN_FIRST_RUN_HELPER_IMPL_H_ +#define ASH_FIRST_RUN_FIRST_RUN_HELPER_IMPL_H_ + +#include "ash/first_run/first_run_helper.h" +#include "base/compiler_specific.h" + +namespace ash { + +class Shell; + +class FirstRunHelperImpl : public FirstRunHelper { + public: + FirstRunHelperImpl(); + + // Overriden from FirstRunHelper. + virtual void OpenAppList() OVERRIDE; + virtual void CloseAppList() OVERRIDE; + virtual gfx::Rect GetLauncherBounds() OVERRIDE; + virtual gfx::Rect GetAppListButtonBounds() OVERRIDE; + virtual gfx::Rect GetAppListBounds() OVERRIDE; + + private: + DISALLOW_COPY_AND_ASSIGN(FirstRunHelperImpl); +}; + +} // namespace ash + +#endif // ASH_FIRST_RUN_FIRST_RUN_HELPER_IMPL_H_ + diff --git a/ash/shell.cc b/ash/shell.cc index deae2eb..6a37652 100644 --- a/ash/shell.cc +++ b/ash/shell.cc @@ -24,6 +24,7 @@ #include "ash/display/resolution_notification_controller.h" #include "ash/display/screen_position_controller.h" #include "ash/drag_drop/drag_drop_controller.h" +#include "ash/first_run/first_run_helper_impl.h" #include "ash/focus_cycler.h" #include "ash/high_contrast/high_contrast_controller.h" #include "ash/host/root_window_host_factory.h" @@ -288,6 +289,10 @@ aura::Window* Shell::GetAppListWindow() { return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL; } +app_list::AppListView* Shell::GetAppListView() { + return app_list_controller_.get() ? app_list_controller_->GetView() : NULL; +} + bool Shell::IsSystemModalWindowOpen() const { if (simulate_modal_window_open_for_testing_) return true; @@ -516,6 +521,12 @@ void Shell::SetTouchHudProjectionEnabled(bool enabled) { OnTouchHudProjectionToggled(enabled)); } +#if defined(OS_CHROMEOS) +ash::FirstRunHelper* Shell::CreateFirstRunHelper() { + return new ash::FirstRunHelperImpl; +} +#endif // defined(OS_CHROMEOS) + void Shell::DoInitialWorkspaceAnimation() { return GetPrimaryRootWindowController()->workspace_controller()-> DoInitialAnimation(); diff --git a/ash/shell.h b/ash/shell.h index 750d7d6..4e8658c 100644 --- a/ash/shell.h +++ b/ash/shell.h @@ -27,6 +27,9 @@ class CommandLine; +namespace app_list { +class AppListView; +} namespace aura { class EventFilter; class RootWindow; @@ -78,6 +81,7 @@ class AutoclickController; class CapsLockDelegate; class DesktopBackgroundController; class DisplayController; +class FirstRunHelper; class HighContrastController; class Launcher; class LauncherDelegate; @@ -234,6 +238,9 @@ class ASH_EXPORT Shell // Returns app list window or NULL if it is not visible. aura::Window* GetAppListWindow(); + // Returns app list view or NULL if it is not visible. + app_list::AppListView* GetAppListView(); + // Returns true if a system-modal dialog window is currently open. bool IsSystemModalWindowOpen() const; @@ -496,6 +503,12 @@ class ASH_EXPORT Shell return is_touch_hud_projection_enabled_; } +#if defined(OS_CHROMEOS) + // Creates instance of FirstRunHelper. Caller is responsible for deleting + // returned object. + ash::FirstRunHelper* CreateFirstRunHelper(); +#endif // defined(OS_CHROMEOS) + private: FRIEND_TEST_ALL_PREFIXES(ExtendedDesktopTest, TestCursor); FRIEND_TEST_ALL_PREFIXES(WindowManagerTest, MouseEventCursors); diff --git a/ash/wm/app_list_controller.h b/ash/wm/app_list_controller.h index 3475697..f47c7a4 100644 --- a/ash/wm/app_list_controller.h +++ b/ash/wm/app_list_controller.h @@ -66,6 +66,9 @@ class AppListController : public ui::EventHandler, // Returns app list window or NULL if it is not visible. aura::Window* GetWindow(); + // Returns app list view or NULL if it is not visible. + app_list::AppListView* GetView() { return view_; } + private: friend class test::AppListControllerTestApi; |