summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-09 04:11:45 +0000
committerxiyuan@chromium.org <xiyuan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-09 04:11:45 +0000
commit0039db9b4f365a4c6b1bbd72b4ca4e2aeb65c354 (patch)
tree5a50f8caa29ce4038da05b20f18161887c3c8fc3
parenteb951d02de207130faca3a648d481108c97a8525 (diff)
downloadchromium_src-0039db9b4f365a4c6b1bbd72b4ca4e2aeb65c354.zip
chromium_src-0039db9b4f365a4c6b1bbd72b4ca4e2aeb65c354.tar.gz
chromium_src-0039db9b4f365a4c6b1bbd72b4ca4e2aeb65c354.tar.bz2
Move app list from ash to ui.
The goal is to make app list an independent component so that it could be reused in elsewhere. BUG=none. TEST=none. Review URL: https://chromiumcodereview.appspot.com/10388032 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135981 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--ash/ash.gyp30
-rw-r--r--ash/shell.cc18
-rw-r--r--ash/shell.h6
-rw-r--r--ash/shell/app_list.cc30
-rw-r--r--ash/shell/example_factory.h6
-rw-r--r--ash/shell/shell_delegate_impl.cc2
-rw-r--r--ash/shell/shell_delegate_impl.h2
-rw-r--r--ash/shell_delegate.h7
-rw-r--r--ash/test/test_shell_delegate.cc2
-rw-r--r--ash/test/test_shell_delegate.h2
-rw-r--r--ash/wm/app_list_controller.cc (renamed from ash/app_list/app_list.cc)136
-rw-r--r--ash/wm/app_list_controller.h (renamed from ash/app_list/app_list.h)38
-rw-r--r--chrome/browser/ui/views/ash/app_list/app_list_model_builder.cc8
-rw-r--r--chrome/browser/ui/views/ash/app_list/app_list_model_builder.h13
-rw-r--r--chrome/browser/ui/views/ash/app_list/app_list_model_builder_unittest.cc15
-rw-r--r--chrome/browser/ui/views/ash/app_list/app_list_view_delegate.cc11
-rw-r--r--chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h13
-rw-r--r--chrome/browser/ui/views/ash/app_list/chrome_app_list_item.h4
-rw-r--r--chrome/browser/ui/views/ash/app_list/extension_app_item.cc2
-rw-r--r--chrome/browser/ui/views/ash/app_list/extension_app_item.h2
-rw-r--r--chrome/browser/ui/views/ash/chrome_shell_delegate.cc2
-rw-r--r--chrome/browser/ui/views/ash/chrome_shell_delegate.h2
-rw-r--r--chrome/chrome_browser.gypi1
-rw-r--r--ui/app_list/DEPS6
-rw-r--r--ui/app_list/OWNERS (renamed from ash/app_list/OWNERS)0
-rw-r--r--ui/app_list/app_list.gyp70
-rw-r--r--ui/app_list/app_list_bubble_border.cc (renamed from ash/app_list/app_list_bubble_border.cc)6
-rw-r--r--ui/app_list/app_list_bubble_border.h (renamed from ash/app_list/app_list_bubble_border.h)10
-rw-r--r--ui/app_list/app_list_export.h30
-rw-r--r--ui/app_list/app_list_item_model.cc (renamed from ash/app_list/app_list_item_model.cc)8
-rw-r--r--ui/app_list/app_list_item_model.h (renamed from ash/app_list/app_list_item_model.h)14
-rw-r--r--ui/app_list/app_list_item_model_observer.h (renamed from ash/app_list/app_list_item_model_observer.h)14
-rw-r--r--ui/app_list/app_list_item_view.cc (renamed from ash/app_list/app_list_item_view.cc)21
-rw-r--r--ui/app_list/app_list_item_view.h (renamed from ash/app_list/app_list_item_view.h)22
-rw-r--r--ui/app_list/app_list_model.cc (renamed from ash/app_list/app_list_model.cc)6
-rw-r--r--ui/app_list/app_list_model.h (renamed from ash/app_list/app_list_model.h)16
-rw-r--r--ui/app_list/app_list_model_view.cc (renamed from ash/app_list/app_list_model_view.cc)14
-rw-r--r--ui/app_list/app_list_model_view.h (renamed from ash/app_list/app_list_model_view.h)20
-rw-r--r--ui/app_list/app_list_model_view_unittest.cc (renamed from ash/app_list/app_list_unittest.cc)23
-rw-r--r--ui/app_list/app_list_view.cc (renamed from ash/app_list/app_list_view.cc)141
-rw-r--r--ui/app_list/app_list_view.h (renamed from ash/app_list/app_list_view.h)32
-rw-r--r--ui/app_list/app_list_view_delegate.h (renamed from ash/app_list/app_list_view_delegate.h)17
-rw-r--r--ui/app_list/drop_shadow_label.cc (renamed from ash/app_list/drop_shadow_label.cc)6
-rw-r--r--ui/app_list/drop_shadow_label.h (renamed from ash/app_list/drop_shadow_label.h)10
-rw-r--r--ui/app_list/icon_cache.cc (renamed from ash/app_list/icon_cache.cc)6
-rw-r--r--ui/app_list/icon_cache.h (renamed from ash/app_list/icon_cache.h)13
-rw-r--r--ui/app_list/page_switcher.cc (renamed from ash/app_list/page_switcher.cc)10
-rw-r--r--ui/app_list/page_switcher.h (renamed from ash/app_list/page_switcher.h)12
-rw-r--r--ui/app_list/pagination_model.cc (renamed from ash/app_list/pagination_model.cc)8
-rw-r--r--ui/app_list/pagination_model.h (renamed from ash/app_list/pagination_model.h)14
-rw-r--r--ui/app_list/pagination_model_observer.h (renamed from ash/app_list/pagination_model_observer.h)14
-rw-r--r--ui/app_list/run_all_unittests.cc9
52 files changed, 548 insertions, 376 deletions
diff --git a/ash/ash.gyp b/ash/ash.gyp
index 189cfb8..9b53f00 100644
--- a/ash/ash.gyp
+++ b/ash/ash.gyp
@@ -25,6 +25,7 @@
'../skia/skia.gyp:skia',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
+ '../ui/app_list/app_list.gyp:app_list',
'../ui/aura/aura.gyp:aura',
'../ui/base/strings/ui_strings.gyp:ui_strings',
'../ui/compositor/compositor.gyp:compositor',
@@ -49,31 +50,6 @@
'accelerators/accelerator_table.h',
'accelerators/nested_dispatcher_controller.cc',
'accelerators/nested_dispatcher_controller.h',
- 'app_list/app_list.cc',
- 'app_list/app_list.h',
- 'app_list/app_list_bubble_border.cc',
- 'app_list/app_list_bubble_border.h',
- 'app_list/app_list_item_model.cc',
- 'app_list/app_list_item_model.h',
- 'app_list/app_list_item_model_observer.h',
- 'app_list/app_list_item_view.cc',
- 'app_list/app_list_item_view.h',
- 'app_list/app_list_model.cc',
- 'app_list/app_list_model.h',
- 'app_list/app_list_model_view.cc',
- 'app_list/app_list_model_view.h',
- 'app_list/app_list_view.cc',
- 'app_list/app_list_view.h',
- 'app_list/app_list_view_delegate.h',
- 'app_list/drop_shadow_label.cc',
- 'app_list/drop_shadow_label.h',
- 'app_list/icon_cache.cc',
- 'app_list/icon_cache.h',
- 'app_list/page_switcher.cc',
- 'app_list/page_switcher.h',
- 'app_list/pagination_model.cc',
- 'app_list/pagination_model.h',
- 'app_list/pagination_model_observer.h',
'ash_switches.cc',
'ash_switches.h',
'caps_lock_delegate.h',
@@ -196,6 +172,8 @@
'tooltips/tooltip_controller.cc',
'tooltips/tooltip_controller.h',
'volume_control_delegate.h',
+ 'wm/app_list_controller.cc',
+ 'wm/app_list_controller.h',
'wm/activation_controller.cc',
'wm/activation_controller.h',
'wm/always_on_top_controller.cc',
@@ -361,7 +339,6 @@
'accelerators/accelerator_filter_unittest.cc',
'accelerators/accelerator_table_unittest.cc',
'accelerators/nested_dispatcher_controller_unittest.cc',
- 'app_list/app_list_unittest.cc',
'dip_unittest.cc',
'drag_drop/drag_drop_controller_unittest.cc',
'focus_cycler_unittest.cc',
@@ -465,6 +442,7 @@
'../skia/skia.gyp:skia',
'../third_party/icu/icu.gyp:icui18n',
'../third_party/icu/icu.gyp:icuuc',
+ '../ui/app_list/app_list.gyp:app_list',
'../ui/aura/aura.gyp:aura',
'../ui/compositor/compositor.gyp:compositor',
'../ui/compositor/compositor.gyp:compositor_test_support',
diff --git a/ash/shell.cc b/ash/shell.cc
index 19944f2..6799e0e 100644
--- a/ash/shell.cc
+++ b/ash/shell.cc
@@ -5,8 +5,8 @@
#include "ash/shell.h"
#include <algorithm>
+#include <string>
-#include "ash/app_list/app_list.h"
#include "ash/ash_switches.h"
#include "ash/desktop_background/desktop_background_controller.h"
#include "ash/desktop_background/desktop_background_resources.h"
@@ -29,6 +29,7 @@
#include "ash/system/tray/system_tray_delegate.h"
#include "ash/tooltips/tooltip_controller.h"
#include "ash/wm/activation_controller.h"
+#include "ash/wm/app_list_controller.h"
#include "ash/wm/base_layout_manager.h"
#include "ash/wm/custom_frame_view_ash.h"
#include "ash/wm/dialog_frame_view.h"
@@ -66,7 +67,6 @@
#include "ui/aura/env.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/monitor_manager.h"
-#include "ui/aura/monitor_manager.h"
#include "ui/aura/root_window.h"
#include "ui/aura/ui_controls_aura.h"
#include "ui/aura/window.h"
@@ -241,7 +241,7 @@ class DummyUserWallpaperDelegate : public UserWallpaperDelegate {
}
private:
- DISALLOW_COPY_AND_ASSIGN(DummyUserWallpaperDelegate);
+ DISALLOW_COPY_AND_ASSIGN(DummyUserWallpaperDelegate);
};
class DummySystemTrayDelegate : public SystemTrayDelegate {
@@ -258,7 +258,6 @@ class DummySystemTrayDelegate : public SystemTrayDelegate {
virtual ~DummySystemTrayDelegate() {}
private:
-
virtual bool GetTrayVisibilityOnStartup() OVERRIDE { return true; }
// Overridden from SystemTrayDelegate:
@@ -774,17 +773,18 @@ void Shell::ShowBackgroundMenu(views::Widget* widget,
}
void Shell::ToggleAppList() {
- if (!app_list_.get())
- app_list_.reset(new internal::AppList);
- app_list_->SetVisible(!app_list_->IsVisible());
+ if (!app_list_controller_.get())
+ app_list_controller_.reset(new internal::AppListController);
+ app_list_controller_->SetVisible(!app_list_controller_->IsVisible());
}
bool Shell::GetAppListTargetVisibility() const {
- return app_list_.get() && app_list_->GetTargetVisibility();
+ return app_list_controller_.get() &&
+ app_list_controller_->GetTargetVisibility();
}
aura::Window* Shell::GetAppListWindow() {
- return app_list_.get() ? app_list_->GetWindow() : NULL;
+ return app_list_controller_.get() ? app_list_controller_->GetWindow() : NULL;
}
bool Shell::IsScreenLocked() const {
diff --git a/ash/shell.h b/ash/shell.h
index 2f47db3..8ec275b 100644
--- a/ash/shell.h
+++ b/ash/shell.h
@@ -62,9 +62,9 @@ class VideoDetector;
class WindowCycleController;
namespace internal {
-class ActivationController;
class AcceleratorFilter;
-class AppList;
+class ActivationController;
+class AppListController;
class DragDropController;
class EventClientImpl;
class FocusCycler;
@@ -323,7 +323,7 @@ class ASH_EXPORT Shell {
scoped_ptr<Launcher> launcher_;
- scoped_ptr<internal::AppList> app_list_;
+ scoped_ptr<internal::AppListController> app_list_controller_;
scoped_ptr<internal::ShellContextMenu> shell_context_menu_;
scoped_ptr<internal::StackingController> stacking_controller_;
diff --git a/ash/shell/app_list.cc b/ash/shell/app_list.cc
index 2e4fd77..4430e7b 100644
--- a/ash/shell/app_list.cc
+++ b/ash/shell/app_list.cc
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/app_list/app_list_item_model.h"
-#include "ash/app_list/app_list_item_view.h"
-#include "ash/app_list/app_list_model.h"
-#include "ash/app_list/app_list_view.h"
-#include "ash/app_list/app_list_view_delegate.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell/example_factory.h"
#include "ash/shell/toplevel_window.h"
#include "base/basictypes.h"
+#include "ui/app_list/app_list_item_model.h"
+#include "ui/app_list/app_list_item_view.h"
+#include "ui/app_list/app_list_model.h"
+#include "ui/app_list/app_list_view.h"
+#include "ui/app_list/app_list_view_delegate.h"
#include "ui/views/examples/examples_window.h"
namespace ash {
@@ -19,7 +19,7 @@ namespace shell {
namespace {
-class WindowTypeLauncherItem : public ash::AppListItemModel {
+class WindowTypeLauncherItem : public app_list::AppListItemModel {
public:
enum Type {
TOPLEVEL_WINDOW = 0,
@@ -30,7 +30,7 @@ class WindowTypeLauncherItem : public ash::AppListItemModel {
LAST_TYPE,
};
- WindowTypeLauncherItem(Type type) : type_(type) {
+ explicit WindowTypeLauncherItem(Type type) : type_(type) {
SetIcon(GetIcon(type));
SetTitle(GetTitle(type));
}
@@ -108,13 +108,13 @@ class WindowTypeLauncherItem : public ash::AppListItemModel {
DISALLOW_COPY_AND_ASSIGN(WindowTypeLauncherItem);
};
-class ExampleAppListViewDelegate : public ash::AppListViewDelegate {
+class ExampleAppListViewDelegate : public app_list::AppListViewDelegate {
public:
ExampleAppListViewDelegate() : model_(NULL) {}
private:
// Overridden from ash::AppListViewDelegate:
- virtual void SetModel(AppListModel* model) OVERRIDE {
+ virtual void SetModel(app_list::AppListModel* model) OVERRIDE {
model_ = model;
}
@@ -133,19 +133,25 @@ class ExampleAppListViewDelegate : public ash::AppListViewDelegate {
}
}
- virtual void OnAppListItemActivated(ash::AppListItemModel* item,
+ virtual void OnAppListItemActivated(app_list::AppListItemModel* item,
int event_flags) OVERRIDE {
static_cast<WindowTypeLauncherItem*>(item)->Activate(event_flags);
}
- AppListModel* model_;
+ virtual void Close() OVERRIDE {
+ DCHECK(ash::Shell::HasInstance());
+ if (Shell::GetInstance()->GetAppListTargetVisibility())
+ Shell::GetInstance()->ToggleAppList();
+ }
+
+ app_list::AppListModel* model_;
DISALLOW_COPY_AND_ASSIGN(ExampleAppListViewDelegate);
};
} // namespace
-ash::AppListViewDelegate* CreateAppListViewDelegate() {
+app_list::AppListViewDelegate* CreateAppListViewDelegate() {
return new ExampleAppListViewDelegate;
}
diff --git a/ash/shell/example_factory.h b/ash/shell/example_factory.h
index 225a2fb..7ce4f5f 100644
--- a/ash/shell/example_factory.h
+++ b/ash/shell/example_factory.h
@@ -6,7 +6,7 @@
#define ASH_SHELL_EXAMPLE_FACTORY_H_
#pragma once
-namespace ash {
+namespace app_list {
class AppListModel;
class AppListViewDelegate;
}
@@ -25,9 +25,9 @@ void CreateLockScreen();
// Creates a window showing samples of commonly used widgets.
void CreateWidgetsWindow();
-void BuildAppListModel(ash::AppListModel* model);
+void BuildAppListModel(app_list::AppListModel* model);
-ash::AppListViewDelegate* CreateAppListViewDelegate();
+app_list::AppListViewDelegate* CreateAppListViewDelegate();
} // namespace shell
} // namespace ash
diff --git a/ash/shell/shell_delegate_impl.cc b/ash/shell/shell_delegate_impl.cc
index 31edb6a..f1d52bb 100644
--- a/ash/shell/shell_delegate_impl.cc
+++ b/ash/shell/shell_delegate_impl.cc
@@ -82,7 +82,7 @@ content::BrowserContext* ShellDelegateImpl::GetCurrentBrowserContext() {
void ShellDelegateImpl::ToggleSpokenFeedback() {
}
-ash::AppListViewDelegate* ShellDelegateImpl::CreateAppListViewDelegate() {
+app_list::AppListViewDelegate* ShellDelegateImpl::CreateAppListViewDelegate() {
return ash::shell::CreateAppListViewDelegate();
}
diff --git a/ash/shell/shell_delegate_impl.h b/ash/shell/shell_delegate_impl.h
index 71b65b2..de999f8 100644
--- a/ash/shell/shell_delegate_impl.h
+++ b/ash/shell/shell_delegate_impl.h
@@ -35,7 +35,7 @@ class ShellDelegateImpl : public ash::ShellDelegate {
virtual void OpenMobileSetup() OVERRIDE;
virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE;
virtual void ToggleSpokenFeedback() OVERRIDE;
- virtual ash::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
+ virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
virtual void StartPartialScreenshot(
ash::ScreenshotDelegate* screenshot_delegate) OVERRIDE;
virtual ash::LauncherDelegate* CreateLauncherDelegate(
diff --git a/ash/shell_delegate.h b/ash/shell_delegate.h
index 43c1593..ce857f8 100644
--- a/ash/shell_delegate.h
+++ b/ash/shell_delegate.h
@@ -13,6 +13,10 @@
#include "base/callback.h"
#include "base/string16.h"
+namespace app_list {
+class AppListViewDelegate;
+}
+
namespace aura {
class Window;
}
@@ -23,7 +27,6 @@ class Widget;
namespace ash {
-class AppListViewDelegate;
class LauncherDelegate;
class LauncherModel;
struct LauncherItem;
@@ -80,7 +83,7 @@ class ASH_EXPORT ShellDelegate {
// Invoked to create an AppListViewDelegate. Shell takes the ownership of
// the created delegate.
- virtual AppListViewDelegate* CreateAppListViewDelegate() = 0;
+ virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() = 0;
// Invoked to start taking partial screenshot.
virtual void StartPartialScreenshot(
diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc
index 0dcd167..56f208b 100644
--- a/ash/test/test_shell_delegate.cc
+++ b/ash/test/test_shell_delegate.cc
@@ -67,7 +67,7 @@ content::BrowserContext* TestShellDelegate::GetCurrentBrowserContext() {
void TestShellDelegate::ToggleSpokenFeedback() {
}
-AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() {
+app_list::AppListViewDelegate* TestShellDelegate::CreateAppListViewDelegate() {
return NULL;
}
diff --git a/ash/test/test_shell_delegate.h b/ash/test/test_shell_delegate.h
index 1c13794..d59972d 100644
--- a/ash/test/test_shell_delegate.h
+++ b/ash/test/test_shell_delegate.h
@@ -31,7 +31,7 @@ class TestShellDelegate : public ShellDelegate {
virtual void OpenMobileSetup() OVERRIDE;
virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE;
virtual void ToggleSpokenFeedback() OVERRIDE;
- virtual AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
+ virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
virtual void StartPartialScreenshot(
ScreenshotDelegate* screenshot_delegate) OVERRIDE;
virtual LauncherDelegate* CreateLauncherDelegate(
diff --git a/ash/app_list/app_list.cc b/ash/wm/app_list_controller.cc
index f5fae714..9e7f895 100644
--- a/ash/app_list/app_list.cc
+++ b/ash/wm/app_list_controller.cc
@@ -2,22 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/app_list/app_list.h"
+#include "ash/wm/app_list_controller.h"
-#include "ash/app_list/app_list_view.h"
-#include "ash/app_list/icon_cache.h"
#include "ash/ash_switches.h"
+#include "ash/screen_ash.h"
#include "ash/shell.h"
#include "ash/shell_delegate.h"
#include "ash/shell_window_ids.h"
#include "ash/wm/shelf_layout_manager.h"
#include "ash/wm/window_util.h"
#include "base/command_line.h"
+#include "ui/app_list/app_list_view.h"
+#include "ui/app_list/icon_cache.h"
#include "ui/aura/event.h"
#include "ui/aura/root_window.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
+#include "ui/gfx/screen.h"
#include "ui/gfx/transform_util.h"
namespace ash {
@@ -37,27 +39,44 @@ ui::Layer* GetLayer(views::Widget* widget) {
return widget->GetNativeView()->layer();
}
+// Bounds returned is used for full screen app list. Use full monitor rect
+// so that the app list shade goes behind the launcher.
+gfx::Rect GetFullScreenBoundsForWidget(views::Widget* widget) {
+ gfx::NativeView window = widget->GetNativeView();
+ return gfx::Screen::GetMonitorNearestWindow(window).bounds();
+}
+
+// Return work area rect for full screen app list layout. This function is
+// needed to get final work area in one shot instead of waiting for shelf
+// animation to finish.
+gfx::Rect GetWorkAreaBoundsForWidget(views::Widget* widget) {
+ gfx::NativeView window = widget->GetNativeView();
+ return Shell::GetInstance()->shelf()->IsVisible() ?
+ ScreenAsh::GetUnmaximizedWorkAreaBounds(window) :
+ gfx::Screen::GetMonitorNearestWindow(window).work_area();
+}
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
-// AppList, public:
+// AppListController, public:
-AppList::AppList() : is_visible_(false), view_(NULL) {
- IconCache::CreateInstance();
+AppListController::AppListController() : is_visible_(false), view_(NULL) {
+ app_list::IconCache::CreateInstance();
}
-AppList::~AppList() {
+AppListController::~AppListController() {
ResetView();
- IconCache::DeleteInstance();
+ app_list::IconCache::DeleteInstance();
}
// static
-bool AppList::UseAppListV2() {
+bool AppListController::UseAppListV2() {
return CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableAppListV2);
}
-void AppList::SetVisible(bool visible) {
+void AppListController::SetVisible(bool visible) {
if (visible == is_visible_)
return;
@@ -72,27 +91,40 @@ void AppList::SetVisible(bool visible) {
} else if (is_visible_) {
// AppListModel and AppListViewDelegate are owned by AppListView. They
// will be released with AppListView on close.
- SetView(new AppListView(
- Shell::GetInstance()->delegate()->CreateAppListViewDelegate()));
+ app_list::AppListView* view = new app_list::AppListView(
+ Shell::GetInstance()->delegate()->CreateAppListViewDelegate());
+ if (UseAppListV2()) {
+ view->InitAsBubble(
+ Shell::GetInstance()->GetContainer(kShellWindowId_AppListContainer),
+ Shell::GetInstance()->launcher()->GetAppListButtonView());
+ } else {
+ views::Widget* launcher_widget =
+ Shell::GetInstance()->launcher()->widget();
+ view->InitAsFullscreenWidget(Shell::GetInstance()->GetContainer(
+ kShellWindowId_AppListContainer),
+ GetFullScreenBoundsForWidget(launcher_widget),
+ GetWorkAreaBoundsForWidget(launcher_widget));
+ }
+ SetView(view);
}
}
-bool AppList::IsVisible() {
+bool AppListController::IsVisible() const {
return view_ && view_->GetWidget()->IsVisible();
}
-aura::Window* AppList::GetWindow() {
+aura::Window* AppListController::GetWindow() {
return is_visible_ && view_ ? view_->GetWidget()->GetNativeWindow() : NULL;
}
////////////////////////////////////////////////////////////////////////////////
-// AppList, private:
+// AppListController, private:
-void AppList::SetView(AppListView* view) {
+void AppListController::SetView(app_list::AppListView* view) {
DCHECK(view_ == NULL);
if (is_visible_) {
- IconCache::GetInstance()->MarkAllEntryUnused();
+ app_list::IconCache::GetInstance()->MarkAllEntryUnused();
view_ = view;
views::Widget* widget = view_->GetWidget();
@@ -109,7 +141,7 @@ void AppList::SetView(AppListView* view) {
}
}
-void AppList::ResetView() {
+void AppListController::ResetView() {
if (!view_)
return;
@@ -120,10 +152,10 @@ void AppList::ResetView() {
widget->GetNativeView()->GetRootWindow()->RemoveRootWindowObserver(this);
view_ = NULL;
- IconCache::GetInstance()->PurgeAllUnused();
+ app_list::IconCache::GetInstance()->PurgeAllUnused();
}
-void AppList::ScheduleAnimation() {
+void AppListController::ScheduleAnimation() {
second_animation_timer_.Stop();
// Stop observing previous animation.
@@ -141,19 +173,18 @@ void AppList::ScheduleAnimation() {
FROM_HERE,
base::TimeDelta::FromMilliseconds(kSecondAnimationStartDelay),
this,
- &AppList::ScheduleAppListAnimation);
+ &AppListController::ScheduleAppListAnimation);
} else {
ScheduleAppListAnimation();
second_animation_timer_.Start(
FROM_HERE,
base::TimeDelta::FromMilliseconds(kSecondAnimationStartDelay),
this,
- &AppList::ScheduleBrowserWindowsAnimation);
+ &AppListController::ScheduleBrowserWindowsAnimation);
}
-
}
-void AppList::ScheduleBrowserWindowsAnimationForContainer(
+void AppListController::ScheduleBrowserWindowsAnimationForContainer(
aura::Window* container) {
DCHECK(container);
ui::Layer* layer = container->layer();
@@ -174,19 +205,19 @@ void AppList::ScheduleBrowserWindowsAnimationForContainer(
ui::Transform());
}
-void AppList::ScheduleBrowserWindowsAnimation() {
+void AppListController::ScheduleBrowserWindowsAnimation() {
// Note: containers could be NULL during Shell shutdown.
aura::Window* default_container = Shell::GetInstance()->GetContainer(
- internal::kShellWindowId_DefaultContainer);
+ kShellWindowId_DefaultContainer);
if (default_container)
ScheduleBrowserWindowsAnimationForContainer(default_container);
- aura::Window* always_on_top_container = Shell::GetInstance()->GetContainer(
- internal::kShellWindowId_AlwaysOnTopContainer);
+ aura::Window* always_on_top_container = Shell::GetInstance()->
+ GetContainer(kShellWindowId_AlwaysOnTopContainer);
if (always_on_top_container)
ScheduleBrowserWindowsAnimationForContainer(always_on_top_container);
}
-void AppList::ScheduleDimmingAnimation() {
+void AppListController::ScheduleDimmingAnimation() {
ui::Layer* layer = GetLayer(view_->GetWidget());
layer->GetAnimator()->StopAnimating();
@@ -201,7 +232,7 @@ void AppList::ScheduleDimmingAnimation() {
layer->SetOpacity(is_visible_ ? 1.0 : 0.0);
}
-void AppList::ScheduleAppListAnimation() {
+void AppListController::ScheduleAppListAnimation() {
if (is_visible_)
view_->AnimateShow(kAnimationDurationMs);
else
@@ -209,15 +240,15 @@ void AppList::ScheduleAppListAnimation() {
}
////////////////////////////////////////////////////////////////////////////////
-// AppList, aura::EventFilter implementation:
+// AppListController, aura::EventFilter implementation:
-bool AppList::PreHandleKeyEvent(aura::Window* target,
- aura::KeyEvent* event) {
+bool AppListController::PreHandleKeyEvent(aura::Window* target,
+ aura::KeyEvent* event) {
return false;
}
-bool AppList::PreHandleMouseEvent(aura::Window* target,
- aura::MouseEvent* event) {
+bool AppListController::PreHandleMouseEvent(aura::Window* target,
+ aura::MouseEvent* event) {
if (view_ && is_visible_ && event->type() == ui::ET_MOUSE_PRESSED) {
views::Widget* widget = view_->GetWidget();
aura::MouseEvent translated(*event, target, widget->GetNativeView());
@@ -227,31 +258,36 @@ bool AppList::PreHandleMouseEvent(aura::Window* target,
return false;
}
-ui::TouchStatus AppList::PreHandleTouchEvent(aura::Window* target,
- aura::TouchEvent* event) {
+ui::TouchStatus AppListController::PreHandleTouchEvent(
+ aura::Window* target,
+ aura::TouchEvent* event) {
return ui::TOUCH_STATUS_UNKNOWN;
}
-ui::GestureStatus AppList::PreHandleGestureEvent(
+ui::GestureStatus AppListController::PreHandleGestureEvent(
aura::Window* target,
aura::GestureEvent* event) {
return ui::GESTURE_STATUS_UNKNOWN;
}
////////////////////////////////////////////////////////////////////////////////
-// AppList, ura::RootWindowObserver implementation:
-void AppList::OnRootWindowResized(const aura::RootWindow* root,
- const gfx::Size& old_size) {
- if (view_ && is_visible_)
- view_->UpdateBounds();
+// AppListController, aura::RootWindowObserver implementation:
+void AppListController::OnRootWindowResized(const aura::RootWindow* root,
+ const gfx::Size& old_size) {
+ if (view_ && is_visible_) {
+ views::Widget* launcher_widget =
+ Shell::GetInstance()->launcher()->widget();
+ view_->UpdateBounds(GetFullScreenBoundsForWidget(launcher_widget),
+ GetWorkAreaBoundsForWidget(launcher_widget));
+ }
}
-void AppList::OnWindowFocused(aura::Window* window) {
+void AppListController::OnWindowFocused(aura::Window* window) {
if (view_ && is_visible_) {
aura::Window* applist_container = Shell::GetInstance()->GetContainer(
- internal::kShellWindowId_AppListContainer);
+ kShellWindowId_AppListContainer);
aura::Window* bubble_container = Shell::GetInstance()->GetContainer(
- internal::kShellWindowId_SettingBubbleContainer);
+ kShellWindowId_SettingBubbleContainer);
if (window->parent() != applist_container &&
window->parent() != bubble_container) {
SetVisible(false);
@@ -260,9 +296,9 @@ void AppList::OnWindowFocused(aura::Window* window) {
}
////////////////////////////////////////////////////////////////////////////////
-// AppList, ui::ImplicitAnimationObserver implementation:
+// AppListController, ui::ImplicitAnimationObserver implementation:
-void AppList::OnImplicitAnimationsCompleted() {
+void AppListController::OnImplicitAnimationsCompleted() {
if (is_visible_ )
view_->GetWidget()->Activate();
else
@@ -270,9 +306,9 @@ void AppList::OnImplicitAnimationsCompleted() {
}
////////////////////////////////////////////////////////////////////////////////
-// AppList, views::Widget::Observer implementation:
+// AppListController, views::Widget::Observer implementation:
-void AppList::OnWidgetClosing(views::Widget* widget) {
+void AppListController::OnWidgetClosing(views::Widget* widget) {
DCHECK(view_->GetWidget() == widget);
if (is_visible_)
SetVisible(false);
diff --git a/ash/app_list/app_list.h b/ash/wm/app_list_controller.h
index 6230f94..95ea61c 100644
--- a/ash/app_list/app_list.h
+++ b/ash/wm/app_list_controller.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 ASH_APP_LIST_APP_LIST_H_
-#define ASH_APP_LIST_APP_LIST_H_
+#ifndef ASH_WM_APP_LIST_CONTROLLER_H_
+#define ASH_WM_APP_LIST_CONTROLLER_H_
#pragma once
#include "base/basictypes.h"
@@ -14,23 +14,24 @@
#include "ui/compositor/layer_animation_observer.h"
#include "ui/views/widget/widget.h"
-namespace ash {
-
+namespace app_list {
class AppListView;
+}
+namespace ash {
namespace internal {
-// AppList is a controller that manages app list UI for shell. To show the UI,
-// it requests app list widget from ShellDelegate and shows it when ready.
+// AppListController is a controller that manages app list UI for shell.
+// It creates AppListView and schedules showing/hiding animation.
// While the UI is visible, it monitors things such as app list widget's
// activation state and desktop mouse click to auto dismiss the UI.
-class AppList : public aura::EventFilter,
- public aura::RootWindowObserver,
- public ui::ImplicitAnimationObserver,
- public views::Widget::Observer {
+class AppListController : public aura::EventFilter,
+ public aura::RootWindowObserver,
+ public ui::ImplicitAnimationObserver,
+ public views::Widget::Observer {
public:
- AppList();
- virtual ~AppList();
+ AppListController();
+ virtual ~AppListController();
// Returns true if AppListV2 is enabled.
static bool UseAppListV2();
@@ -39,7 +40,7 @@ class AppList : public aura::EventFilter,
void SetVisible(bool visible);
// Whether app list window is visible (shown or being shown).
- bool IsVisible();
+ bool IsVisible() const;
// Returns target visibility. This differs from IsVisible() if an animation
// is ongoing.
@@ -51,7 +52,7 @@ class AppList : public aura::EventFilter,
private:
// Sets app list view. If we are in visible mode, start showing animation.
// Otherwise, we just close it.
- void SetView(AppListView* view);
+ void SetView(app_list::AppListView* view);
// Forgets the view.
void ResetView();
@@ -98,16 +99,17 @@ class AppList : public aura::EventFilter,
bool is_visible_;
// The AppListView this class manages, owned by its widget.
- AppListView* view_;
+ app_list::AppListView* view_;
// Timer to schedule the 2nd step animation, started when the first step
// animation is scheduled in ScheduleAnimation.
- base::OneShotTimer<AppList> second_animation_timer_;
+ base::OneShotTimer<AppListController> second_animation_timer_;
- DISALLOW_COPY_AND_ASSIGN(AppList);
+ DISALLOW_COPY_AND_ASSIGN(AppListController);
};
} // namespace internal
} // namespace ash
-#endif // ASH_APP_LIST_APP_LIST_H_
+#endif // ASH_WM_APP_LIST_CONTROLLER_H_
+
diff --git a/chrome/browser/ui/views/ash/app_list/app_list_model_builder.cc b/chrome/browser/ui/views/ash/app_list/app_list_model_builder.cc
index def39ce..9a3fb35 100644
--- a/chrome/browser/ui/views/ash/app_list/app_list_model_builder.cc
+++ b/chrome/browser/ui/views/ash/app_list/app_list_model_builder.cc
@@ -53,7 +53,7 @@ class ChromeAppItem : public ChromeAppListItem {
// ModelItemSortData provides a string key to sort with
// l10n_util::StringComparator.
struct ModelItemSortData {
- explicit ModelItemSortData(ash::AppListItemModel* item)
+ explicit ModelItemSortData(app_list::AppListItemModel* item)
: item(item),
key(base::i18n::ToLower(UTF8ToUTF16(item->title()))) {
}
@@ -64,7 +64,7 @@ struct ModelItemSortData {
return key;
}
- ash::AppListItemModel* item;
+ app_list::AppListItemModel* item;
string16 key;
};
@@ -102,7 +102,7 @@ AppListModelBuilder::AppListModelBuilder(Profile* profile)
AppListModelBuilder::~AppListModelBuilder() {
}
-void AppListModelBuilder::SetModel(ash::AppListModel* model) {
+void AppListModelBuilder::SetModel(app_list::AppListModel* model) {
model_ = model;
}
@@ -139,7 +139,7 @@ void AppListModelBuilder::SortAndPopulateModel(const Items& items) {
}
}
-void AppListModelBuilder::InsertItemByTitle(ash::AppListItemModel* item) {
+void AppListModelBuilder::InsertItemByTitle(app_list::AppListItemModel* item) {
DCHECK(model_);
icu::Locale locale(g_browser_process->GetApplicationLocale().c_str());
diff --git a/chrome/browser/ui/views/ash/app_list/app_list_model_builder.h b/chrome/browser/ui/views/ash/app_list/app_list_model_builder.h
index 6bdcdcd..b75ebdf 100644
--- a/chrome/browser/ui/views/ash/app_list/app_list_model_builder.h
+++ b/chrome/browser/ui/views/ash/app_list/app_list_model_builder.h
@@ -6,11 +6,14 @@
#define CHROME_BROWSER_UI_VIEWS_ASH_APP_LIST_APP_LIST_MODEL_BUILDER_H_
#pragma once
-#include "ash/app_list/app_list_model.h"
+#include <string>
+#include <vector>
+
#include "base/gtest_prod_util.h"
#include "base/string16.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
+#include "ui/app_list/app_list_model.h"
class Profile;
@@ -19,20 +22,20 @@ class AppListModelBuilder : public content::NotificationObserver {
explicit AppListModelBuilder(Profile* profile);
virtual ~AppListModelBuilder();
- void SetModel(ash::AppListModel* model);
+ void SetModel(app_list::AppListModel* model);
// Populates the model.
void Build(const std::string& query);
private:
- typedef std::vector<ash::AppListItemModel*> Items;
+ typedef std::vector<app_list::AppListItemModel*> Items;
FRIEND_TEST_ALL_PREFIXES(AppListModelBuilderTest, GetExtensionApps);
FRIEND_TEST_ALL_PREFIXES(AppListModelBuilderTest, SortAndPopulateModel);
FRIEND_TEST_ALL_PREFIXES(AppListModelBuilderTest, InsertItemByTitle);
void SortAndPopulateModel(const Items& items);
- void InsertItemByTitle(ash::AppListItemModel* item);
+ void InsertItemByTitle(app_list::AppListItemModel* item);
void GetExtensionApps(const string16& query, Items* items);
void CreateSpecialItems();
@@ -57,7 +60,7 @@ class AppListModelBuilder : public content::NotificationObserver {
// The model used by AppListView. It is passed in via SetModel and owned by
// AppListView.
- ash::AppListModel* model_;
+ app_list::AppListModel* model_;
// Number of special items in the model. Special items index should be ranged
// from [0, special_items_count_ - 1].
diff --git a/chrome/browser/ui/views/ash/app_list/app_list_model_builder_unittest.cc b/chrome/browser/ui/views/ash/app_list/app_list_model_builder_unittest.cc
index 9137752..ed2d918 100644
--- a/chrome/browser/ui/views/ash/app_list/app_list_model_builder_unittest.cc
+++ b/chrome/browser/ui/views/ash/app_list/app_list_model_builder_unittest.cc
@@ -2,18 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/app_list/app_list_item_model.h"
+#include "chrome/browser/ui/views/ash/app_list/app_list_model_builder.h"
+
+#include <string>
+
#include "base/file_util.h"
#include "base/stl_util.h"
#include "base/memory/scoped_ptr.h"
-#include "chrome/browser/ui/views/ash/app_list/app_list_model_builder.h"
#include "chrome/browser/extensions/extension_service_unittest.h"
#include "chrome/test/base/testing_profile.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/app_list/app_list_item_model.h"
namespace {
-class TestAppListItemModel : public ash::AppListItemModel {
+class TestAppListItemModel : public app_list::AppListItemModel {
public:
explicit TestAppListItemModel(const std::string& title) {
SetTitle(title);
@@ -24,7 +27,7 @@ class TestAppListItemModel : public ash::AppListItemModel {
};
// Get a string of all items in |model| joined with ','.
-std::string GetModelContent(ash::AppListModel* model) {
+std::string GetModelContent(app_list::AppListModel* model) {
std::string content;
for (int i = 0; i < model->item_count(); ++i) {
if (i > 0)
@@ -78,7 +81,7 @@ TEST_F(AppListModelBuilderTest, SortAndPopulateModel) {
};
const char* kExpected = "a,B,Ca,CB";
- scoped_ptr<ash::AppListModel> model(new ash::AppListModel());
+ scoped_ptr<app_list::AppListModel> model(new app_list::AppListModel());
AppListModelBuilder::Items items;
for (size_t i = 0; i < arraysize(kInput); ++i)
@@ -92,7 +95,7 @@ TEST_F(AppListModelBuilderTest, SortAndPopulateModel) {
}
TEST_F(AppListModelBuilderTest, InsertItemByTitle) {
- scoped_ptr<ash::AppListModel> model(new ash::AppListModel());
+ scoped_ptr<app_list::AppListModel> model(new app_list::AppListModel());
AppListModelBuilder builder(profile_.get());
builder.SetModel(model.get());
diff --git a/chrome/browser/ui/views/ash/app_list/app_list_view_delegate.cc b/chrome/browser/ui/views/ash/app_list/app_list_view_delegate.cc
index 487830b..1dfe853 100644
--- a/chrome/browser/ui/views/ash/app_list/app_list_view_delegate.cc
+++ b/chrome/browser/ui/views/ash/app_list/app_list_view_delegate.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h"
+#include "ash/shell.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/views/ash/app_list/app_list_model_builder.h"
#include "chrome/browser/ui/views/ash/app_list/chrome_app_list_item.h"
@@ -14,7 +15,7 @@ AppListViewDelegate::AppListViewDelegate() {
AppListViewDelegate::~AppListViewDelegate() {
}
-void AppListViewDelegate::SetModel(ash::AppListModel* model) {
+void AppListViewDelegate::SetModel(app_list::AppListModel* model) {
if (model) {
if (!model_builder_.get()) {
model_builder_.reset(
@@ -33,7 +34,13 @@ void AppListViewDelegate::UpdateModel(const std::string& query) {
}
void AppListViewDelegate::OnAppListItemActivated(
- ash::AppListItemModel* item,
+ app_list::AppListItemModel* item,
int event_flags) {
static_cast<ChromeAppListItem*>(item)->Activate(event_flags);
}
+
+void AppListViewDelegate::Close() {
+ DCHECK(ash::Shell::HasInstance());
+ if (ash::Shell::GetInstance()->GetAppListTargetVisibility())
+ ash::Shell::GetInstance()->ToggleAppList();
+}
diff --git a/chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h b/chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h
index aefe3ee..0837997 100644
--- a/chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h
+++ b/chrome/browser/ui/views/ash/app_list/app_list_view_delegate.h
@@ -6,24 +6,27 @@
#define CHROME_BROWSER_UI_VIEWS_ASH_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
#pragma once
-#include "ash/app_list/app_list_view_delegate.h"
+#include <string>
+
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
+#include "ui/app_list/app_list_view_delegate.h"
class AppListModelBuilder;
-class AppListViewDelegate : public ash::AppListViewDelegate {
+class AppListViewDelegate : public app_list::AppListViewDelegate {
public:
AppListViewDelegate();
virtual ~AppListViewDelegate();
private:
- // Overridden from ash::AppListViewDelegate:
- virtual void SetModel(ash::AppListModel* model) OVERRIDE;
+ // Overridden from app_list::AppListViewDelegate:
+ virtual void SetModel(app_list::AppListModel* model) OVERRIDE;
virtual void UpdateModel(const std::string& query) OVERRIDE;
- virtual void OnAppListItemActivated(ash::AppListItemModel* item,
+ virtual void OnAppListItemActivated(app_list::AppListItemModel* item,
int event_flags) OVERRIDE;
+ virtual void Close() OVERRIDE;
scoped_ptr<AppListModelBuilder> model_builder_;
diff --git a/chrome/browser/ui/views/ash/app_list/chrome_app_list_item.h b/chrome/browser/ui/views/ash/app_list/chrome_app_list_item.h
index dd0aac2..ae3129f 100644
--- a/chrome/browser/ui/views/ash/app_list/chrome_app_list_item.h
+++ b/chrome/browser/ui/views/ash/app_list/chrome_app_list_item.h
@@ -6,12 +6,12 @@
#define CHROME_BROWSER_UI_VIEWS_ASH_APP_LIST_CHROME_APP_LIST_ITEM_H_
#pragma once
-#include "ash/app_list/app_list_item_model.h"
+#include "ui/app_list/app_list_item_model.h"
// Base class of all chrome app list items. Chrome's AppListViewDelegate assumes
// all items are derived from this class and calls Activate when an item is
// activated.
-class ChromeAppListItem : public ash::AppListItemModel {
+class ChromeAppListItem : public app_list::AppListItemModel {
public:
enum Type {
TYPE_APP,
diff --git a/chrome/browser/ui/views/ash/app_list/extension_app_item.cc b/chrome/browser/ui/views/ash/app_list/extension_app_item.cc
index 6750a6c..abb17c0 100644
--- a/chrome/browser/ui/views/ash/app_list/extension_app_item.cc
+++ b/chrome/browser/ui/views/ash/app_list/extension_app_item.cc
@@ -4,7 +4,6 @@
#include "chrome/browser/ui/views/ash/app_list/extension_app_item.h"
-#include "ash/app_list/app_list_item_view.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/extension_prefs.h"
#include "chrome/browser/extensions/extension_service.h"
@@ -19,6 +18,7 @@
#include "chrome/common/extensions/extension_icon_set.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
+#include "ui/app_list/app_list_item_view.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/image/image.h"
diff --git a/chrome/browser/ui/views/ash/app_list/extension_app_item.h b/chrome/browser/ui/views/ash/app_list/extension_app_item.h
index 19aad01..3621ded 100644
--- a/chrome/browser/ui/views/ash/app_list/extension_app_item.h
+++ b/chrome/browser/ui/views/ash/app_list/extension_app_item.h
@@ -6,6 +6,8 @@
#define CHROME_BROWSER_UI_VIEWS_ASH_APP_LIST_EXTENSION_APP_ITEM_H_
#pragma once
+#include <string>
+
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/extensions/image_loading_tracker.h"
#include "chrome/browser/ui/views/ash/app_list/chrome_app_list_item.h"
diff --git a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc
index ab8d0f2..9ee52fa 100644
--- a/chrome/browser/ui/views/ash/chrome_shell_delegate.cc
+++ b/chrome/browser/ui/views/ash/chrome_shell_delegate.cc
@@ -207,7 +207,7 @@ void ChromeShellDelegate::ToggleSpokenFeedback() {
#endif
}
-ash::AppListViewDelegate*
+app_list::AppListViewDelegate*
ChromeShellDelegate::CreateAppListViewDelegate() {
// Shell will own the created delegate.
return new AppListViewDelegate;
diff --git a/chrome/browser/ui/views/ash/chrome_shell_delegate.h b/chrome/browser/ui/views/ash/chrome_shell_delegate.h
index 4e9f243..ab1d222 100644
--- a/chrome/browser/ui/views/ash/chrome_shell_delegate.h
+++ b/chrome/browser/ui/views/ash/chrome_shell_delegate.h
@@ -44,7 +44,7 @@ class ChromeShellDelegate : public ash::ShellDelegate,
virtual void OpenMobileSetup() OVERRIDE;
virtual content::BrowserContext* GetCurrentBrowserContext() OVERRIDE;
virtual void ToggleSpokenFeedback() OVERRIDE;
- virtual ash::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
+ virtual app_list::AppListViewDelegate* CreateAppListViewDelegate() OVERRIDE;
virtual void StartPartialScreenshot(
ash::ScreenshotDelegate* screenshot_delegate) OVERRIDE;
virtual ash::LauncherDelegate* CreateLauncherDelegate(
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 87e53e4..22e2f20 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -4262,6 +4262,7 @@
['use_ash==1', {
'dependencies': [
'../ash/ash.gyp:ash',
+ '../ui/app_list/app_list.gyp:app_list',
],
}],
['use_aura==1', {
diff --git a/ui/app_list/DEPS b/ui/app_list/DEPS
new file mode 100644
index 0000000..428414c
--- /dev/null
+++ b/ui/app_list/DEPS
@@ -0,0 +1,6 @@
+include_rules = [
+ "+base",
+ "+ui",
+ "+testing",
+ "+third_party/skia",
+]
diff --git a/ash/app_list/OWNERS b/ui/app_list/OWNERS
index ff3209c..ff3209c 100644
--- a/ash/app_list/OWNERS
+++ b/ui/app_list/OWNERS
diff --git a/ui/app_list/app_list.gyp b/ui/app_list/app_list.gyp
new file mode 100644
index 0000000..5e771de
--- /dev/null
+++ b/ui/app_list/app_list.gyp
@@ -0,0 +1,70 @@
+# 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.
+
+{
+ 'variables': {
+ 'chromium_code': 1,
+ },
+ 'targets': [
+ {
+ 'target_name': 'app_list',
+ 'type': '<(component)',
+ 'dependencies': [
+ '../../base/base.gyp:base',
+ '../../base/third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
+ '../../skia/skia.gyp:skia',
+ '../aura/aura.gyp:aura',
+ '../compositor/compositor.gyp:compositor',
+ '../ui.gyp:ui',
+ '../views/views.gyp:views',
+ ],
+ 'defines': [
+ 'APP_LIST_IMPLEMENTATION',
+ ],
+ 'sources': [
+ 'app_list_bubble_border.cc',
+ 'app_list_bubble_border.h',
+ 'app_list_item_model.cc',
+ 'app_list_item_model.h',
+ 'app_list_item_model_observer.h',
+ 'app_list_item_view.cc',
+ 'app_list_item_view.h',
+ 'app_list_model.cc',
+ 'app_list_model.h',
+ 'app_list_model_view.cc',
+ 'app_list_model_view.h',
+ 'app_list_view.cc',
+ 'app_list_view.h',
+ 'app_list_view_delegate.h',
+ 'drop_shadow_label.cc',
+ 'drop_shadow_label.h',
+ 'icon_cache.cc',
+ 'icon_cache.h',
+ 'page_switcher.cc',
+ 'page_switcher.h',
+ 'pagination_model.cc',
+ 'pagination_model.h',
+ 'pagination_model_observer.h',
+ ],
+ },
+ {
+ 'target_name': 'app_list_unittests',
+ 'type': 'executable',
+ 'dependencies': [
+ '../../base/base.gyp:base',
+ '../../base/base.gyp:test_support_base',
+ '../../skia/skia.gyp:skia',
+ '../../testing/gtest.gyp:gtest',
+ '../compositor/compositor.gyp:compositor',
+ '../compositor/compositor.gyp:compositor_test_support',
+ '../views/views.gyp:views',
+ 'app_list',
+ ],
+ 'sources': [
+ 'app_list_model_view_unittest.cc',
+ 'run_all_unittests.cc',
+ ],
+ },
+ ],
+}
diff --git a/ash/app_list/app_list_bubble_border.cc b/ui/app_list/app_list_bubble_border.cc
index ca634cb..145dea9 100644
--- a/ash/app_list/app_list_bubble_border.cc
+++ b/ui/app_list/app_list_bubble_border.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 "ash/app_list/app_list_bubble_border.h"
+#include "ui/app_list/app_list_bubble_border.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkPaint.h"
@@ -85,7 +85,7 @@ void BuildShape(const gfx::Rect& bounds,
} // namespace
-namespace ash {
+namespace app_list {
AppListBubbleBorder::AppListBubbleBorder(views::View* app_list_view)
: views::BubbleBorder(views::BubbleBorder::BOTTOM_RIGHT,
@@ -210,4 +210,4 @@ void AppListBubbleBorder::Paint(const views::View& view,
canvas->Restore();
}
-} // namespace ash
+} // namespace app_list
diff --git a/ash/app_list/app_list_bubble_border.h b/ui/app_list/app_list_bubble_border.h
index 345e4eb..53d7bed 100644
--- a/ash/app_list/app_list_bubble_border.h
+++ b/ui/app_list/app_list_bubble_border.h
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_APP_LIST_APP_LIST_BUBBLE_BORDER_H_
-#define ASH_APP_LIST_APP_LIST_BUBBLE_BORDER_H_
+#ifndef UI_APP_LIST_APP_LIST_BUBBLE_BORDER_H_
+#define UI_APP_LIST_APP_LIST_BUBBLE_BORDER_H_
#pragma once
#include "base/basictypes.h"
#include "ui/views/bubble/bubble_border.h"
-namespace ash {
+namespace app_list {
// A class to paint bubble border and background.
class AppListBubbleBorder : public views::BubbleBorder {
@@ -48,6 +48,6 @@ class AppListBubbleBorder : public views::BubbleBorder {
DISALLOW_COPY_AND_ASSIGN(AppListBubbleBorder);
};
-} // namespace ash
+} // namespace app_list
-#endif // ASH_APP_LIST_APP_LIST_BUBBLE_BORDER_H_
+#endif // UI_APP_LIST_APP_LIST_BUBBLE_BORDER_H_
diff --git a/ui/app_list/app_list_export.h b/ui/app_list/app_list_export.h
new file mode 100644
index 0000000..0dbcb6e
--- /dev/null
+++ b/ui/app_list/app_list_export.h
@@ -0,0 +1,30 @@
+// 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 UI_APP_LIST_APP_LIST_EXPORT_H_
+#define UI_APP_LIST_APP_LIST_EXPORT_H_
+#pragma once
+
+// Defines APP_LIST_EXPORT so that functionality implemented by the aura_shell
+// module can be exported to consumers.
+
+#if defined(COMPONENT_BUILD)
+#if defined(WIN32)
+
+#if defined(APP_LIST_IMPLEMENTATION)
+#define APP_LIST_EXPORT __declspec(dllexport)
+#else
+#define APP_LIST_EXPORT __declspec(dllimport)
+#endif // defined(APP_LIST_IMPLEMENTATION)
+
+#else // defined(WIN32)
+#define APP_LIST_EXPORT __attribute__((visibility("default")))
+#endif
+
+#else // defined(COMPONENT_BUILD)
+#define APP_LIST_EXPORT
+#endif
+
+#endif // UI_APP_LIST_APP_LIST_EXPORT_H_
+
diff --git a/ash/app_list/app_list_item_model.cc b/ui/app_list/app_list_item_model.cc
index c8c5938..6c052cb 100644
--- a/ash/app_list/app_list_item_model.cc
+++ b/ui/app_list/app_list_item_model.cc
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/app_list/app_list_item_model.h"
+#include "ui/app_list/app_list_item_model.h"
-#include "ash/app_list/app_list_item_model_observer.h"
+#include "ui/app_list/app_list_item_model_observer.h"
-namespace ash {
+namespace app_list {
AppListItemModel::AppListItemModel() : highlighted_(false) {
}
@@ -47,4 +47,4 @@ ui::MenuModel* AppListItemModel::GetContextMenuModel() {
return NULL;
}
-} // namespace ash
+} // namespace app_list
diff --git a/ash/app_list/app_list_item_model.h b/ui/app_list/app_list_item_model.h
index 9dec482..3729b95 100644
--- a/ash/app_list/app_list_item_model.h
+++ b/ui/app_list/app_list_item_model.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_AURA_SHELL_APP_LIST_APP_LIST_ITEM_MODEL_H_
-#define UI_AURA_SHELL_APP_LIST_APP_LIST_ITEM_MODEL_H_
+#ifndef UI_APP_LIST_APP_LIST_ITEM_MODEL_H_
+#define UI_APP_LIST_APP_LIST_ITEM_MODEL_H_
#pragma once
#include <string>
@@ -11,19 +11,19 @@
#include "base/basictypes.h"
#include "base/observer_list.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "ash/ash_export.h"
+#include "ui/app_list/app_list_export.h"
namespace ui {
class MenuModel;
}
-namespace ash {
+namespace app_list {
class AppListItemModelObserver;
// AppListItemModel provides icon and title to be shown in a AppListItemView
// and action to be executed when the AppListItemView is activated.
-class ASH_EXPORT AppListItemModel {
+class APP_LIST_EXPORT AppListItemModel {
public:
AppListItemModel();
virtual ~AppListItemModel();
@@ -60,6 +60,6 @@ class ASH_EXPORT AppListItemModel {
DISALLOW_COPY_AND_ASSIGN(AppListItemModel);
};
-} // namespace ash
+} // namespace app_list
-#endif // #define ASH_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_
+#endif // UI_APP_LIST_APP_LIST_ITEM_MODEL_H_
diff --git a/ash/app_list/app_list_item_model_observer.h b/ui/app_list/app_list_item_model_observer.h
index 0162a31..813b6d7 100644
--- a/ash/app_list/app_list_item_model_observer.h
+++ b/ui/app_list/app_list_item_model_observer.h
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_
-#define ASH_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_
+#ifndef UI_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_
+#define UI_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_
#pragma once
-#include "ash/ash_export.h"
+#include "ui/app_list/app_list_export.h"
-namespace ash {
+namespace app_list {
-class ASH_EXPORT AppListItemModelObserver {
+class APP_LIST_EXPORT AppListItemModelObserver {
public:
// Invoked after item's icon is changed.
virtual void ItemIconChanged() = 0;
@@ -25,6 +25,6 @@ class ASH_EXPORT AppListItemModelObserver {
virtual ~AppListItemModelObserver() {}
};
-} // namespace ash
+} // namespace app_list
-#endif // ASH_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_
+#endif // UI_APP_LIST_APP_LIST_ITEM_MODEL_OBSERVER_H_
diff --git a/ash/app_list/app_list_item_view.cc b/ui/app_list/app_list_item_view.cc
index 869e6a4..26bff6a 100644
--- a/ash/app_list/app_list_item_view.cc
+++ b/ui/app_list/app_list_item_view.cc
@@ -2,18 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/app_list/app_list_item_view.h"
+#include "ui/app_list/app_list_item_view.h"
+
+#include <algorithm>
-#include "ash/app_list/app_list.h"
-#include "ash/app_list/app_list_item_model.h"
-#include "ash/app_list/app_list_model_view.h"
-#include "ash/app_list/drop_shadow_label.h"
-#include "ash/app_list/icon_cache.h"
#include "base/bind.h"
#include "base/message_loop.h"
#include "base/synchronization/cancellation_flag.h"
#include "base/threading/worker_pool.h"
#include "base/utf_string_conversions.h"
+#include "ui/app_list/app_list_item_model.h"
+#include "ui/app_list/app_list_model_view.h"
+#include "ui/app_list/drop_shadow_label.h"
+#include "ui/app_list/icon_cache.h"
#include "ui/base/accessibility/accessible_view_state.h"
#include "ui/base/animation/throb_animation.h"
#include "ui/base/resource/resource_bundle.h"
@@ -26,7 +27,7 @@
#include "ui/views/controls/menu/menu_model_adapter.h"
#include "ui/views/controls/menu/menu_runner.h"
-namespace ash {
+namespace app_list {
namespace {
@@ -102,7 +103,7 @@ int g_min_title_width = 0;
} // namespace
// static
-const char AppListItemView::kViewClassName[] = "ash/app_list/AppListItemView";
+const char AppListItemView::kViewClassName[] = "ui/app_list/AppListItemView";
// AppListItemView::IconOperation wraps background icon processing.
class AppListItemView::IconOperation
@@ -188,7 +189,7 @@ AppListItemView::AppListItemView(AppListModelView* list_model_view,
ALLOW_THIS_IN_INITIALIZER_LIST(apply_shadow_factory_(this)) {
title_->SetBackgroundColor(0);
- if (internal::AppList::UseAppListV2()) {
+ if (list_model_view_->fixed_layout()) {
title_->SetEnabledColor(kTitleColorV2);
} else {
title_->SetEnabledColor(kTitleColor);
@@ -400,4 +401,4 @@ void AppListItemView::StateChanged() {
}
}
-} // namespace ash
+} // namespace app_list
diff --git a/ash/app_list/app_list_item_view.h b/ui/app_list/app_list_item_view.h
index da377e8..7d293d0 100644
--- a/ash/app_list/app_list_item_view.h
+++ b/ui/app_list/app_list_item_view.h
@@ -2,15 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_
-#define ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_
+#ifndef UI_APP_LIST_APP_LIST_ITEM_VIEW_H_
+#define UI_APP_LIST_APP_LIST_ITEM_VIEW_H_
#pragma once
-#include "ash/app_list/app_list_item_model_observer.h"
-#include "ash/ash_export.h"
+#include <string>
+
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h"
+#include "ui/app_list/app_list_export.h"
+#include "ui/app_list/app_list_item_model_observer.h"
#include "ui/views/context_menu_controller.h"
#include "ui/views/controls/button/custom_button.h"
@@ -21,15 +23,15 @@ class ImageView;
class MenuRunner;
}
-namespace ash {
+namespace app_list {
class AppListItemModel;
class AppListModelView;
class DropShadowLabel;
-class ASH_EXPORT AppListItemView : public views::CustomButton,
- public views::ContextMenuController,
- public AppListItemModelObserver {
+class APP_LIST_EXPORT AppListItemView : public views::CustomButton,
+ public views::ContextMenuController,
+ public AppListItemModelObserver {
public:
AppListItemView(AppListModelView* list_model_view,
AppListItemModel* model,
@@ -105,6 +107,6 @@ class ASH_EXPORT AppListItemView : public views::CustomButton,
DISALLOW_COPY_AND_ASSIGN(AppListItemView);
};
-} // namespace ash
+} // namespace app_list
-#endif // ASH_APP_LIST_APP_LIST_ITEM_VIEW_H_
+#endif // UI_APP_LIST_APP_LIST_ITEM_VIEW_H_
diff --git a/ash/app_list/app_list_model.cc b/ui/app_list/app_list_model.cc
index ff42d92..f19f89d 100644
--- a/ash/app_list/app_list_model.cc
+++ b/ui/app_list/app_list_model.cc
@@ -2,9 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/app_list/app_list_model.h"
+#include "ui/app_list/app_list_model.h"
-namespace ash {
+namespace app_list {
AppListModel::AppListModel() {
}
@@ -36,4 +36,4 @@ void AppListModel::RemoveObserver(ui::ListModelObserver* observer) {
items_.RemoveObserver(observer);
}
-} // namespace ash
+} // namespace app_list
diff --git a/ash/app_list/app_list_model.h b/ui/app_list/app_list_model.h
index 6ec296c..2424f6e 100644
--- a/ash/app_list/app_list_model.h
+++ b/ui/app_list/app_list_model.h
@@ -2,21 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_APP_LIST_APP_LIST_MODEL_H_
-#define ASH_APP_LIST_APP_LIST_MODEL_H_
+#ifndef UI_APP_LIST_APP_LIST_MODEL_H_
+#define UI_APP_LIST_APP_LIST_MODEL_H_
#pragma once
-#include "ash/app_list/app_list_item_model.h"
-#include "ash/ash_export.h"
#include "base/basictypes.h"
+#include "ui/app_list/app_list_export.h"
+#include "ui/app_list/app_list_item_model.h"
#include "ui/base/models/list_model.h"
-namespace ash {
+namespace app_list {
class AppListItemModel;
// Model for AppListModelView that owns a list of AppListItemModels.
-class ASH_EXPORT AppListModel {
+class APP_LIST_EXPORT AppListModel {
public:
AppListModel();
virtual ~AppListModel();
@@ -43,6 +43,6 @@ class ASH_EXPORT AppListModel {
DISALLOW_COPY_AND_ASSIGN(AppListModel);
};
-} // namespace ash
+} // namespace app_list
-#endif // ASH_APP_LIST_APP_LIST_MODEL_H_
+#endif // UI_APP_LIST_APP_LIST_MODEL_H_
diff --git a/ash/app_list/app_list_model_view.cc b/ui/app_list/app_list_model_view.cc
index db984d3..3afe0d4 100644
--- a/ash/app_list/app_list_model_view.cc
+++ b/ui/app_list/app_list_model_view.cc
@@ -2,13 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/app_list/app_list_model_view.h"
+#include "ui/app_list/app_list_model_view.h"
-#include "ash/app_list/app_list_item_view.h"
-#include "ash/app_list/app_list_model.h"
-#include "ash/app_list/pagination_model.h"
+#include <algorithm>
-namespace ash {
+#include "ui/app_list/app_list_item_view.h"
+#include "ui/app_list/app_list_model.h"
+#include "ui/app_list/pagination_model.h"
+
+namespace app_list {
AppListModelView::AppListModelView(views::ButtonListener* listener,
PaginationModel* pagination_model)
@@ -304,4 +306,4 @@ void AppListModelView::SelectedPageChanged(int old_selected, int new_selected) {
Layout();
}
-} // namespace ash
+} // namespace app_list
diff --git a/ash/app_list/app_list_model_view.h b/ui/app_list/app_list_model_view.h
index 31fec61..90095fa 100644
--- a/ash/app_list/app_list_model_view.h
+++ b/ui/app_list/app_list_model_view.h
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_APP_LIST_APP_LIST_MODEL_VIEW_H_
-#define ASH_APP_LIST_APP_LIST_MODEL_VIEW_H_
+#ifndef UI_APP_LIST_APP_LIST_MODEL_VIEW_H_
+#define UI_APP_LIST_APP_LIST_MODEL_VIEW_H_
#pragma once
-#include "ash/ash_export.h"
-#include "ash/app_list/pagination_model_observer.h"
+#include "ui/app_list/app_list_export.h"
+#include "ui/app_list/pagination_model_observer.h"
#include "ui/base/models/list_model_observer.h"
#include "ui/views/view.h"
@@ -15,14 +15,14 @@ namespace views {
class ButtonListener;
}
-namespace ash {
+namespace app_list {
class AppListItemView;
class AppListModel;
class PaginationModel;
// AppListModelView displays the UI for an AppListModel.
-class ASH_EXPORT AppListModelView : public views::View,
+class APP_LIST_EXPORT AppListModelView : public views::View,
public ui::ListModelObserver,
public PaginationModelObserver {
public:
@@ -52,6 +52,10 @@ class ASH_EXPORT AppListModelView : public views::View,
return cols_ * rows_per_page_;
}
+ bool fixed_layout() const {
+ return fixed_layout_;
+ }
+
private:
// Updates from model.
void Update();
@@ -89,6 +93,6 @@ class ASH_EXPORT AppListModelView : public views::View,
DISALLOW_COPY_AND_ASSIGN(AppListModelView);
};
-} // namespace ash
+} // namespace app_list
-#endif // ASH_APP_LIST_APP_LIST_MODEL_VIEW_H_
+#endif // UI_APP_LIST_APP_LIST_MODEL_VIEW_H_
diff --git a/ash/app_list/app_list_unittest.cc b/ui/app_list/app_list_model_view_unittest.cc
index 824eee4..16cc112 100644
--- a/ash/app_list/app_list_unittest.cc
+++ b/ui/app_list/app_list_model_view_unittest.cc
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/app_list/app_list_item_view.h"
-#include "ash/app_list/app_list_model_view.h"
+#include "ui/app_list/app_list_model_view.h"
+
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/app_list/app_list_item_view.h"
namespace {
@@ -18,12 +19,14 @@ struct ModelViewCalculateLayoutCase {
} // namespace
-TEST(AppListTest, ModelViewCalculateLayout) {
+namespace app_list {
+
+TEST(AppListModelViewTest, ModelViewCalculateLayout) {
// kMinTitleWidth is the average width of 15 chars of default size 12 font in
// chromeos. Override here to avoid flakiness from different default font on
// bots.
const int kMinTitleWidth = 90;
- ash::AppListItemView::SetMinTitleWidth(kMinTitleWidth);
+ AppListItemView::SetMinTitleWidth(kMinTitleWidth);
const int kLauncherHeight = 50;
const ModelViewCalculateLayoutCase kCases[] = {
@@ -52,13 +55,15 @@ TEST(AppListTest, ModelViewCalculateLayout) {
int cols = 0;
gfx::Size content_size(kCases[i].screen_size.width(),
kCases[i].screen_size.height() - kLauncherHeight);
- ash::AppListModelView::CalculateLayout(content_size,
- kCases[i].num_of_tiles,
- &icon_size,
- &rows,
- &cols);
+ AppListModelView::CalculateLayout(content_size,
+ kCases[i].num_of_tiles,
+ &icon_size,
+ &rows,
+ &cols);
EXPECT_EQ(kCases[i].expected_icon_size, icon_size) << "i=" << i;
EXPECT_EQ(kCases[i].expected_rows, rows) << "i=" << i;
EXPECT_EQ(kCases[i].expected_cols, cols) << "i=" << i;
}
}
+
+} // namespace app_list
diff --git a/ash/app_list/app_list_view.cc b/ui/app_list/app_list_view.cc
index beecfbe..14289a6 100644
--- a/ash/app_list/app_list_view.cc
+++ b/ui/app_list/app_list_view.cc
@@ -2,21 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/app_list/app_list_view.h"
-
-#include "ash/app_list/app_list.h"
-#include "ash/app_list/app_list_bubble_border.h"
-#include "ash/app_list/app_list_item_view.h"
-#include "ash/app_list/app_list_model.h"
-#include "ash/app_list/app_list_model_view.h"
-#include "ash/app_list/app_list_view_delegate.h"
-#include "ash/app_list/page_switcher.h"
-#include "ash/app_list/pagination_model.h"
-#include "ash/launcher/launcher.h"
-#include "ash/screen_ash.h"
-#include "ash/shell.h"
-#include "ash/shell_window_ids.h"
-#include "ash/wm/shelf_layout_manager.h"
+#include "ui/app_list/app_list_view.h"
+
+#include <string>
+
+#include "ui/app_list/app_list_bubble_border.h"
+#include "ui/app_list/app_list_item_view.h"
+#include "ui/app_list/app_list_model.h"
+#include "ui/app_list/app_list_model_view.h"
+#include "ui/app_list/app_list_view_delegate.h"
+#include "ui/app_list/page_switcher.h"
+#include "ui/app_list/pagination_model.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/gfx/screen.h"
@@ -26,7 +22,7 @@
#include "ui/views/layout/box_layout.h"
#include "ui/views/widget/widget.h"
-namespace ash {
+namespace app_list {
namespace {
@@ -47,13 +43,6 @@ ui::Transform GetScaleTransform(AppListModelView* model_view) {
return ui::GetScaleTransform(center, kModelViewAnimationScaleFactor);
}
-// Bounds returned is used for full screen mode. Use full monitor rect so that
-// the app list shade goes behind the launcher.
-gfx::Rect GetFullScreenBounds() {
- gfx::Point cursor = gfx::Screen::GetCursorScreenPoint();
- return gfx::Screen::GetMonitorNearestPoint(cursor).bounds();
-}
-
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -65,10 +54,6 @@ AppListView::AppListView(AppListViewDelegate* delegate)
bubble_style_(false),
bubble_border_(NULL),
model_view_(NULL) {
- if (internal::AppList::UseAppListV2())
- InitAsBubble();
- else
- InitAsFullscreenWidget();
}
AppListView::~AppListView() {
@@ -77,46 +62,13 @@ AppListView::~AppListView() {
model_view_->SetModel(NULL);
}
-void AppListView::AnimateShow(int duration_ms) {
- if (bubble_style_)
- return;
-
- ui::Layer* layer = model_view_->layer();
- ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
- animation.SetTransitionDuration(
- base::TimeDelta::FromMilliseconds(duration_ms));
- animation.SetTweenType(ui::Tween::EASE_OUT);
- model_view_->SetTransform(ui::Transform());
-}
-
-void AppListView::AnimateHide(int duration_ms) {
- if (bubble_style_)
- return;
-
- ui::Layer* layer = model_view_->layer();
- ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
- animation.SetTransitionDuration(
- base::TimeDelta::FromMilliseconds(duration_ms));
- animation.SetTweenType(ui::Tween::EASE_IN);
- model_view_->SetTransform(GetScaleTransform(model_view_));
-}
-
-void AppListView::Close() {
- if (GetWidget()->IsVisible())
- Shell::GetInstance()->ToggleAppList();
-}
-
-void AppListView::UpdateBounds() {
- if (bubble_style_)
- SizeToContents();
- else
- GetWidget()->SetBounds(GetFullScreenBounds());
-}
-
-void AppListView::InitAsFullscreenWidget() {
+void AppListView::InitAsFullscreenWidget(gfx::NativeView parent,
+ const gfx::Rect& screen_bounds,
+ const gfx::Rect& work_area) {
bubble_style_ = false;
set_background(views::Background::CreateSolidBackground(
kWidgetBackgroundColor));
+ work_area_ = work_area;
model_view_ = new AppListModelView(this, pagination_model_.get());
model_view_->SetPaintToLayer(true);
@@ -127,14 +79,12 @@ void AppListView::InitAsFullscreenWidget() {
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS);
widget_params.delegate = this;
widget_params.transparent = true;
- widget_params.parent = Shell::GetInstance()->GetContainer(
- internal::kShellWindowId_AppListContainer);
+ widget_params.parent = parent;
views::Widget* widget = new views::Widget;
widget->Init(widget_params);
widget->SetContentsView(this);
-
- widget->SetBounds(GetFullScreenBounds());
+ widget->SetBounds(screen_bounds);
// Turns off default animation.
widget->SetVisibilityChangedAnimationsEnabled(false);
@@ -144,7 +94,7 @@ void AppListView::InitAsFullscreenWidget() {
UpdateModel();
}
-void AppListView::InitAsBubble() {
+void AppListView::InitAsBubble(gfx::NativeView parent, views::View* anchor) {
bubble_style_ = true;
set_background(NULL);
@@ -160,9 +110,8 @@ void AppListView::InitAsBubble() {
PageSwitcher* page_switcher = new PageSwitcher(pagination_model_.get());
AddChildView(page_switcher);
- set_anchor_view(Shell::GetInstance()->launcher()->GetAppListButtonView());
- set_parent_window(Shell::GetInstance()->GetContainer(
- internal::kShellWindowId_AppListContainer));
+ set_anchor_view(anchor);
+ set_parent_window(parent);
set_close_on_deactivate(false);
views::BubbleDelegateView::CreateBubble(this);
@@ -177,6 +126,47 @@ void AppListView::InitAsBubble() {
UpdateModel();
}
+void AppListView::AnimateShow(int duration_ms) {
+ if (bubble_style_)
+ return;
+
+ ui::Layer* layer = model_view_->layer();
+ ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
+ animation.SetTransitionDuration(
+ base::TimeDelta::FromMilliseconds(duration_ms));
+ animation.SetTweenType(ui::Tween::EASE_OUT);
+ model_view_->SetTransform(ui::Transform());
+}
+
+void AppListView::AnimateHide(int duration_ms) {
+ if (bubble_style_)
+ return;
+
+ ui::Layer* layer = model_view_->layer();
+ ui::ScopedLayerAnimationSettings animation(layer->GetAnimator());
+ animation.SetTransitionDuration(
+ base::TimeDelta::FromMilliseconds(duration_ms));
+ animation.SetTweenType(ui::Tween::EASE_IN);
+ model_view_->SetTransform(GetScaleTransform(model_view_));
+}
+
+void AppListView::Close() {
+ if (delegate_.get())
+ delegate_->Close();
+ else
+ GetWidget()->Close();
+}
+
+void AppListView::UpdateBounds(const gfx::Rect& screen_bounds,
+ const gfx::Rect& work_area) {
+ if (bubble_style_) {
+ SizeToContents();
+ } else {
+ work_area_ = work_area;
+ GetWidget()->SetBounds(screen_bounds);
+ }
+}
+
void AppListView::UpdateModel() {
if (delegate_.get()) {
scoped_ptr<AppListModel> new_model(new AppListModel);
@@ -200,10 +190,7 @@ void AppListView::Layout() {
views::View::Layout();
} else {
// Gets work area rect, which is in screen coordinates.
- gfx::Rect workarea = Shell::GetInstance()->shelf()->IsVisible() ?
- ScreenAsh::GetUnmaximizedWorkAreaBounds(GetWidget()->GetNativeView()) :
- gfx::Screen::GetMonitorNearestWindow(
- GetWidget()->GetNativeView()).work_area();
+ gfx::Rect workarea(work_area_);
// Converts |workarea| into view's coordinates.
gfx::Point origin(workarea.origin());
@@ -285,4 +272,4 @@ gfx::Rect AppListView::GetBubbleBounds() {
return bubble_rect;
}
-} // namespace ash
+} // namespace app_list
diff --git a/ash/app_list/app_list_view.h b/ui/app_list/app_list_view.h
index 73e9543..cb938c63 100644
--- a/ash/app_list/app_list_view.h
+++ b/ui/app_list/app_list_view.h
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_APP_LIST_APP_LIST_VIEW_H_
-#define ASH_APP_LIST_APP_LIST_VIEW_H_
+#ifndef UI_APP_LIST_APP_LIST_VIEW_H_
+#define UI_APP_LIST_APP_LIST_VIEW_H_
#pragma once
#include "base/memory/scoped_ptr.h"
+#include "ui/app_list/app_list_export.h"
#include "ui/views/bubble/bubble_delegate.h"
#include "ui/views/controls/button/button.h"
@@ -14,7 +15,7 @@ namespace views {
class View;
}
-namespace ash {
+namespace app_list {
class AppListBubbleBorder;
class AppListModel;
@@ -24,24 +25,27 @@ class PaginationModel;
// AppListView is the top-level view and controller of app list UI. It creates
// and hosts a AppListModelView and passes AppListModel to it for display.
-class AppListView : public views::BubbleDelegateView,
- public views::ButtonListener {
+class APP_LIST_EXPORT AppListView : public views::BubbleDelegateView,
+ public views::ButtonListener {
public:
// Takes ownership of |delegate|.
explicit AppListView(AppListViewDelegate* delegate);
virtual ~AppListView();
+ // Initializes the widget.
+ void InitAsFullscreenWidget(gfx::NativeView parent,
+ const gfx::Rect& screen_bounds,
+ const gfx::Rect& work_area);
+ void InitAsBubble(gfx::NativeView parent, views::View* anchor);
+
void AnimateShow(int duration_ms);
void AnimateHide(int duration_ms);
void Close();
- void UpdateBounds();
+ void UpdateBounds(const gfx::Rect& screen_bounds,
+ const gfx::Rect& work_area);
private:
- // Initializes the window.
- void InitAsFullscreenWidget();
- void InitAsBubble();
-
// Updates model using query text in search box.
void UpdateModel();
@@ -70,9 +74,13 @@ class AppListView : public views::BubbleDelegateView,
AppListBubbleBorder* bubble_border_; // Owned by views hierarchy.
AppListModelView* model_view_;
+ // Work area in screen coordinates to layout app list. This is used for
+ // full screen mode.
+ gfx::Rect work_area_;
+
DISALLOW_COPY_AND_ASSIGN(AppListView);
};
-} // namespace ash
+} // namespace app_list
-#endif // ASH_APP_LIST_APP_LIST_VIEW_H_
+#endif // UI_APP_LIST_APP_LIST_VIEW_H_
diff --git a/ash/app_list/app_list_view_delegate.h b/ui/app_list/app_list_view_delegate.h
index 1950a12..57ca3ac 100644
--- a/ash/app_list/app_list_view_delegate.h
+++ b/ui/app_list/app_list_view_delegate.h
@@ -2,20 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
-#define ASH_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
+#ifndef UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
+#define UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
#pragma once
#include <string>
-#include "ash/ash_export.h"
+#include "ui/app_list/app_list_export.h"
-namespace ash {
+namespace app_list {
class AppListItemModel;
class AppListModel;
-class ASH_EXPORT AppListViewDelegate {
+class APP_LIST_EXPORT AppListViewDelegate {
public:
// AppListView owns the delegate.
virtual ~AppListViewDelegate() {}
@@ -30,8 +30,11 @@ class ASH_EXPORT AppListViewDelegate {
// Invoked an AppListeItemModelView is activated by click or enter key.
virtual void OnAppListItemActivated(AppListItemModel* item,
int event_flags) = 0;
+
+ // Invoked to close app list.
+ virtual void Close() = 0;
};
-} // namespace ash
+} // namespace app_list
-#endif // ASH_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
+#endif // UI_APP_LIST_APP_LIST_VIEW_DELEGATE_H_
diff --git a/ash/app_list/drop_shadow_label.cc b/ui/app_list/drop_shadow_label.cc
index c897e2a..64cffbb 100644
--- a/ash/app_list/drop_shadow_label.cc
+++ b/ui/app_list/drop_shadow_label.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 "ash/app_list/drop_shadow_label.h"
+#include "ui/app_list/drop_shadow_label.h"
#include "base/utf_string_conversions.h"
#include "third_party/skia/include/effects/SkGradientShader.h"
@@ -13,7 +13,7 @@
using views::Label;
-namespace ash {
+namespace app_list {
DropShadowLabel::DropShadowLabel() {
}
@@ -60,4 +60,4 @@ void DropShadowLabel::PaintText(gfx::Canvas* canvas,
}
}
-} // namespace ash
+} // namespace app_list
diff --git a/ash/app_list/drop_shadow_label.h b/ui/app_list/drop_shadow_label.h
index 25a24e1..faee5f0 100644
--- a/ash/app_list/drop_shadow_label.h
+++ b/ui/app_list/drop_shadow_label.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 ASH_APP_LIST_DROP_SHADOW_LABEL_H_
-#define ASH_APP_LIST_DROP_SHADOW_LABEL_H_
+#ifndef UI_APP_LIST_DROP_SHADOW_LABEL_H_
+#define UI_APP_LIST_DROP_SHADOW_LABEL_H_
#pragma once
#include <vector>
@@ -11,7 +11,7 @@
#include "ui/gfx/shadow_value.h"
#include "ui/views/controls/label.h"
-namespace ash {
+namespace app_list {
/////////////////////////////////////////////////////////////////////////////
//
@@ -41,6 +41,6 @@ class DropShadowLabel : public views::Label {
DISALLOW_COPY_AND_ASSIGN(DropShadowLabel);
};
-} // namespace ash
+} // namespace app_list
-#endif // ASH_APP_LIST_DROP_SHADOW_LABEL_H_
+#endif // UI_APP_LIST_DROP_SHADOW_LABEL_H_
diff --git a/ash/app_list/icon_cache.cc b/ui/app_list/icon_cache.cc
index 92fdd90..b0b9997 100644
--- a/ash/app_list/icon_cache.cc
+++ b/ui/app_list/icon_cache.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 "ash/app_list/icon_cache.h"
+#include "ui/app_list/icon_cache.h"
#include "base/logging.h"
#include "base/md5.h"
@@ -21,7 +21,7 @@ std::string GetKey(const SkBitmap& image, const gfx::Size& size) {
} // namespace
-namespace ash {
+namespace app_list {
// static
IconCache* IconCache::instance_ = NULL;
@@ -87,4 +87,4 @@ IconCache::IconCache() {
IconCache::~IconCache() {
}
-} // namespace ash
+} // namespace app_list
diff --git a/ash/app_list/icon_cache.h b/ui/app_list/icon_cache.h
index f06ac1d..75ffa067 100644
--- a/ash/app_list/icon_cache.h
+++ b/ui/app_list/icon_cache.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 ASH_APP_LIST_ICON_CACHE_H_
-#define ASH_APP_LIST_ICON_CACHE_H_
+#ifndef UI_APP_LIST_ICON_CACHE_H_
+#define UI_APP_LIST_ICON_CACHE_H_
#pragma once
#include <map>
@@ -11,15 +11,16 @@
#include "base/basictypes.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/app_list/app_list_export.h"
namespace gfx {
class Size;
}
-namespace ash {
+namespace app_list {
// IconCache stores processed image, keyed by the source image and desired size.
-class IconCache {
+class APP_LIST_EXPORT IconCache {
public:
static void CreateInstance();
static void DeleteInstance();
@@ -53,6 +54,6 @@ class IconCache {
DISALLOW_COPY_AND_ASSIGN(IconCache);
};
-} // namespace ash
+} // namespace app_list
-#endif // ASH_APP_LIST_ICON_CACHE_H_
+#endif // UI_APP_LIST_ICON_CACHE_H_
diff --git a/ash/app_list/page_switcher.cc b/ui/app_list/page_switcher.cc
index 275cc09..a35c8be 100644
--- a/ash/app_list/page_switcher.cc
+++ b/ui/app_list/page_switcher.cc
@@ -2,10 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/app_list/page_switcher.h"
+#include "ui/app_list/page_switcher.h"
-#include "ash/app_list/pagination_model.h"
#include "third_party/skia/include/core/SkPath.h"
+#include "ui/app_list/pagination_model.h"
#include "ui/base/animation/throb_animation.h"
#include "ui/gfx/canvas.h"
#include "ui/views/controls/button/custom_button.h"
@@ -30,7 +30,7 @@ const SkColor kSelectedColor = SkColorSetARGB(0x55, 0x00, 0x00, 0x00);
class PageSwitcherButton : public views::CustomButton {
public:
- PageSwitcherButton(views::ButtonListener* listener)
+ explicit PageSwitcherButton(views::ButtonListener* listener)
: views::CustomButton(listener),
selected_(false) {
}
@@ -97,7 +97,7 @@ PageSwitcherButton* GetButtonByIndex(views::View* buttons, int index) {
} // namespace
-namespace ash {
+namespace app_list {
PageSwitcher::PageSwitcher(PaginationModel* model)
: model_(model),
@@ -155,4 +155,4 @@ void PageSwitcher::SelectedPageChanged(int old_selected, int new_selected) {
GetButtonByIndex(buttons_, new_selected)->SetSelected(true);
}
-} // namespace ash
+} // namespace app_list
diff --git a/ash/app_list/page_switcher.h b/ui/app_list/page_switcher.h
index 36168df..46c534e 100644
--- a/ash/app_list/page_switcher.h
+++ b/ui/app_list/page_switcher.h
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_APP_LIST_PAGE_SWITCHER_H_
-#define ASH_APP_LIST_PAGE_SWITCHER_H_
+#ifndef UI_APP_LIST_PAGE_SWITCHER_H_
+#define UI_APP_LIST_PAGE_SWITCHER_H_
#pragma once
-#include "ash/app_list/pagination_model_observer.h"
#include "base/basictypes.h"
+#include "ui/app_list/pagination_model_observer.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/view.h"
-namespace ash {
+namespace app_list {
class PaginationModel;
@@ -44,6 +44,6 @@ class PageSwitcher : public views::View,
DISALLOW_COPY_AND_ASSIGN(PageSwitcher);
};
-} // namespace ash
+} // namespace app_list
-#endif // ASH_APP_LIST_PAGE_SWITCHER_H_
+#endif // UI_APP_LIST_PAGE_SWITCHER_H_
diff --git a/ash/app_list/pagination_model.cc b/ui/app_list/pagination_model.cc
index 413a632..64556a5 100644
--- a/ash/app_list/pagination_model.cc
+++ b/ui/app_list/pagination_model.cc
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ash/app_list/pagination_model.h"
+#include "ui/app_list/pagination_model.h"
-#include "ash/app_list/pagination_model_observer.h"
+#include "ui/app_list/pagination_model_observer.h"
-namespace ash {
+namespace app_list {
PaginationModel::PaginationModel()
: total_pages_(-1),
@@ -47,4 +47,4 @@ void PaginationModel::RemoveObserver(PaginationModelObserver* observer) {
observers_.RemoveObserver(observer);
}
-} // namespace ash
+} // namespace app_list
diff --git a/ash/app_list/pagination_model.h b/ui/app_list/pagination_model.h
index 981c229..39820d8 100644
--- a/ash/app_list/pagination_model.h
+++ b/ui/app_list/pagination_model.h
@@ -2,22 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_APP_LIST_PAGINATION_MODEL_H_
-#define ASH_APP_LIST_PAGINATION_MODEL_H_
+#ifndef UI_APP_LIST_PAGINATION_MODEL_H_
+#define UI_APP_LIST_PAGINATION_MODEL_H_
#pragma once
-#include "ash/ash_export.h"
+#include "ui/app_list/app_list_export.h"
#include "base/basictypes.h"
#include "base/observer_list.h"
-namespace ash {
+namespace app_list {
class PaginationModelObserver;
// A simple pagination model that consists of two numbers: the total pages and
// the currently selected page. The model is a single selection model that at
// the most one page can become selected at any time.
-class ASH_EXPORT PaginationModel {
+class APP_LIST_EXPORT PaginationModel {
public:
PaginationModel();
~PaginationModel();
@@ -44,6 +44,6 @@ class ASH_EXPORT PaginationModel {
DISALLOW_COPY_AND_ASSIGN(PaginationModel);
};
-} // namespace ash
+} // namespace app_list
-#endif // ASH_APP_LIST_PAGINATION_MODEL_H_
+#endif // UI_APP_LIST_PAGINATION_MODEL_H_
diff --git a/ash/app_list/pagination_model_observer.h b/ui/app_list/pagination_model_observer.h
index 44136e8..10e670d 100644
--- a/ash/app_list/pagination_model_observer.h
+++ b/ui/app_list/pagination_model_observer.h
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef ASH_APP_LIST_PAGINATION_MODEL_OBSERVER_H_
-#define ASH_APP_LIST_PAGINATION_MODEL_OBSERVER_H_
+#ifndef UI_APP_LIST_PAGINATION_MODEL_OBSERVER_H_
+#define UI_APP_LIST_PAGINATION_MODEL_OBSERVER_H_
#pragma once
-#include "ash/ash_export.h"
+#include "ui/app_list/app_list_export.h"
-namespace ash {
+namespace app_list {
-class ASH_EXPORT PaginationModelObserver {
+class APP_LIST_EXPORT PaginationModelObserver {
public:
// Invoked when the total number of page is changed.
virtual void TotalPagesChanged() = 0;
@@ -22,6 +22,6 @@ class ASH_EXPORT PaginationModelObserver {
virtual ~PaginationModelObserver() {}
};
-} // namespace ash
+} // namespace app_list
-#endif // ASH_APP_LIST_PAGINATION_MODEL_OBSERVER_H_
+#endif // UI_APP_LIST_PAGINATION_MODEL_OBSERVER_H_
diff --git a/ui/app_list/run_all_unittests.cc b/ui/app_list/run_all_unittests.cc
new file mode 100644
index 0000000..2c8d29c
--- /dev/null
+++ b/ui/app_list/run_all_unittests.cc
@@ -0,0 +1,9 @@
+// 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 "base/test/test_suite.h"
+
+int main(int argc, char** argv) {
+ return base::TestSuite(argc, argv).Run();
+}