Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ui / app_list / views / app_list_view.h
blob27e6e8abe23a070c2303dcb5632595e55e145fd3
1 // Copyright (c) 2012 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.
5 #ifndef UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_
6 #define UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_
8 #include "base/callback.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/observer_list.h"
11 #include "ui/app_list/app_list_export.h"
12 #include "ui/app_list/app_list_view_delegate_observer.h"
13 #include "ui/app_list/speech_ui_model_observer.h"
14 #include "ui/views/bubble/bubble_delegate.h"
15 #include "ui/views/widget/widget.h"
17 namespace base {
18 class FilePath;
21 namespace test {
22 class AppListViewTestApi;
25 namespace views {
26 class ImageView;
29 namespace app_list {
30 class ApplicationDragAndDropHost;
31 class AppListMainView;
32 class AppListModel;
33 class AppListViewDelegate;
34 class AppListViewObserver;
35 class HideViewAnimationObserver;
36 class PaginationModel;
37 class SearchBoxView;
38 class SpeechView;
40 // AppListView is the top-level view and controller of app list UI. It creates
41 // and hosts a AppsGridView and passes AppListModel to it for display.
42 class APP_LIST_EXPORT AppListView : public views::BubbleDelegateView,
43 public AppListViewDelegateObserver,
44 public SpeechUIModelObserver {
45 public:
46 // Does not take ownership of |delegate|.
47 explicit AppListView(AppListViewDelegate* delegate);
48 ~AppListView() override;
50 // Initializes the widget and use a given |anchor| plus an |anchor_offset| for
51 // positioning.
52 void InitAsBubbleAttachedToAnchor(gfx::NativeView parent,
53 int initial_apps_page,
54 views::View* anchor,
55 const gfx::Vector2d& anchor_offset,
56 views::BubbleBorder::Arrow arrow,
57 bool border_accepts_events);
59 // Initializes the widget and use a fixed |anchor_point_in_screen| for
60 // positioning.
61 void InitAsBubbleAtFixedLocation(gfx::NativeView parent,
62 int initial_apps_page,
63 const gfx::Point& anchor_point_in_screen,
64 views::BubbleBorder::Arrow arrow,
65 bool border_accepts_events);
67 // Initializes the widget as a frameless window, not a bubble.
68 void InitAsFramelessWindow(gfx::NativeView parent,
69 int initial_apps_page,
70 gfx::Rect bounds);
72 void SetBubbleArrow(views::BubbleBorder::Arrow arrow);
74 void SetAnchorPoint(const gfx::Point& anchor_point);
76 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop
77 // operations outside the application list. This has to be called after
78 // InitAsBubble was called since the app list object needs to exist so that
79 // it can set the host.
80 void SetDragAndDropHostOfCurrentAppList(
81 ApplicationDragAndDropHost* drag_and_drop_host);
83 // Shows the UI when there are no pending icon loads. Otherwise, starts a
84 // timer to show the UI when a maximum allowed wait time has expired.
85 void ShowWhenReady();
87 void Close();
89 void UpdateBounds();
91 // Enables/disables a semi-transparent overlay over the app list (good for
92 // hiding the app list when a modal dialog is being shown).
93 void SetAppListOverlayVisible(bool visible);
95 // Returns true if the app list should be centered and in landscape mode.
96 bool ShouldCenterWindow() const;
98 views::Widget* search_box_widget() const { return search_box_widget_; }
100 // Overridden from views::View:
101 gfx::Size GetPreferredSize() const override;
102 void OnPaint(gfx::Canvas* canvas) override;
103 void OnThemeChanged() override;
105 // WidgetDelegate overrides:
106 bool ShouldHandleSystemCommands() const override;
107 bool ShouldDescendIntoChildForEventHandling(
108 gfx::NativeView child,
109 const gfx::Point& location) override;
111 // Overridden from AppListViewDelegateObserver:
112 void OnProfilesChanged() override;
113 void OnShutdown() override;
115 void Prerender();
117 void SetProfileByPath(const base::FilePath& profile_path);
119 void AddObserver(AppListViewObserver* observer);
120 void RemoveObserver(AppListViewObserver* observer);
122 // Set a callback to be called the next time any app list paints.
123 void SetNextPaintCallback(const base::Closure& callback);
125 #if defined(OS_WIN)
126 HWND GetHWND() const;
127 #endif
129 AppListMainView* app_list_main_view() { return app_list_main_view_; }
131 // Gets the PaginationModel owned by this view's apps grid.
132 PaginationModel* GetAppsPaginationModel();
134 // Overridden from views::View:
135 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
136 void Layout() override;
137 void SchedulePaintInRect(const gfx::Rect& rect) override;
139 private:
140 friend class ::test::AppListViewTestApi;
142 void InitContents(gfx::NativeView parent, int initial_apps_page);
144 void InitChildWidgets();
146 void InitAsBubbleInternal(gfx::NativeView parent,
147 int initial_apps_page,
148 views::BubbleBorder::Arrow arrow,
149 bool border_accepts_events,
150 const gfx::Vector2d& anchor_offset);
152 // Overridden from views::BubbleDelegateView:
153 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params,
154 views::Widget* widget) const override;
156 // Overridden from views::WidgetDelegateView:
157 views::View* GetInitiallyFocusedView() override;
158 gfx::ImageSkia GetWindowIcon() override;
159 bool WidgetHasHitTestMask() const override;
160 void GetWidgetHitTestMask(gfx::Path* mask) const override;
162 // Overridden from views::WidgetObserver:
163 void OnWidgetDestroying(views::Widget* widget) override;
164 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override;
165 void OnWidgetActivationChanged(views::Widget* widget, bool active) override;
167 // Overridden from SpeechUIModelObserver:
168 void OnSpeechRecognitionStateChanged(
169 SpeechRecognitionState new_state) override;
171 AppListViewDelegate* delegate_; // Weak. Owned by AppListService.
173 AppListMainView* app_list_main_view_;
174 SpeechView* speech_view_;
176 views::View* search_box_focus_host_; // Owned by the views hierarchy.
177 views::Widget* search_box_widget_; // Owned by the app list's widget.
178 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|.
180 // A semi-transparent white overlay that covers the app list while dialogs are
181 // open.
182 views::View* overlay_view_;
184 ObserverList<AppListViewObserver> observers_;
185 scoped_ptr<HideViewAnimationObserver> animation_observer_;
187 // For UMA and testing. If non-null, triggered when the app list is painted.
188 base::Closure next_paint_callback_;
190 DISALLOW_COPY_AND_ASSIGN(AppListView);
193 } // namespace app_list
195 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_