Views Omnibox: tolerate minor click-to-select-all dragging.
[chromium-blink-merge.git] / ui / app_list / views / app_list_view.h
blob3e6196e97f3f9234a013e1c676705e00c518beba
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/memory/scoped_ptr.h"
9 #include "base/observer_list.h"
10 #include "ui/app_list/app_list_export.h"
11 #include "ui/app_list/app_list_view_delegate_observer.h"
12 #include "ui/app_list/speech_ui_model_observer.h"
13 #include "ui/views/bubble/bubble_delegate.h"
14 #include "ui/views/widget/widget.h"
16 namespace base {
17 class FilePath;
20 namespace app_list {
21 class ApplicationDragAndDropHost;
22 class AppListMainView;
23 class AppListModel;
24 class AppListViewDelegate;
25 class AppListViewObserver;
26 class HideViewAnimationObserver;
27 class PaginationModel;
28 class SigninDelegate;
29 class SigninView;
30 class SpeechView;
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 AppListViewDelegateObserver,
36 public SpeechUIModelObserver {
37 public:
39 // Takes ownership of |delegate|.
40 explicit AppListView(AppListViewDelegate* delegate);
41 virtual ~AppListView();
43 // Initializes the widget and use a given |anchor| plus an |anchor_offset| for
44 // positioning.
45 void InitAsBubbleAttachedToAnchor(gfx::NativeView parent,
46 PaginationModel* pagination_model,
47 views::View* anchor,
48 const gfx::Vector2d& anchor_offset,
49 views::BubbleBorder::Arrow arrow,
50 bool border_accepts_events);
52 // Initializes the widget and use a fixed |anchor_point_in_screen| for
53 // positioning.
54 void InitAsBubbleAtFixedLocation(gfx::NativeView parent,
55 PaginationModel* pagination_model,
56 const gfx::Point& anchor_point_in_screen,
57 views::BubbleBorder::Arrow arrow,
58 bool border_accepts_events);
60 void SetBubbleArrow(views::BubbleBorder::Arrow arrow);
62 void SetAnchorPoint(const gfx::Point& anchor_point);
64 // If |drag_and_drop_host| is not NULL it will be called upon drag and drop
65 // operations outside the application list. This has to be called after
66 // InitAsBubble was called since the app list object needs to exist so that
67 // it can set the host.
68 void SetDragAndDropHostOfCurrentAppList(
69 ApplicationDragAndDropHost* drag_and_drop_host);
71 // Shows the UI when there are no pending icon loads. Otherwise, starts a
72 // timer to show the UI when a maximum allowed wait time has expired.
73 void ShowWhenReady();
75 void Close();
77 void UpdateBounds();
79 // Overridden from views::View:
80 virtual gfx::Size GetPreferredSize() OVERRIDE;
81 virtual void Paint(gfx::Canvas* canvas) OVERRIDE;
82 virtual void OnThemeChanged() OVERRIDE;
84 // WidgetDelegate overrides:
85 virtual bool ShouldHandleSystemCommands() const OVERRIDE;
87 // Overridden from AppListViewDelegateObserver:
88 virtual void OnProfilesChanged() OVERRIDE;
90 void Prerender();
92 void SetProfileByPath(const base::FilePath& profile_path);
94 void AddObserver(AppListViewObserver* observer);
95 void RemoveObserver(AppListViewObserver* observer);
97 // Set a callback to be called the next time any app list paints.
98 static void SetNextPaintCallback(void (*callback)());
100 #if defined(OS_WIN)
101 HWND GetHWND() const;
102 #endif
104 AppListMainView* app_list_main_view() { return app_list_main_view_; }
106 private:
107 void InitAsBubbleInternal(gfx::NativeView parent,
108 PaginationModel* pagination_model,
109 views::BubbleBorder::Arrow arrow,
110 bool border_accepts_events,
111 const gfx::Vector2d& anchor_offset);
113 // Overridden from views::BubbleDelegateView:
114 virtual void OnBeforeBubbleWidgetInit(
115 views::Widget::InitParams* params,
116 views::Widget* widget) const OVERRIDE;
118 // Overridden from views::WidgetDelegateView:
119 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
120 virtual gfx::ImageSkia GetWindowIcon() OVERRIDE;
121 virtual bool WidgetHasHitTestMask() const OVERRIDE;
122 virtual void GetWidgetHitTestMask(gfx::Path* mask) const OVERRIDE;
124 // Overridden from views::View:
125 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
126 virtual void Layout() OVERRIDE;
128 // Overridden from views::WidgetObserver:
129 virtual void OnWidgetDestroying(views::Widget* widget) OVERRIDE;
130 virtual void OnWidgetVisibilityChanged(
131 views::Widget* widget, bool visible) OVERRIDE;
132 virtual void OnWidgetActivationChanged(
133 views::Widget* widget, bool active) OVERRIDE;
135 // Overridden from SpeechUIModelObserver:
136 virtual void OnSpeechRecognitionStateChanged(
137 SpeechRecognitionState new_state) OVERRIDE;
139 SigninDelegate* GetSigninDelegate();
141 scoped_ptr<AppListViewDelegate> delegate_;
143 AppListMainView* app_list_main_view_;
144 SigninView* signin_view_;
145 SpeechView* speech_view_;
147 ObserverList<AppListViewObserver> observers_;
148 scoped_ptr<HideViewAnimationObserver> animation_observer_;
150 DISALLOW_COPY_AND_ASSIGN(AppListView);
153 } // namespace app_list
155 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_