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 CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 } | 25 } |
26 | 26 |
27 // Item controller for an app shortcut. Shortcuts track app and launcher ids, | 27 // Item controller for an app shortcut. Shortcuts track app and launcher ids, |
28 // but do not have any associated windows (opening a shortcut will replace the | 28 // but do not have any associated windows (opening a shortcut will replace the |
29 // item with the appropriate ash::ShelfItemDelegate type). | 29 // item with the appropriate ash::ShelfItemDelegate type). |
30 class AppShortcutLauncherItemController : public ash::ShelfItemDelegate { | 30 class AppShortcutLauncherItemController : public ash::ShelfItemDelegate { |
31 public: | 31 public: |
32 ~AppShortcutLauncherItemController() override; | 32 ~AppShortcutLauncherItemController() override; |
33 | 33 |
34 static std::unique_ptr<AppShortcutLauncherItemController> Create( | 34 static std::unique_ptr<AppShortcutLauncherItemController> Create( |
35 const ash::AppLaunchId& app_launch_id); | 35 const ash::ShelfID& shelf_id); |
36 | 36 |
37 std::vector<content::WebContents*> GetRunningApplications(); | 37 std::vector<content::WebContents*> GetRunningApplications(); |
38 | 38 |
39 // ash::ShelfItemDelegate overrides: | 39 // ash::ShelfItemDelegate overrides: |
40 void ItemSelected(std::unique_ptr<ui::Event> event, | 40 void ItemSelected(std::unique_ptr<ui::Event> event, |
41 int64_t display_id, | 41 int64_t display_id, |
42 ash::ShelfLaunchSource source, | 42 ash::ShelfLaunchSource source, |
43 const ItemSelectedCallback& callback) override; | 43 const ItemSelectedCallback& callback) override; |
44 ash::MenuItemList GetAppMenuItems(int event_flags) override; | 44 ash::MenuItemList GetAppMenuItems(int event_flags) override; |
45 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override; | 45 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override; |
46 void Close() override; | 46 void Close() override; |
47 | 47 |
48 // Get the refocus url pattern, which can be used to identify this application | 48 // Get the refocus url pattern, which can be used to identify this application |
49 // from a URL link. | 49 // from a URL link. |
50 const GURL& refocus_url() const { return refocus_url_; } | 50 const GURL& refocus_url() const { return refocus_url_; } |
51 // Set the refocus url pattern. Used by unit tests. | 51 // Set the refocus url pattern. Used by unit tests. |
52 void set_refocus_url(const GURL& refocus_url) { refocus_url_ = refocus_url; } | 52 void set_refocus_url(const GURL& refocus_url) { refocus_url_ = refocus_url; } |
53 | 53 |
54 protected: | 54 protected: |
55 explicit AppShortcutLauncherItemController( | 55 explicit AppShortcutLauncherItemController(const ash::ShelfID& shelf_id); |
56 const ash::AppLaunchId& app_launch_id); | |
57 | 56 |
58 private: | 57 private: |
59 // Get the last running application. | 58 // Get the last running application. |
60 content::WebContents* GetLRUApplication(); | 59 content::WebContents* GetLRUApplication(); |
61 | 60 |
62 // Returns true if this app matches the given |web_contents|. To accelerate | 61 // Returns true if this app matches the given |web_contents|. To accelerate |
63 // the matching, the app managing |extension| as well as the parsed | 62 // the matching, the app managing |extension| as well as the parsed |
64 // |refocus_pattern| get passed. If |is_app| is true, the application gets | 63 // |refocus_pattern| get passed. If |is_app| is true, the application gets |
65 // first checked against its original URL since a windowed app might have | 64 // first checked against its original URL since a windowed app might have |
66 // navigated away from its app domain. | 65 // navigated away from its app domain. |
(...skipping 22 matching lines...) Expand all Loading... |
89 // keeping track of the last launch attempt. | 88 // keeping track of the last launch attempt. |
90 base::Time last_launch_attempt_; | 89 base::Time last_launch_attempt_; |
91 | 90 |
92 // The cached list of open app web contents shown in an application menu. | 91 // The cached list of open app web contents shown in an application menu. |
93 std::vector<content::WebContents*> app_menu_items_; | 92 std::vector<content::WebContents*> app_menu_items_; |
94 | 93 |
95 DISALLOW_COPY_AND_ASSIGN(AppShortcutLauncherItemController); | 94 DISALLOW_COPY_AND_ASSIGN(AppShortcutLauncherItemController); |
96 }; | 95 }; |
97 | 96 |
98 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_
H_ | 97 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_
H_ |
OLD | NEW |