OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_BROWSER_SHORTCUT_LAUNCHER_ITEM_CONTROLLER
_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_SHORTCUT_LAUNCHER_ITEM_CONTROLLER
_H_ |
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_SHORTCUT_LAUNCHER_ITEM_CONTROLLER
_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_SHORTCUT_LAUNCHER_ITEM_CONTROLLER
_H_ |
7 | 7 |
8 #include "ash/public/cpp/shelf_item_delegate.h" | 8 #include "ash/public/cpp/shelf_item_delegate.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/scoped_observer.h" |
10 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
11 #include "content/public/browser/notification_observer.h" | 12 #include "chrome/browser/ui/browser_list_observer.h" |
12 #include "content/public/browser/notification_registrar.h" | |
13 | 13 |
14 namespace ash { | 14 namespace ash { |
15 class ShelfModel; | 15 class ShelfModel; |
16 } | 16 } |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 class WebContents; | 19 class WebContents; |
20 } | 20 } |
21 | 21 |
22 // Shelf item delegate for a browser shortcut; only one such item should exist. | 22 // Shelf item delegate for a browser shortcut; only one such item should exist. |
23 // This item shows an application menu that lists open browser windows or tabs. | 23 // This item shows an application menu that lists open browser windows or tabs. |
24 class BrowserShortcutLauncherItemController | 24 class BrowserShortcutLauncherItemController |
25 : public ash::ShelfItemDelegate, | 25 : public ash::ShelfItemDelegate, |
26 public content::NotificationObserver { | 26 public chrome::BrowserListObserver { |
27 public: | 27 public: |
28 explicit BrowserShortcutLauncherItemController(ash::ShelfModel* shelf_model); | 28 explicit BrowserShortcutLauncherItemController(ash::ShelfModel* shelf_model); |
29 | 29 |
30 ~BrowserShortcutLauncherItemController() override; | 30 ~BrowserShortcutLauncherItemController() override; |
31 | 31 |
32 // Updates the activation state of the Broswer item. | 32 // Updates the activation state of the Broswer item. |
33 void UpdateBrowserItemState(); | 33 void UpdateBrowserItemState(); |
34 | 34 |
35 // Sets the shelf id for the browser window if the browser is represented. | 35 // Sets the shelf id for the browser window if the browser is represented. |
36 void SetShelfIDForBrowserWindowContents(Browser* browser, | 36 void SetShelfIDForBrowserWindowContents(Browser* browser, |
(...skipping 17 matching lines...) Expand all Loading... |
54 // SHELF_ACTION_WINDOW_ACTIVATED, or SHELF_ACTION_NEW_WINDOW_CREATED. | 54 // SHELF_ACTION_WINDOW_ACTIVATED, or SHELF_ACTION_NEW_WINDOW_CREATED. |
55 ash::ShelfAction ActivateOrAdvanceToNextBrowser(); | 55 ash::ShelfAction ActivateOrAdvanceToNextBrowser(); |
56 | 56 |
57 // Returns true when the given |browser| is listed in the browser application | 57 // Returns true when the given |browser| is listed in the browser application |
58 // list. | 58 // list. |
59 bool IsBrowserRepresentedInBrowserList(Browser* browser); | 59 bool IsBrowserRepresentedInBrowserList(Browser* browser); |
60 | 60 |
61 // Get a list of active browsers. | 61 // Get a list of active browsers. |
62 BrowserList::BrowserVector GetListOfActiveBrowsers(); | 62 BrowserList::BrowserVector GetListOfActiveBrowsers(); |
63 | 63 |
64 // content::NotificationObserver: | 64 // chrome::BrowserListObserver: |
65 void Observe(int type, | 65 void OnBrowserClosing(Browser* browser) override; |
66 const content::NotificationSource& source, | |
67 const content::NotificationDetails& details) override; | |
68 | 66 |
69 ash::ShelfModel* shelf_model_; | 67 ash::ShelfModel* shelf_model_; |
70 | 68 |
71 // The cached list of open browser windows shown in an application menu. | 69 // The cached list of open browser windows shown in an application menu. |
72 BrowserList::BrowserVector browser_menu_items_; | 70 BrowserList::BrowserVector browser_menu_items_; |
73 | 71 |
74 // Registers for notifications of closing browser windows. | 72 // Observer for browser windows closing events. |
75 content::NotificationRegistrar registrar_; | 73 ScopedObserver<BrowserList, BrowserListObserver> browser_list_observer_; |
76 | 74 |
77 DISALLOW_COPY_AND_ASSIGN(BrowserShortcutLauncherItemController); | 75 DISALLOW_COPY_AND_ASSIGN(BrowserShortcutLauncherItemController); |
78 }; | 76 }; |
79 | 77 |
80 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_SHORTCUT_LAUNCHER_ITEM_CONTROL
LER_H_ | 78 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_SHORTCUT_LAUNCHER_ITEM_CONTROL
LER_H_ |
OLD | NEW |