app_list_shower_views.h revision 03b57e008b61dfcb1fbad3aea950ae0e001748b0
1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SHOWER_VIEWS_H_
6#define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SHOWER_VIEWS_H_
7
8#include "base/memory/scoped_ptr.h"
9#include "ui/gfx/native_widget_types.h"
10
11namespace app_list {
12class AppListView;
13}
14
15class AppListShowerDelegate;
16class AppListShowerUnitTest;
17class Profile;
18class ScopedKeepAlive;
19
20// Creates and shows an AppList as needed for non-Ash desktops. It is owned by
21// AppListServiceViews.
22class AppListShower {
23 public:
24  explicit AppListShower(AppListShowerDelegate* delegate);
25  virtual ~AppListShower();
26
27  void ShowForProfile(Profile* requested_profile);
28  gfx::NativeWindow GetWindow();
29
30  app_list::AppListView* app_list() { return app_list_; }
31  Profile* profile() const { return profile_; }
32
33  // Create or recreate, and initialize |app_list_| from |requested_profile|.
34  void CreateViewForProfile(Profile* requested_profile);
35
36  void DismissAppList();
37
38  // Virtual functions mocked out in tests.
39  virtual void HandleViewBeingDestroyed();
40  virtual bool IsAppListVisible() const;
41  void WarmupForProfile(Profile* profile);
42  virtual bool HasView() const;
43
44 protected:
45  virtual app_list::AppListView* MakeViewForCurrentProfile();
46  virtual void UpdateViewForNewProfile();
47
48  // Shows the app list, activates it, and ensures the taskbar icon is updated.
49  virtual void Show();
50  virtual void Hide();
51
52 private:
53  friend class ::AppListShowerUnitTest;
54
55  void ResetKeepAliveSoon();
56  void ResetKeepAlive();
57
58  AppListShowerDelegate* delegate_;  // Weak. Owns this.
59
60  // The profile currently shown by |app_list_|.
61  Profile* profile_;
62
63  // The view, once created. Owned by native widget.
64  app_list::AppListView* app_list_;
65
66  // Used to keep the browser process alive while the app list is visible.
67  scoped_ptr<ScopedKeepAlive> keep_alive_;
68
69  bool window_icon_updated_;
70
71  DISALLOW_COPY_AND_ASSIGN(AppListShower);
72};
73
74#endif  // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SHOWER_VIEWS_H_
75