| 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_LAUNCHER_CONTROLLER_HELPER_H_ | 5 #ifndef CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTROLLER_HELPER_H_ |
| 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTROLLER_HELPER_H_ | 6 #define CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTROLLER_HELPER_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <string> | 9 #include <string> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_types.h" |
| 14 #include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h" |
| 12 | 15 |
| 16 class ExtensionEnableFlow; |
| 13 class Profile; | 17 class Profile; |
| 14 | 18 |
| 15 namespace content { | 19 namespace content { |
| 16 class WebContents; | 20 class WebContents; |
| 17 } | 21 } |
| 18 | 22 |
| 19 // Assists the LauncherController with ExtensionService interaction. | 23 // Assists the LauncherController with ExtensionService interaction. |
| 20 class LauncherControllerHelper { | 24 class LauncherControllerHelper : public ExtensionEnableFlowDelegate { |
| 21 public: | 25 public: |
| 22 explicit LauncherControllerHelper(Profile* profile); | 26 explicit LauncherControllerHelper(Profile* profile); |
| 23 virtual ~LauncherControllerHelper(); | 27 ~LauncherControllerHelper() override; |
| 24 | 28 |
| 25 // Helper function to return the title associated with |app_id|. | 29 // Helper function to return the title associated with |app_id|. |
| 26 // Returns an empty title if no matching extension can be found. | 30 // Returns an empty title if no matching extension can be found. |
| 27 static base::string16 GetAppTitle(Profile* profile, | 31 static base::string16 GetAppTitle(Profile* profile, |
| 28 const std::string& app_id); | 32 const std::string& app_id); |
| 29 | 33 |
| 30 // Returns the app id of the specified tab, or an empty string if there is | 34 // Returns the app id of the specified tab, or an empty string if there is |
| 31 // no app. All known profiles will be queried for this. | 35 // no app. All known profiles will be queried for this. |
| 32 virtual std::string GetAppID(content::WebContents* tab); | 36 virtual std::string GetAppID(content::WebContents* tab); |
| 33 | 37 |
| 34 // Returns true if |id| is valid for the currently active profile. | 38 // Returns true if |id| is valid for the currently active profile. |
| 35 // Used during restore to ignore no longer valid extensions. | 39 // Used during restore to ignore no longer valid extensions. |
| 36 // Note that already running applications are ignored by the restore process. | 40 // Note that already running applications are ignored by the restore process. |
| 37 virtual bool IsValidIDForCurrentUser(const std::string& id); | 41 virtual bool IsValidIDForCurrentUser(const std::string& id); |
| 38 | 42 |
| 39 // Sets the currently active profile for the usage of |GetAppID|. | 43 // Sets the currently active profile for the usage of |GetAppID|. |
| 40 virtual void SetCurrentUser(Profile* profile); | 44 virtual void SetCurrentUser(Profile* profile); |
| 41 | 45 |
| 46 void LaunchApp(const std::string& app_id, |
| 47 ash::LaunchSource source, |
| 48 int event_flags); |
| 49 |
| 42 private: | 50 private: |
| 51 // ExtensionEnableFlowDelegate: |
| 52 void ExtensionEnableFlowFinished() override; |
| 53 void ExtensionEnableFlowAborted(bool user_initiated) override; |
| 54 |
| 43 Profile* profile_; | 55 Profile* profile_; |
| 56 std::unique_ptr<ExtensionEnableFlow> extension_enable_flow_; |
| 44 | 57 |
| 45 DISALLOW_COPY_AND_ASSIGN(LauncherControllerHelper); | 58 DISALLOW_COPY_AND_ASSIGN(LauncherControllerHelper); |
| 46 }; | 59 }; |
| 47 | 60 |
| 48 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTROLLER_HELPER_H_ | 61 #endif // CHROME_BROWSER_UI_ASH_LAUNCHER_LAUNCHER_CONTROLLER_HELPER_H_ |
| OLD | NEW |