| OLD | NEW |
| 1 // Copyright 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_EXTENSIONS_LAUNCH_UTIL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_LAUNCH_UTIL_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_LAUNCH_UTIL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_LAUNCH_UTIL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "extensions/common/constants.h" | 10 #include "chrome/common/extensions/extension_constants.h" |
| 11 | 11 |
| 12 namespace extensions { | 12 namespace extensions { |
| 13 | 13 |
| 14 class Extension; | 14 class Extension; |
| 15 class ExtensionPrefs; | 15 class ExtensionPrefs; |
| 16 | 16 |
| 17 // This enum is used for the launch type the user wants to use for an | |
| 18 // application. | |
| 19 // Do not remove items or re-order this enum as it is used in preferences | |
| 20 // and histograms. | |
| 21 enum LaunchType { | |
| 22 LAUNCH_TYPE_PINNED, | |
| 23 LAUNCH_TYPE_REGULAR, | |
| 24 LAUNCH_TYPE_FULLSCREEN, | |
| 25 LAUNCH_TYPE_WINDOW, | |
| 26 | |
| 27 // Launch an app in the in the way a click on the NTP would, | |
| 28 // if no user pref were set. Update this constant to change | |
| 29 // the default for the NTP and chrome.management.launchApp(). | |
| 30 LAUNCH_TYPE_DEFAULT = LAUNCH_TYPE_REGULAR | |
| 31 }; | |
| 32 | |
| 33 // Gets the launch type preference. If no preference is set, returns | 17 // Gets the launch type preference. If no preference is set, returns |
| 34 // LAUNCH_DEFAULT. | 18 // LAUNCH_TYPE_DEFAULT. |
| 35 // Returns LAUNCH_WINDOW if there's no preference and | 19 // Returns LAUNCH_TYPE_WINDOW if there's no preference and |
| 36 // 'streamlined hosted apps' are enabled. | 20 // 'streamlined hosted apps' are enabled. |
| 37 LaunchType GetLaunchType(const ExtensionPrefs* prefs, | 21 LaunchType GetLaunchType(const ExtensionPrefs* prefs, |
| 38 const Extension* extension); | 22 const Extension* extension); |
| 39 | 23 |
| 40 // Sets an extension's launch type preference. | 24 // Sets an extension's launch type preference. |
| 41 void SetLaunchType(ExtensionPrefs* prefs, | 25 void SetLaunchType(ExtensionPrefs* prefs, |
| 42 const std::string& extension_id, | 26 const std::string& extension_id, |
| 43 LaunchType launch_type); | 27 LaunchType launch_type); |
| 44 | 28 |
| 45 // Finds the right launch container based on the launch type. | 29 // Finds the right launch container based on the launch type. |
| 46 // If |extension|'s prefs do not have a launch type set, then the default | 30 // If |extension|'s prefs do not have a launch type set, then the default |
| 47 // value from GetLaunchType() is used to choose the launch container. | 31 // value from GetLaunchType() is used to choose the launch container. |
| 48 LaunchContainer GetLaunchContainer(const ExtensionPrefs* prefs, | 32 LaunchContainer GetLaunchContainer(const ExtensionPrefs* prefs, |
| 49 const Extension* extension); | 33 const Extension* extension); |
| 50 | 34 |
| 51 // Returns true if a launch container preference has been specified for | 35 // Returns true if a launch container preference has been specified for |
| 52 // |extension|. GetLaunchContainer() will still return a default value even if | 36 // |extension|. GetLaunchContainer() will still return a default value even if |
| 53 // this returns false. | 37 // this returns false. |
| 54 bool HasPreferredLaunchContainer(const ExtensionPrefs* prefs, | 38 bool HasPreferredLaunchContainer(const ExtensionPrefs* prefs, |
| 55 const Extension* extension); | 39 const Extension* extension); |
| 56 | 40 |
| 57 } // namespace extensions | 41 } // namespace extensions |
| 58 | 42 |
| 59 #endif // CHROME_BROWSER_EXTENSIONS_LAUNCH_UTIL_H_ | 43 #endif // CHROME_BROWSER_EXTENSIONS_LAUNCH_UTIL_H_ |
| OLD | NEW |