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_forward.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_model_observer.h"
13 #include "ui/views/bubble/bubble_delegate.h"
24 class ApplicationDragAndDropHost
;
25 class AppListMainView
;
27 class AppListViewDelegate
;
28 class PaginationModel
;
32 // AppListView is the top-level view and controller of app list UI. It creates
33 // and hosts a AppsGridView and passes AppListModel to it for display.
34 class APP_LIST_EXPORT AppListView
: public views::BubbleDelegateView
,
35 public AppListModelObserver
{
39 virtual void OnActivationChanged(views::Widget
* widget
, bool active
) = 0;
42 // Takes ownership of |delegate|.
43 explicit AppListView(AppListViewDelegate
* delegate
);
44 virtual ~AppListView();
46 // Initializes the widget and use a given |anchor| plus an |anchor_offset| for
48 void InitAsBubbleAttachedToAnchor(gfx::NativeView parent
,
49 PaginationModel
* pagination_model
,
51 const gfx::Vector2d
& anchor_offset
,
52 views::BubbleBorder::Arrow arrow
,
53 bool border_accepts_events
);
55 // Initializes the widget and use a fixed |anchor_point_in_screen| for
57 void InitAsBubbleAtFixedLocation(gfx::NativeView parent
,
58 PaginationModel
* pagination_model
,
59 const gfx::Point
& anchor_point_in_screen
,
60 views::BubbleBorder::Arrow arrow
,
61 bool border_accepts_events
);
63 void SetBubbleArrow(views::BubbleBorder::Arrow arrow
);
65 void SetAnchorPoint(const gfx::Point
& anchor_point
);
67 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop
68 // operations outside the application list. This has to be called after
69 // InitAsBubble was called since the app list object needs to exist so that
70 // it can set the host.
71 void SetDragAndDropHostOfCurrentAppList(
72 ApplicationDragAndDropHost
* drag_and_drop_host
);
74 // Shows the UI when there are no pending icon loads. Otherwise, starts a
75 // timer to show the UI when a maximum allowed wait time has expired.
82 // Overridden from views::View:
83 virtual gfx::Size
GetPreferredSize() OVERRIDE
;
84 virtual void Paint(gfx::Canvas
* canvas
) OVERRIDE
;
86 // WidgetDelegate overrides:
87 virtual bool ShouldHandleSystemCommands() const OVERRIDE
;
91 // Invoked when the sign-in status is changed to switch on/off sign-in view.
92 void OnSigninStatusChanged();
94 void SetProfileByPath(const base::FilePath
& profile_path
);
96 void AddObserver(Observer
* observer
);
97 void RemoveObserver(Observer
* observer
);
99 // Set a callback to be called the next time any app list paints.
100 static void SetNextPaintCallback(const base::Closure
& callback
);
103 HWND
GetHWND() const;
106 AppListModel
* model() { return model_
.get(); }
107 AppListMainView
* app_list_main_view() { return app_list_main_view_
; }
110 void InitAsBubbleInternal(gfx::NativeView parent
,
111 PaginationModel
* pagination_model
,
112 views::BubbleBorder::Arrow arrow
,
113 bool border_accepts_events
,
114 const gfx::Vector2d
& anchor_offset
);
116 // Overridden from views::WidgetDelegateView:
117 virtual views::View
* GetInitiallyFocusedView() OVERRIDE
;
118 virtual gfx::ImageSkia
GetWindowIcon() OVERRIDE
;
119 virtual bool WidgetHasHitTestMask() const OVERRIDE
;
120 virtual void GetWidgetHitTestMask(gfx::Path
* mask
) const OVERRIDE
;
122 // Overridden from views::View:
123 virtual bool AcceleratorPressed(const ui::Accelerator
& accelerator
) OVERRIDE
;
124 virtual void Layout() OVERRIDE
;
126 // Overridden from views::WidgetObserver:
127 virtual void OnWidgetDestroying(views::Widget
* widget
) OVERRIDE
;
128 virtual void OnWidgetVisibilityChanged(
129 views::Widget
* widget
, bool visible
) OVERRIDE
;
130 virtual void OnWidgetActivationChanged(
131 views::Widget
* widget
, bool active
) OVERRIDE
;
133 // Overridden from AppListModelObserver:
134 virtual void OnAppListModelSigninStatusChanged() OVERRIDE
;
135 virtual void OnAppListModelUsersChanged() OVERRIDE
;
137 SigninDelegate
* GetSigninDelegate();
139 scoped_ptr
<AppListModel
> model_
;
140 scoped_ptr
<AppListViewDelegate
> delegate_
;
142 AppListMainView
* app_list_main_view_
;
143 SigninView
* signin_view_
;
145 ObserverList
<Observer
> observers_
;
147 DISALLOW_COPY_AND_ASSIGN(AppListView
);
150 } // namespace app_list
152 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_