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 #include "chrome/browser/extensions/launch_util.h" | 5 #include "chrome/browser/extensions/launch_util.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | |
| 7 #include "base/values.h" | 8 #include "base/values.h" |
| 8 #include "chrome/browser/extensions/extension_sync_service.h" | 9 #include "chrome/browser/extensions/extension_sync_service.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/host_desktop.h" | 11 #include "chrome/browser/ui/host_desktop.h" |
| 12 #include "chrome/common/chrome_switches.h" | |
| 11 #include "chrome/common/extensions/extension_constants.h" | 13 #include "chrome/common/extensions/extension_constants.h" |
| 12 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 14 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
| 13 #include "components/pref_registry/pref_registry_syncable.h" | 15 #include "components/pref_registry/pref_registry_syncable.h" |
| 14 #include "extensions/browser/extension_prefs.h" | 16 #include "extensions/browser/extension_prefs.h" |
| 15 #include "extensions/browser/extension_registry.h" | 17 #include "extensions/browser/extension_registry.h" |
| 16 #include "extensions/browser/pref_names.h" | 18 #include "extensions/browser/pref_names.h" |
| 17 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
| 18 | 20 |
| 19 #if defined(USE_ASH) | 21 #if defined(USE_ASH) |
| 20 #include "ash/shell.h" | 22 #include "ash/shell.h" |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 42 } // namespace launch_util | 44 } // namespace launch_util |
| 43 | 45 |
| 44 LaunchType GetLaunchType(const ExtensionPrefs* prefs, | 46 LaunchType GetLaunchType(const ExtensionPrefs* prefs, |
| 45 const Extension* extension) { | 47 const Extension* extension) { |
| 46 LaunchType result = LAUNCH_TYPE_DEFAULT; | 48 LaunchType result = LAUNCH_TYPE_DEFAULT; |
| 47 | 49 |
| 48 int value = GetLaunchTypePrefValue(prefs, extension->id()); | 50 int value = GetLaunchTypePrefValue(prefs, extension->id()); |
| 49 if (value >= LAUNCH_TYPE_FIRST && value < NUM_LAUNCH_TYPES) | 51 if (value >= LAUNCH_TYPE_FIRST && value < NUM_LAUNCH_TYPES) |
| 50 result = static_cast<LaunchType>(value); | 52 result = static_cast<LaunchType>(value); |
| 51 | 53 |
| 54 #if defined(OS_MACOSX) | |
| 55 // On Mac, opening in a window is only supported if bookmark apps are enabled. | |
| 56 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 57 switches::kDisableNewBookmarkApps) && | |
|
benwells
2015/02/16 07:52:19
Please use IsNewBookmarkAppsEnabled instead (https
jackhou1
2015/02/16 23:20:27
Done.
| |
| 58 !extension->is_platform_app() && result == LAUNCH_TYPE_WINDOW) | |
| 59 result = LAUNCH_TYPE_REGULAR; | |
| 60 #endif | |
| 61 | |
| 52 return result; | 62 return result; |
| 53 } | 63 } |
| 54 | 64 |
| 55 LaunchType GetLaunchTypePrefValue(const ExtensionPrefs* prefs, | 65 LaunchType GetLaunchTypePrefValue(const ExtensionPrefs* prefs, |
| 56 const std::string& extension_id) { | 66 const std::string& extension_id) { |
| 57 int value = LAUNCH_TYPE_INVALID; | 67 int value = LAUNCH_TYPE_INVALID; |
| 58 return prefs->ReadPrefAsInteger(extension_id, kPrefLaunchType, &value) | 68 return prefs->ReadPrefAsInteger(extension_id, kPrefLaunchType, &value) |
| 59 ? static_cast<LaunchType>(value) : LAUNCH_TYPE_INVALID; | 69 ? static_cast<LaunchType>(value) : LAUNCH_TYPE_INVALID; |
| 60 } | 70 } |
| 61 | 71 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 bool HasPreferredLaunchContainer(const ExtensionPrefs* prefs, | 142 bool HasPreferredLaunchContainer(const ExtensionPrefs* prefs, |
| 133 const Extension* extension) { | 143 const Extension* extension) { |
| 134 int value = -1; | 144 int value = -1; |
| 135 LaunchContainer manifest_launch_container = | 145 LaunchContainer manifest_launch_container = |
| 136 AppLaunchInfo::GetLaunchContainer(extension); | 146 AppLaunchInfo::GetLaunchContainer(extension); |
| 137 return manifest_launch_container == LAUNCH_CONTAINER_TAB && | 147 return manifest_launch_container == LAUNCH_CONTAINER_TAB && |
| 138 prefs->ReadPrefAsInteger(extension->id(), kPrefLaunchType, &value); | 148 prefs->ReadPrefAsInteger(extension->id(), kPrefLaunchType, &value); |
| 139 } | 149 } |
| 140 | 150 |
| 141 } // namespace extensions | 151 } // namespace extensions |
| OLD | NEW |