| 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 |
| 11 #include "ash/public/cpp/shelf_item_delegate.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 13 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" | |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 class Browser; | 16 class Browser; |
| 17 class URLPattern; | 17 class URLPattern; |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 class WebContents; | 20 class WebContents; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace extensions { | 23 namespace extensions { |
| 24 class Extension; | 24 class Extension; |
| 25 } | 25 } |
| 26 | 26 |
| 27 class ChromeLauncherController; | |
| 28 | |
| 29 // 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, |
| 30 // 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 |
| 31 // item with the appropriate LauncherItemController type). | 29 // item with the appropriate ash::ShelfItemDelegate type). |
| 32 class AppShortcutLauncherItemController : public LauncherItemController { | 30 class AppShortcutLauncherItemController : public ash::ShelfItemDelegate { |
| 33 public: | 31 public: |
| 34 ~AppShortcutLauncherItemController() override; | 32 ~AppShortcutLauncherItemController() override; |
| 35 | 33 |
| 36 static AppShortcutLauncherItemController* Create( | 34 static std::unique_ptr<AppShortcutLauncherItemController> Create( |
| 37 const ash::AppLaunchId& app_launch_id, | 35 const ash::AppLaunchId& app_launch_id); |
| 38 ChromeLauncherController* controller); | |
| 39 | 36 |
| 40 std::vector<content::WebContents*> GetRunningApplications(); | 37 std::vector<content::WebContents*> GetRunningApplications(); |
| 41 | 38 |
| 42 // LauncherItemController overrides: | 39 // ash::ShelfItemDelegate overrides: |
| 43 void ItemSelected(std::unique_ptr<ui::Event> event, | 40 void ItemSelected(std::unique_ptr<ui::Event> event, |
| 44 int64_t display_id, | 41 int64_t display_id, |
| 45 ash::ShelfLaunchSource source, | 42 ash::ShelfLaunchSource source, |
| 46 const ItemSelectedCallback& callback) override; | 43 const ItemSelectedCallback& callback) override; |
| 47 MenuItemList GetAppMenuItems(int event_flags) override; | 44 ash::MenuItemList GetAppMenuItems(int event_flags) override; |
| 48 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override; | 45 void ExecuteCommand(uint32_t command_id, int32_t event_flags) override; |
| 49 void Close() override; | 46 void Close() override; |
| 50 | 47 |
| 51 // 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 |
| 52 // from a URL link. | 49 // from a URL link. |
| 53 const GURL& refocus_url() const { return refocus_url_; } | 50 const GURL& refocus_url() const { return refocus_url_; } |
| 54 // Set the refocus url pattern. Used by unit tests. | 51 // Set the refocus url pattern. Used by unit tests. |
| 55 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; } |
| 56 | 53 |
| 57 ChromeLauncherController* controller() { return chrome_launcher_controller_; } | |
| 58 | |
| 59 protected: | 54 protected: |
| 60 AppShortcutLauncherItemController(const ash::AppLaunchId& app_launch_id, | 55 explicit AppShortcutLauncherItemController( |
| 61 ChromeLauncherController* controller); | 56 const ash::AppLaunchId& app_launch_id); |
| 62 | 57 |
| 63 private: | 58 private: |
| 64 // Get the last running application. | 59 // Get the last running application. |
| 65 content::WebContents* GetLRUApplication(); | 60 content::WebContents* GetLRUApplication(); |
| 66 | 61 |
| 67 // Returns true if this app matches the given |web_contents|. To accelerate | 62 // Returns true if this app matches the given |web_contents|. To accelerate |
| 68 // the matching, the app managing |extension| as well as the parsed | 63 // the matching, the app managing |extension| as well as the parsed |
| 69 // |refocus_pattern| get passed. If |is_app| is true, the application gets | 64 // |refocus_pattern| get passed. If |is_app| is true, the application gets |
| 70 // first checked against its original URL since a windowed app might have | 65 // first checked against its original URL since a windowed app might have |
| 71 // navigated away from its app domain. | 66 // navigated away from its app domain. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 87 | 82 |
| 88 // Returns true if it is allowed to try starting a V2 app again. | 83 // Returns true if it is allowed to try starting a V2 app again. |
| 89 bool AllowNextLaunchAttempt(); | 84 bool AllowNextLaunchAttempt(); |
| 90 | 85 |
| 91 GURL refocus_url_; | 86 GURL refocus_url_; |
| 92 | 87 |
| 93 // Since V2 applications can be undetectable after launching, this timer is | 88 // Since V2 applications can be undetectable after launching, this timer is |
| 94 // keeping track of the last launch attempt. | 89 // keeping track of the last launch attempt. |
| 95 base::Time last_launch_attempt_; | 90 base::Time last_launch_attempt_; |
| 96 | 91 |
| 97 ChromeLauncherController* chrome_launcher_controller_; | |
| 98 | |
| 99 // The cached list of open app web contents shown in an application menu. | 92 // The cached list of open app web contents shown in an application menu. |
| 100 std::vector<content::WebContents*> app_menu_items_; | 93 std::vector<content::WebContents*> app_menu_items_; |
| 101 | 94 |
| 102 DISALLOW_COPY_AND_ASSIGN(AppShortcutLauncherItemController); | 95 DISALLOW_COPY_AND_ASSIGN(AppShortcutLauncherItemController); |
| 103 }; | 96 }; |
| 104 | 97 |
| 105 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_
H_ | 98 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_APP_SHORTCUT_LAUNCHER_ITEM_CONTROLLER_
H_ |
| OLD | NEW |