| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 5 #ifndef UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ |
| 6 #define UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 6 #define UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/observer_list.h" | |
| 13 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 14 #include "ui/app_list/app_list_export.h" | 13 #include "ui/app_list/app_list_export.h" |
| 15 #include "ui/app_list/speech_ui_model_observer.h" | 14 #include "ui/app_list/speech_ui_model_observer.h" |
| 16 #include "ui/views/bubble/bubble_dialog_delegate.h" | 15 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 17 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
| 18 | 17 |
| 19 namespace base { | 18 namespace base { |
| 20 class FilePath; | 19 class FilePath; |
| 21 } | 20 } |
| 22 | 21 |
| 23 namespace app_list { | 22 namespace app_list { |
| 24 class ApplicationDragAndDropHost; | 23 class ApplicationDragAndDropHost; |
| 25 class AppListMainView; | 24 class AppListMainView; |
| 26 class AppListModel; | 25 class AppListModel; |
| 27 class AppListViewDelegate; | 26 class AppListViewDelegate; |
| 28 class AppListViewObserver; | |
| 29 class HideViewAnimationObserver; | 27 class HideViewAnimationObserver; |
| 30 class PaginationModel; | 28 class PaginationModel; |
| 31 class SearchBoxView; | 29 class SearchBoxView; |
| 32 class SpeechView; | 30 class SpeechView; |
| 33 | 31 |
| 34 namespace test { | 32 namespace test { |
| 35 class AppListViewTestApi; | 33 class AppListViewTestApi; |
| 36 } | 34 } |
| 37 | 35 |
| 38 // AppListView is the top-level view and controller of app list UI. It creates | 36 // AppListView is the top-level view and controller of app list UI. It creates |
| 39 // and hosts a AppsGridView and passes AppListModel to it for display. | 37 // and hosts a AppsGridView and passes AppListModel to it for display. |
| 40 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, | 38 class APP_LIST_EXPORT AppListView : public views::BubbleDialogDelegateView, |
| 41 public SpeechUIModelObserver { | 39 public SpeechUIModelObserver { |
| 42 public: | 40 public: |
| 43 // Does not take ownership of |delegate|. | 41 // Does not take ownership of |delegate|. |
| 44 explicit AppListView(AppListViewDelegate* delegate); | 42 explicit AppListView(AppListViewDelegate* delegate); |
| 45 ~AppListView() override; | 43 ~AppListView() override; |
| 46 | 44 |
| 47 // Initializes the widget and use a fixed |anchor_point_in_screen| for | 45 // Initializes the widget. |
| 48 // positioning. | 46 void InitAsBubble(gfx::NativeView parent, int initial_apps_page); |
| 49 void InitAsBubbleAtFixedLocation(gfx::NativeView parent, | |
| 50 int initial_apps_page, | |
| 51 const gfx::Point& anchor_point_in_screen, | |
| 52 views::BubbleBorder::Arrow arrow, | |
| 53 bool border_accepts_events); | |
| 54 | 47 |
| 55 // Initializes the widget as a frameless window, not a bubble. | 48 // Initializes the widget as a frameless window, not a bubble. |
| 56 void InitAsFramelessWindow(gfx::NativeView parent, | 49 void InitAsFramelessWindow(gfx::NativeView parent, |
| 57 int initial_apps_page, | 50 int initial_apps_page, |
| 58 gfx::Rect bounds); | 51 gfx::Rect bounds); |
| 59 | 52 |
| 60 void SetBubbleArrow(views::BubbleBorder::Arrow arrow); | 53 void SetBubbleArrow(views::BubbleBorder::Arrow arrow); |
| 61 | 54 |
| 62 void SetAnchorPoint(const gfx::Point& anchor_point); | 55 void SetAnchorPoint(const gfx::Point& anchor_point); |
| 63 | 56 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 87 void OnPaint(gfx::Canvas* canvas) override; | 80 void OnPaint(gfx::Canvas* canvas) override; |
| 88 | 81 |
| 89 // WidgetDelegate overrides: | 82 // WidgetDelegate overrides: |
| 90 bool ShouldHandleSystemCommands() const override; | 83 bool ShouldHandleSystemCommands() const override; |
| 91 bool ShouldDescendIntoChildForEventHandling( | 84 bool ShouldDescendIntoChildForEventHandling( |
| 92 gfx::NativeView child, | 85 gfx::NativeView child, |
| 93 const gfx::Point& location) override; | 86 const gfx::Point& location) override; |
| 94 | 87 |
| 95 void SetProfileByPath(const base::FilePath& profile_path); | 88 void SetProfileByPath(const base::FilePath& profile_path); |
| 96 | 89 |
| 97 void AddObserver(AppListViewObserver* observer); | |
| 98 void RemoveObserver(AppListViewObserver* observer); | |
| 99 | |
| 100 AppListMainView* app_list_main_view() { return app_list_main_view_; } | 90 AppListMainView* app_list_main_view() { return app_list_main_view_; } |
| 101 | 91 |
| 102 // Gets the PaginationModel owned by this view's apps grid. | 92 // Gets the PaginationModel owned by this view's apps grid. |
| 103 PaginationModel* GetAppsPaginationModel(); | 93 PaginationModel* GetAppsPaginationModel(); |
| 104 | 94 |
| 105 // Overridden from views::View: | 95 // Overridden from views::View: |
| 106 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 96 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 107 void Layout() override; | 97 void Layout() override; |
| 108 void SchedulePaintInRect(const gfx::Rect& rect) override; | 98 void SchedulePaintInRect(const gfx::Rect& rect) override; |
| 109 | 99 |
| 110 private: | 100 private: |
| 111 friend class test::AppListViewTestApi; | 101 friend class test::AppListViewTestApi; |
| 112 | 102 |
| 113 void InitContents(gfx::NativeView parent, int initial_apps_page); | 103 void InitContents(gfx::NativeView parent, int initial_apps_page); |
| 114 | 104 |
| 115 void InitChildWidgets(); | 105 void InitChildWidgets(); |
| 116 | 106 |
| 117 void InitAsBubbleInternal(gfx::NativeView parent, | |
| 118 int initial_apps_page, | |
| 119 views::BubbleBorder::Arrow arrow, | |
| 120 bool border_accepts_events, | |
| 121 const gfx::Vector2d& anchor_offset); | |
| 122 | |
| 123 // Overridden from views::BubbleDialogDelegateView: | 107 // Overridden from views::BubbleDialogDelegateView: |
| 124 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, | 108 void OnBeforeBubbleWidgetInit(views::Widget::InitParams* params, |
| 125 views::Widget* widget) const override; | 109 views::Widget* widget) const override; |
| 126 int GetDialogButtons() const override; | 110 int GetDialogButtons() const override; |
| 127 | 111 |
| 128 // Overridden from views::WidgetDelegateView: | 112 // Overridden from views::WidgetDelegateView: |
| 129 views::View* GetInitiallyFocusedView() override; | 113 views::View* GetInitiallyFocusedView() override; |
| 130 bool WidgetHasHitTestMask() const override; | 114 bool WidgetHasHitTestMask() const override; |
| 131 void GetWidgetHitTestMask(gfx::Path* mask) const override; | 115 void GetWidgetHitTestMask(gfx::Path* mask) const override; |
| 132 | 116 |
| 133 // Overridden from views::WidgetObserver: | 117 // Overridden from views::WidgetObserver: |
| 134 void OnWidgetDestroying(views::Widget* widget) override; | 118 void OnWidgetDestroying(views::Widget* widget) override; |
| 135 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; | 119 void OnWidgetVisibilityChanged(views::Widget* widget, bool visible) override; |
| 136 void OnWidgetActivationChanged(views::Widget* widget, bool active) override; | |
| 137 | 120 |
| 138 // Overridden from SpeechUIModelObserver: | 121 // Overridden from SpeechUIModelObserver: |
| 139 void OnSpeechRecognitionStateChanged( | 122 void OnSpeechRecognitionStateChanged( |
| 140 SpeechRecognitionState new_state) override; | 123 SpeechRecognitionState new_state) override; |
| 141 | 124 |
| 142 AppListViewDelegate* delegate_; // Weak. Owned by AppListService. | 125 AppListViewDelegate* delegate_; // Weak. Owned by AppListService. |
| 143 | 126 |
| 144 AppListMainView* app_list_main_view_; | 127 AppListMainView* app_list_main_view_; |
| 145 SpeechView* speech_view_; | 128 SpeechView* speech_view_; |
| 146 | 129 |
| 147 views::View* search_box_focus_host_; // Owned by the views hierarchy. | 130 views::View* search_box_focus_host_; // Owned by the views hierarchy. |
| 148 views::Widget* search_box_widget_; // Owned by the app list's widget. | 131 views::Widget* search_box_widget_; // Owned by the app list's widget. |
| 149 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. | 132 SearchBoxView* search_box_view_; // Owned by |search_box_widget_|. |
| 150 | 133 |
| 151 // A semi-transparent white overlay that covers the app list while dialogs are | 134 // A semi-transparent white overlay that covers the app list while dialogs are |
| 152 // open. | 135 // open. |
| 153 views::View* overlay_view_; | 136 views::View* overlay_view_; |
| 154 | 137 |
| 155 base::ObserverList<AppListViewObserver> observers_; | |
| 156 std::unique_ptr<HideViewAnimationObserver> animation_observer_; | 138 std::unique_ptr<HideViewAnimationObserver> animation_observer_; |
| 157 | 139 |
| 158 // For UMA and testing. If non-null, triggered when the app list is painted. | 140 // For UMA and testing. If non-null, triggered when the app list is painted. |
| 159 base::Closure next_paint_callback_; | 141 base::Closure next_paint_callback_; |
| 160 | 142 |
| 161 DISALLOW_COPY_AND_ASSIGN(AppListView); | 143 DISALLOW_COPY_AND_ASSIGN(AppListView); |
| 162 }; | 144 }; |
| 163 | 145 |
| 164 } // namespace app_list | 146 } // namespace app_list |
| 165 | 147 |
| 166 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ | 148 #endif // UI_APP_LIST_VIEWS_APP_LIST_VIEW_H_ |
| OLD | NEW |