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/command_line.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/host_desktop.h" | 11 #include "chrome/browser/ui/host_desktop.h" |
11 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/extensions/extension_constants.h" | 13 #include "chrome/common/extensions/extension_constants.h" |
13 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 14 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
14 #include "components/user_prefs/pref_registry_syncable.h" | 15 #include "components/user_prefs/pref_registry_syncable.h" |
15 #include "extensions/browser/extension_prefs.h" | 16 #include "extensions/browser/extension_prefs.h" |
16 #include "extensions/browser/pref_names.h" | 17 #include "extensions/browser/pref_names.h" |
17 #include "extensions/common/extension.h" | 18 #include "extensions/common/extension.h" |
18 | 19 |
19 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 int value = LAUNCH_TYPE_INVALID; | 83 int value = LAUNCH_TYPE_INVALID; |
83 return prefs->ReadPrefAsInteger(extension_id, kPrefLaunchType, &value) | 84 return prefs->ReadPrefAsInteger(extension_id, kPrefLaunchType, &value) |
84 ? static_cast<LaunchType>(value) : LAUNCH_TYPE_INVALID; | 85 ? static_cast<LaunchType>(value) : LAUNCH_TYPE_INVALID; |
85 } | 86 } |
86 | 87 |
87 void SetLaunchType(ExtensionService* service, | 88 void SetLaunchType(ExtensionService* service, |
88 const std::string& extension_id, | 89 const std::string& extension_id, |
89 LaunchType launch_type) { | 90 LaunchType launch_type) { |
90 DCHECK(launch_type >= LAUNCH_TYPE_FIRST && launch_type < NUM_LAUNCH_TYPES); | 91 DCHECK(launch_type >= LAUNCH_TYPE_FIRST && launch_type < NUM_LAUNCH_TYPES); |
91 | 92 |
92 service->extension_prefs()->UpdateExtensionPref(extension_id, kPrefLaunchType, | 93 ExtensionPrefs::Get(service->profile())->UpdateExtensionPref( |
| 94 extension_id, |
| 95 kPrefLaunchType, |
93 new base::FundamentalValue(static_cast<int>(launch_type))); | 96 new base::FundamentalValue(static_cast<int>(launch_type))); |
94 | 97 |
95 // Sync the launch type. | 98 // Sync the launch type. |
96 const Extension* extension = service->GetInstalledExtension(extension_id); | 99 const Extension* extension = service->GetInstalledExtension(extension_id); |
97 if (extension) { | 100 if (extension) { |
98 ExtensionSyncService::Get(service->profile())-> | 101 ExtensionSyncService::Get(service->profile())-> |
99 SyncExtensionChangeIfNeeded(*extension); | 102 SyncExtensionChangeIfNeeded(*extension); |
100 } | 103 } |
101 } | 104 } |
102 | 105 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 bool HasPreferredLaunchContainer(const ExtensionPrefs* prefs, | 159 bool HasPreferredLaunchContainer(const ExtensionPrefs* prefs, |
157 const Extension* extension) { | 160 const Extension* extension) { |
158 int value = -1; | 161 int value = -1; |
159 LaunchContainer manifest_launch_container = | 162 LaunchContainer manifest_launch_container = |
160 AppLaunchInfo::GetLaunchContainer(extension); | 163 AppLaunchInfo::GetLaunchContainer(extension); |
161 return manifest_launch_container == LAUNCH_CONTAINER_TAB && | 164 return manifest_launch_container == LAUNCH_CONTAINER_TAB && |
162 prefs->ReadPrefAsInteger(extension->id(), kPrefLaunchType, &value); | 165 prefs->ReadPrefAsInteger(extension->id(), kPrefLaunchType, &value); |
163 } | 166 } |
164 | 167 |
165 } // namespace extensions | 168 } // namespace extensions |
OLD | NEW |