Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6729)

Unified Diff: chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm

Issue 11784034: Skeleton for app_list on OSX, and refactoring for enable_app_list=1 on OS=="mac". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase for 175876 and 175961 Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm b/chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm
new file mode 100644
index 0000000000000000000000000000000000000000..dca65898f8189326bbb780028ef44f6a01ce1d2f
--- /dev/null
+++ b/chrome/browser/ui/cocoa/app_list/app_list_controller_cocoa.mm
@@ -0,0 +1,74 @@
+// 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 "base/bind.h"
+#include "base/lazy_instance.h"
+#include "base/memory/scoped_nsobject.h"
+#include "base/message_loop.h"
+#include "base/time.h"
+#include "base/timer.h"
+#include "chrome/browser/ui/app_list/app_list_util.h"
+#include "ui/app_list/cocoa/app_list_view_window.h"
+
+namespace {
+
+// The AppListController class manages global resources needed for the app
+// list to operate, and controls when the app list is opened and closed.
+class AppListController {
+ public:
+ AppListController() {}
+ ~AppListController() {}
+
+ void CreateAppList();
+ void ShowAppList();
+ void DismissAppList();
+ private:
+ scoped_nsobject<AppListViewWindow> current_window_;
+ base::OneShotTimer<AppListController> timer_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppListController);
+};
+
+base::LazyInstance<AppListController>::Leaky g_app_list_controller =
+ LAZY_INSTANCE_INITIALIZER;
+
+void AppListController::CreateAppList() {
+ current_window_.reset([[AppListViewWindow alloc] initAsBubble]);
+}
+
+void AppListController::ShowAppList() {
+ const int kLifetimeIntervalMS = 1000;
+
+ if (!current_window_)
+ CreateAppList();
+
+ timer_.Start(FROM_HERE,
+ base::TimeDelta::FromMilliseconds(kLifetimeIntervalMS), this,
+ &AppListController::DismissAppList);
+ [current_window_ makeKeyAndOrderFront:nil];
+}
+
+void AppListController::DismissAppList() {
+ if (!current_window_)
+ return;
+
+ timer_.Stop();
+ [current_window_ close];
+}
+
+} // namespace
+
+
+namespace chrome {
+
+void InitAppList() {
+ // TODO(tapted): AppList warmup code coes here.
+}
+
+void ShowAppList() {
+ // Create the App list.
+ g_app_list_controller.Get().ShowAppList();
+}
+
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698