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