Update path of checkdeps to buildtools checkout
[chromium-blink-merge.git] / ui / app_list / views / app_list_view.h
blobc3effe963206fe00789694ebbeb7ef4cba516d77
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 app_list {
26 class ApplicationDragAndDropHost;
27 class AppListMainView;
28 class AppListModel;
29 class AppListViewDelegate;
30 class AppListViewObserver;
31 class HideViewAnimationObserver;
32 class PaginationModel;
33 class SigninDelegate;
34 class SigninView;
35 class SpeechView;
37 // AppListView is the top-level view and controller of app list UI. It creates
38 // and hosts a AppsGridView and passes AppListModel to it for display.
39 class APP_LIST_EXPORT AppListView : public views::BubbleDelegateView,
40 public AppListViewDelegateObserver,
41 public SpeechUIModelObserver {
42 public:
43 // Takes ownership of |delegate|.
44 explicit AppListView(AppListViewDelegate* delegate);
45 virtual ~AppListView();
47 // Initializes the widget and use a given |anchor| plus an |anchor_offset| for
48 // positioning.
49 void InitAsBubbleAttachedToAnchor(gfx::NativeView parent,
50 PaginationModel* pagination_model,
51 views::View* anchor,
52 const gfx::Vector2d& anchor_offset,
53 views::BubbleBorder::Arrow arrow,
54 bool border_accepts_events);
56 // Initializes the widget and use a fixed |anchor_point_in_screen| for
57 // positioning.
58 void InitAsBubbleAtFixedLocation(gfx::NativeView parent,
59 PaginationModel* pagination_model,
60 const gfx::Point& anchor_point_in_screen,
61 views::BubbleBorder::Arrow arrow,
62 bool border_accepts_events);
64 void SetBubbleArrow(views::BubbleBorder::Arrow arrow);
66 void SetAnchorPoint(const gfx::Point& anchor_point);
68 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop
69 // operations outside the application list. This has to be called after
70 // InitAsBubble was called since the app list object needs to exist so that
71 // it can set the host.
72 void SetDragAndDropHostOfCurrentAppList(
73 ApplicationDragAndDropHost* drag_and_drop_host);
75 // Shows the UI when there are no pending icon loads. Otherwise, starts a
76 // timer to show the UI when a maximum allowed wait time has expired.
77 void ShowWhenReady();
79 void Close();
81 void UpdateBounds();
83 // Enables/disables a semi-transparent overlay over the app list (good for
84 // hiding the app list when a modal dialog is being shown).
85 void SetAppListOverlayVisible(bool visible);
87 // Returns true if the app list should be centered and in landscape mode.
88 bool ShouldCenterWindow() const;
90 // Overridden from views::View:
91 virtual gfx::Size GetPreferredSize() const OVERRIDE;
92 virtual void Paint(gfx::Canvas* canvas,
93 const views::CullSet& cull_set) OVERRIDE;
94 virtual void OnThemeChanged() OVERRIDE;
96 // WidgetDelegate overrides:
97 virtual bool ShouldHandleSystemCommands() const OVERRIDE;
99 // Overridden from AppListViewDelegateObserver:
100 virtual void OnProfilesChanged() OVERRIDE;
102 void Prerender();
104 void SetProfileByPath(const base::FilePath& profile_path);
106 void AddObserver(AppListViewObserver* observer);
107 void RemoveObserver(AppListViewObserver* observer);
109 // Set a callback to be called the next time any app list paints.
110 void SetNextPaintCallback(const base::Closure& callback);
112 #if defined(OS_WIN)
113 HWND GetHWND() const;
114 #endif
116 AppListMainView* app_list_main_view() { return app_list_main_view_; }
118 private:
119 friend class ::test::AppListViewTestApi;
121 void InitAsBubbleInternal(gfx::NativeView parent,
122 PaginationModel* pagination_model,
123 views::BubbleBorder::Arrow arrow,
124 bool border_accepts_events,
125 const gfx::Vector2d& anchor_offset);
127 // Overridden from views::BubbleDelegateView:
128 virtual void OnBeforeBubbleWidgetInit(
129 views::Widget::InitParams* params,
130 views::Widget* widget) const OVERRIDE;
132 // Overridden from views::WidgetDelegateView:
133 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
134 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE;
135 virtual bool WidgetHasHitTestMask() const OVERRIDE;
136 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE;
138 // Overridden from views::View:
139 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
140 virtual void Layout() OVERRIDE;
141 virtual void SchedulePaintInRect(const gfx::Rect& rect) OVERRIDE;
143 // Overridden from views::WidgetObserver:
144 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
145 virtual void OnWidgetVisibilityChanged(
146 views::Widget* widget, bool visible) OVERRIDE;
147 virtual void OnWidgetActivationChanged(
148 views::Widget* widget, bool active) OVERRIDE;
150 // Overridden from SpeechUIModelObserver:
151 virtual void OnSpeechRecognitionStateChanged(
152 SpeechRecognitionState new_state) OVERRIDE;
154 SigninDelegate* GetSigninDelegate();
156 scoped_ptr<AppListViewDelegate> delegate_;
158 AppListMainView* app_list_main_view_;
159 SigninView* signin_view_;
160 SpeechView* speech_view_;
162 // A semi-transparent white overlay that covers the app list while dialogs are
163 // open.
164 views::View* overlay_view_;
166 ObserverList<AppListViewObserver> observers_;
167 scoped_ptr<HideViewAnimationObserver> animation_observer_;
169 // For UMA and testing. If non-null, triggered when the app list is painted.
170 base::Closure next_paint_callback_;
172 DISALLOW_COPY_AND_ASSIGN(AppListView);
175 } // namespace app_list
177 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_