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

Side by Side Diff: chrome/browser/ui/app_list/app_list_shower_views.h

Issue 225053004: Refactor views app list services to allow more code sharing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase+sim30 Created 6 years, 7 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SHOWER_H_ 5 #ifndef CHROME_BROWSER_UI_APP_LIST_APP_LIST_SHOWER_VIEWS_H_
6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SHOWER_H_ 6 #define CHROME_BROWSER_UI_APP_LIST_APP_LIST_SHOWER_VIEWS_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "chrome/browser/ui/app_list/app_list.h"
10 #include "chrome/browser/ui/app_list/app_list_factory.h"
11 #include "ui/app_list/pagination_model.h" 9 #include "ui/app_list/pagination_model.h"
12 #include "ui/gfx/native_widget_types.h" 10 #include "ui/gfx/native_widget_types.h"
13 11
14 namespace app_list { 12 namespace app_list {
15 class AppListModel; 13 class AppListView;
16 } 14 }
17 15
16 class AppListShowerDelegate;
18 class AppListShowerUnitTest; 17 class AppListShowerUnitTest;
19 class Profile; 18 class Profile;
20 class ScopedKeepAlive; 19 class ScopedKeepAlive;
21 20
22 // Creates and shows an AppList as needed for non-Ash desktops. It is owned 21 // Creates and shows an AppList as needed for non-Ash desktops. It is owned by
23 // by AppListService. 22 // AppListServiceViews.
24 class AppListShower { 23 class AppListShower {
25 public: 24 public:
26 AppListShower(scoped_ptr<AppListFactory> factory, 25 explicit AppListShower(AppListShowerDelegate* delegate);
27 AppListService* service); 26 virtual ~AppListShower();
28 ~AppListShower();
29
30 void set_can_close(bool can_close) {
31 can_close_app_list_ = can_close;
32 }
33 27
34 void ShowForProfile(Profile* requested_profile); 28 void ShowForProfile(Profile* requested_profile);
35 gfx::NativeWindow GetWindow(); 29 gfx::NativeWindow GetWindow();
36 30
37 AppList* app_list() { return app_list_.get(); } 31 app_list::AppListView* app_list() { return app_list_; }
38 Profile* profile() const { return profile_; } 32 Profile* profile() const { return profile_; }
39 33
40 // Create or recreate, and initialize |app_list_| from |requested_profile|. 34 // Create or recreate, and initialize |app_list_| from |requested_profile|.
41 void CreateViewForProfile(Profile* requested_profile); 35 void CreateViewForProfile(Profile* requested_profile);
42 36
43 void DismissAppList(); 37 void DismissAppList();
44 void HandleViewBeingDestroyed(); 38
45 bool IsAppListVisible() const; 39 // Virtual functions mocked out in tests.
40 virtual void HandleViewBeingDestroyed();
41 virtual bool IsAppListVisible() const;
46 void WarmupForProfile(Profile* profile); 42 void WarmupForProfile(Profile* profile);
47 bool HasView() 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();
48 52
49 private: 53 private:
50 friend class ::AppListShowerUnitTest; 54 friend class ::AppListShowerUnitTest;
51 55
52 void ResetKeepAlive(); 56 void ResetKeepAlive();
53 57
54 scoped_ptr<AppListFactory> factory_; 58 AppListShowerDelegate* delegate_; // Weak. Owns this.
55 scoped_ptr<ScopedKeepAlive> keep_alive_; 59
56 scoped_ptr<AppList> app_list_; 60 // The profile currently shown by |app_list_|.
57 AppListService* service_; // Weak ptr, owns this.
58 Profile* profile_; 61 Profile* profile_;
59 bool can_close_app_list_; 62
63 // The view, once created. Owned by native widget.
64 app_list::AppListView* app_list_;
60 65
61 // Used to keep the browser process alive while the app list is visible. 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 app_list::PaginationModel pagination_model_;
62 71
63 DISALLOW_COPY_AND_ASSIGN(AppListShower); 72 DISALLOW_COPY_AND_ASSIGN(AppListShower);
64 }; 73 };
65 74
66 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SHOWER_H_ 75 #endif // CHROME_BROWSER_UI_APP_LIST_APP_LIST_SHOWER_VIEWS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698