Chromium Code Reviews| 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 "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | 9 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" |
| 10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
| 11 #include "content/public/browser/notification_observer.h" | |
| 12 #include "content/public/browser/notification_registrar.h" | |
| 11 | 13 |
| 12 namespace ash { | 14 namespace ash { |
| 13 class ShelfModel; | 15 class ShelfModel; |
| 14 } | 16 } |
| 15 | 17 |
| 16 namespace content { | 18 namespace content { |
| 17 class WebContents; | 19 class WebContents; |
| 18 } | 20 } |
| 19 | 21 |
| 20 namespace gfx { | |
| 21 class Image; | |
| 22 } | |
| 23 | |
| 24 class Browser; | |
| 25 class ChromeLauncherController; | 22 class ChromeLauncherController; |
| 26 | 23 |
| 27 // Item controller for an browser shortcut. | 24 // Item controller for an browser shortcut. |
|
James Cook
2017/03/01 19:50:48
super nit: while you're here, can you update/clari
msw
2017/03/02 02:59:20
Done.
| |
| 28 class BrowserShortcutLauncherItemController : public LauncherItemController { | 25 class BrowserShortcutLauncherItemController |
| 26 : public LauncherItemController, | |
| 27 public content::NotificationObserver { | |
| 29 public: | 28 public: |
| 30 BrowserShortcutLauncherItemController(ChromeLauncherController* controller, | 29 BrowserShortcutLauncherItemController(ChromeLauncherController* controller, |
| 31 ash::ShelfModel* shelf_model); | 30 ash::ShelfModel* shelf_model); |
| 32 | 31 |
| 33 ~BrowserShortcutLauncherItemController() override; | 32 ~BrowserShortcutLauncherItemController() override; |
| 34 | 33 |
| 35 // Updates the activation state of the Broswer item. | 34 // Updates the activation state of the Broswer item. |
| 36 void UpdateBrowserItemState(); | 35 void UpdateBrowserItemState(); |
| 37 | 36 |
| 38 // Sets the shelf id for the browser window if the browser is represented. | 37 // Sets the shelf id for the browser window if the browser is represented. |
| 39 void SetShelfIDForBrowserWindowContents(Browser* browser, | 38 void SetShelfIDForBrowserWindowContents(Browser* browser, |
| 40 content::WebContents* web_contents); | 39 content::WebContents* web_contents); |
| 41 | 40 |
| 42 // Check if there is any active browsers windows. | 41 // Check if there is any active browsers windows. |
| 43 bool IsListOfActiveBrowserEmpty(); | 42 bool IsListOfActiveBrowserEmpty(); |
| 44 | 43 |
| 45 // LauncherItemController overrides: | 44 // LauncherItemController overrides: |
| 46 ash::ShelfAction ItemSelected(ui::EventType event_type, | 45 ash::ShelfAction ItemSelected(ui::EventType event_type, |
| 47 int event_flags, | 46 int event_flags, |
| 48 int64_t display_id, | 47 int64_t display_id, |
| 49 ash::ShelfLaunchSource source) override; | 48 ash::ShelfLaunchSource source) override; |
| 50 ash::ShelfAppMenuItemList GetAppMenuItems(int event_flags) override; | 49 ash::ShelfAppMenuItemList GetAppMenuItems(int event_flags) override; |
| 50 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override; | |
| 51 void Close() override; | 51 void Close() override; |
| 52 | 52 |
| 53 private: | 53 private: |
| 54 // Get the favicon for the browser list entry for |web_contents|. | |
| 55 // Note that for incognito windows the incognito icon will be returned. | |
| 56 gfx::Image GetBrowserListIcon(content::WebContents* web_contents) const; | |
| 57 | |
| 58 // Get the title for the browser list entry for |web_contents|. | |
| 59 // If |web_contents| has not loaded, returns "Net Tab". | |
| 60 base::string16 GetBrowserListTitle(content::WebContents* web_contents) const; | |
| 61 | |
| 62 // Check if the given |web_contents| is in incognito mode. | |
| 63 bool IsIncognito(content::WebContents* web_contents) const; | |
| 64 | |
| 65 // Activate a browser - or advance to the next one on the list. | 54 // Activate a browser - or advance to the next one on the list. |
| 66 // Returns the action performed. Should be one of SHELF_ACTION_NONE, | 55 // Returns the action performed. Should be one of SHELF_ACTION_NONE, |
| 67 // SHELF_ACTION_WINDOW_ACTIVATED, or SHELF_ACTION_NEW_WINDOW_CREATED. | 56 // SHELF_ACTION_WINDOW_ACTIVATED, or SHELF_ACTION_NEW_WINDOW_CREATED. |
| 68 ash::ShelfAction ActivateOrAdvanceToNextBrowser(); | 57 ash::ShelfAction ActivateOrAdvanceToNextBrowser(); |
| 69 | 58 |
| 70 // Returns true when the given |browser| is listed in the browser application | 59 // Returns true when the given |browser| is listed in the browser application |
| 71 // list. | 60 // list. |
| 72 bool IsBrowserRepresentedInBrowserList(Browser* browser); | 61 bool IsBrowserRepresentedInBrowserList(Browser* browser); |
| 73 | 62 |
| 74 // Get a list of active browsers. | 63 // Get a list of active browsers. |
| 75 BrowserList::BrowserVector GetListOfActiveBrowsers(); | 64 BrowserList::BrowserVector GetListOfActiveBrowsers(); |
| 76 | 65 |
| 66 // content::NotificationObserver: | |
| 67 void Observe(int type, | |
| 68 const content::NotificationSource& source, | |
| 69 const content::NotificationDetails& details) override; | |
| 70 | |
| 77 ash::ShelfModel* shelf_model_; | 71 ash::ShelfModel* shelf_model_; |
| 78 | 72 |
| 73 // The cached list of open browser windows shown in an application menu. | |
| 74 BrowserList::BrowserVector browser_menu_items_; | |
| 75 | |
| 76 // Registers for notifications of closing browser windows. | |
| 77 content::NotificationRegistrar registrar_; | |
| 78 | |
| 79 DISALLOW_COPY_AND_ASSIGN(BrowserShortcutLauncherItemController); | 79 DISALLOW_COPY_AND_ASSIGN(BrowserShortcutLauncherItemController); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_SHORTCUT_LAUNCHER_ITEM_CONTROL LER_H_ | 82 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_BROWSER_SHORTCUT_LAUNCHER_ITEM_CONTROL LER_H_ |
| OLD | NEW |