Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h

Issue 2171813004: mash: Fold ShelfItemDelegateManager into ShelfModel (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: explicitly destroy ShelfItemDelegates Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_ 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_ 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_
7 7
8 #include <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 10
11 #include "ash/common/shelf/shelf_item_delegate_manager.h"
12 #include "ash/common/shelf/shelf_model_observer.h" 11 #include "ash/common/shelf/shelf_model_observer.h"
13 #include "ash/common/shelf/shelf_types.h" 12 #include "ash/common/shelf/shelf_types.h"
14 #include "ash/display/window_tree_host_manager.h" 13 #include "ash/display/window_tree_host_manager.h"
15 #include "ash/shelf/shelf_delegate.h" 14 #include "ash/shelf/shelf_delegate.h"
16 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
17 #include "base/macros.h" 16 #include "base/macros.h"
18 #include "build/build_config.h" 17 #include "build/build_config.h"
19 #include "chrome/browser/ui/app_icon_loader.h" 18 #include "chrome/browser/ui/app_icon_loader.h"
20 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" 19 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
21 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h" 20 #include "chrome/browser/ui/ash/app_sync_ui_state_observer.h"
22 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" 21 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
23 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h" 22 #include "chrome/browser/ui/ash/launcher/launcher_app_updater.h"
24 #include "components/prefs/pref_change_registrar.h" 23 #include "components/prefs/pref_change_registrar.h"
25 #include "ui/aura/window_observer.h" 24 #include "ui/aura/window_observer.h"
26 25
27 class AppSyncUIState; 26 class AppSyncUIState;
28 class BrowserStatusMonitor; 27 class BrowserStatusMonitor;
29 class LauncherControllerHelper; 28 class LauncherControllerHelper;
30 class Profile; 29 class Profile;
31 class AppWindowLauncherController; 30 class AppWindowLauncherController;
32 class TabContents; 31 class TabContents;
33 32
34 namespace ash { 33 namespace ash {
35 class ShelfItemDelegateManager;
36 class ShelfModel; 34 class ShelfModel;
37 namespace launcher { 35 namespace launcher {
38 class ChromeLauncherPrefsObserver; 36 class ChromeLauncherPrefsObserver;
39 } 37 }
40 } 38 }
41 39
42 namespace aura { 40 namespace aura {
43 class Window; 41 class Window;
44 } 42 }
45 43
(...skipping 12 matching lines...) Expand all
58 // a lot of other responsibilities, such as implementing ash::ShelfDelegate, 56 // a lot of other responsibilities, such as implementing ash::ShelfDelegate,
59 // updating the UI state and the shelf model when apps are uninstalled, etc. 57 // updating the UI state and the shelf model when apps are uninstalled, etc.
60 class ChromeLauncherControllerImpl 58 class ChromeLauncherControllerImpl
61 : public ChromeLauncherController, 59 : public ChromeLauncherController,
62 public ash::ShelfDelegate, 60 public ash::ShelfDelegate,
63 public LauncherAppUpdater::Delegate, 61 public LauncherAppUpdater::Delegate,
64 private ash::ShelfModelObserver, 62 private ash::ShelfModelObserver,
65 private ash::WindowTreeHostManager::Observer, 63 private ash::WindowTreeHostManager::Observer,
66 private AppIconLoaderDelegate, 64 private AppIconLoaderDelegate,
67 private AppSyncUIStateObserver, 65 private AppSyncUIStateObserver,
68 private ash::ShelfItemDelegateManagerObserver,
69 private app_list::AppListSyncableService::Observer { 66 private app_list::AppListSyncableService::Observer {
70 public: 67 public:
71 ChromeLauncherControllerImpl(Profile* profile, ash::ShelfModel* model); 68 ChromeLauncherControllerImpl(Profile* profile, ash::ShelfModel* model);
72 ~ChromeLauncherControllerImpl() override; 69 ~ChromeLauncherControllerImpl() override;
73 70
74 // Create ChromeLauncherControllerImpl instance and set is as the 71 // Create ChromeLauncherControllerImpl instance and set is as the
75 // ChromeLauncherController singleton. 72 // ChromeLauncherController singleton.
76 static ChromeLauncherControllerImpl* CreateInstance(Profile* profile, 73 static ChromeLauncherControllerImpl* CreateInstance(Profile* profile,
77 ash::ShelfModel* model); 74 ash::ShelfModel* model);
78 75
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 // Use kInsertItemAtEnd to add a shortcut as the last item. 175 // Use kInsertItemAtEnd to add a shortcut as the last item.
179 ash::ShelfID CreateAppShortcutLauncherItem(const std::string& app_id, 176 ash::ShelfID CreateAppShortcutLauncherItem(const std::string& app_id,
180 int index); 177 int index);
181 178
182 // Sets LauncherControllerHelper/AppIconLoader for test, taking ownership. 179 // Sets LauncherControllerHelper/AppIconLoader for test, taking ownership.
183 void SetLauncherControllerHelperForTest(LauncherControllerHelper* helper); 180 void SetLauncherControllerHelperForTest(LauncherControllerHelper* helper);
184 void SetAppIconLoadersForTest( 181 void SetAppIconLoadersForTest(
185 std::vector<std::unique_ptr<AppIconLoader>>& loaders); 182 std::vector<std::unique_ptr<AppIconLoader>>& loaders);
186 const std::string& GetAppIdFromShelfIdForTest(ash::ShelfID id); 183 const std::string& GetAppIdFromShelfIdForTest(ash::ShelfID id);
187 184
188 // Sets the ash::ShelfItemDelegateManager only for unittests and doesn't
189 // take an ownership of it.
190 void SetShelfItemDelegateManagerForTest(
191 ash::ShelfItemDelegateManager* manager);
192
193 private: 185 private:
194 friend class ChromeLauncherControllerImplTest; 186 friend class ChromeLauncherControllerImplTest;
195 friend class ShelfAppBrowserTest; 187 friend class ShelfAppBrowserTest;
196 friend class LauncherPlatformAppBrowserTest; 188 friend class LauncherPlatformAppBrowserTest;
197 FRIEND_TEST_ALL_PREFIXES(ChromeLauncherControllerImplTest, AppPanels); 189 FRIEND_TEST_ALL_PREFIXES(ChromeLauncherControllerImplTest, AppPanels);
198 190
199 typedef std::map<ash::ShelfID, LauncherItemController*> IDToItemControllerMap; 191 typedef std::map<ash::ShelfID, LauncherItemController*> IDToItemControllerMap;
200 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap; 192 typedef std::map<content::WebContents*, std::string> WebContentsToAppIDMap;
201 193
202 // Remembers / restores list of running applications. 194 // Remembers / restores list of running applications.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 ash::ShelfItemDelegate* item_delegate); 280 ash::ShelfItemDelegate* item_delegate);
289 281
290 // Attach to a specific profile. 282 // Attach to a specific profile.
291 void AttachProfile(Profile* proifile); 283 void AttachProfile(Profile* proifile);
292 284
293 // Forget the current profile to allow attaching to a new one. 285 // Forget the current profile to allow attaching to a new one.
294 void ReleaseProfile(); 286 void ReleaseProfile();
295 287
296 AppIconLoader* GetAppIconLoaderForApp(const std::string& app_id); 288 AppIconLoader* GetAppIconLoaderForApp(const std::string& app_id);
297 289
298 // ash::ShelfItemDelegateManagerObserver:
299 void OnSetShelfItemDelegate(ash::ShelfID id,
300 ash::ShelfItemDelegate* item_delegate) override;
301
302 // ash::ShelfModelObserver: 290 // ash::ShelfModelObserver:
303 void ShelfItemAdded(int index) override; 291 void ShelfItemAdded(int index) override;
304 void ShelfItemRemoved(int index, ash::ShelfID id) override; 292 void ShelfItemRemoved(int index, ash::ShelfID id) override;
305 void ShelfItemMoved(int start_index, int target_index) override; 293 void ShelfItemMoved(int start_index, int target_index) override;
306 void ShelfItemChanged(int index, const ash::ShelfItem& old_item) override; 294 void ShelfItemChanged(int index, const ash::ShelfItem& old_item) override;
295 void OnSetShelfItemDelegate(ash::ShelfID id,
296 ash::ShelfItemDelegate* item_delegate) override;
307 297
308 // ash::WindowTreeHostManager::Observer: 298 // ash::WindowTreeHostManager::Observer:
309 void OnDisplayConfigurationChanged() override; 299 void OnDisplayConfigurationChanged() override;
310 300
311 // AppSyncUIStateObserver: 301 // AppSyncUIStateObserver:
312 void OnAppSyncUIStatusChanged() override; 302 void OnAppSyncUIStatusChanged() override;
313 303
314 // AppIconLoaderDelegate: 304 // AppIconLoaderDelegate:
315 void OnAppImageUpdated(const std::string& app_id, 305 void OnAppImageUpdated(const std::string& app_id,
316 const gfx::ImageSkia& image) override; 306 const gfx::ImageSkia& image) override;
317 307
318 // app_list::AppListSyncableService::Observer: 308 // app_list::AppListSyncableService::Observer:
319 void OnSyncModelUpdated() override; 309 void OnSyncModelUpdated() override;
320 310
321 ash::ShelfModel* model_; 311 ash::ShelfModel* model_;
322 312
323 ash::ShelfItemDelegateManager* item_delegate_manager_ = nullptr;
324
325 // Profile used for prefs and loading extensions. This is NOT necessarily the 313 // Profile used for prefs and loading extensions. This is NOT necessarily the
326 // profile new windows are created with. 314 // profile new windows are created with.
327 Profile* profile_; 315 Profile* profile_;
328 316
329 // Controller items in this map are owned by |ShelfItemDelegateManager|. 317 // Controller items in this map are owned by |ShelfModel|.
330 IDToItemControllerMap id_to_item_controller_map_; 318 IDToItemControllerMap id_to_item_controller_map_;
331 319
332 // Direct access to app_id for a web contents. 320 // Direct access to app_id for a web contents.
333 WebContentsToAppIDMap web_contents_to_app_id_; 321 WebContentsToAppIDMap web_contents_to_app_id_;
334 322
335 // Used to track app windows. 323 // Used to track app windows.
336 std::vector<std::unique_ptr<AppWindowLauncherController>> 324 std::vector<std::unique_ptr<AppWindowLauncherController>>
337 app_window_controllers_; 325 app_window_controllers_;
338 326
339 // Used to get app info for tabs. 327 // Used to get app info for tabs.
(...skipping 26 matching lines...) Expand all
366 // The list of running & un-pinned applications for different users on hidden 354 // The list of running & un-pinned applications for different users on hidden
367 // desktops. 355 // desktops.
368 typedef std::vector<std::string> RunningAppListIds; 356 typedef std::vector<std::string> RunningAppListIds;
369 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap; 357 typedef std::map<std::string, RunningAppListIds> RunningAppListIdMap;
370 RunningAppListIdMap last_used_running_application_order_; 358 RunningAppListIdMap last_used_running_application_order_;
371 359
372 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImpl); 360 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImpl);
373 }; 361 };
374 362
375 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_ 363 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_CHROME_LAUNCHER_CONTROLLER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698