| 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 #include "chrome/browser/extensions/api/autotest_private/autotest_private_api.h" | 5 #include "chrome/browser/extensions/api/autotest_private/autotest_private_api.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "chrome/browser/extensions/api/autotest_private/autotest_private_api_fa
ctory.h" | 8 #include "chrome/browser/extensions/api/autotest_private/autotest_private_api_fa
ctory.h" |
| 9 #include "chrome/browser/extensions/extension_action_manager.h" | 9 #include "chrome/browser/extensions/extension_action_manager.h" |
| 10 #include "chrome/browser/extensions/extension_function_registry.h" | 10 #include "chrome/browser/extensions/extension_function_registry.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #if defined(OS_CHROMEOS) | 22 #if defined(OS_CHROMEOS) |
| 23 #include "chrome/browser/chromeos/login/screen_locker.h" | 23 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 24 #include "chrome/browser/chromeos/login/user_manager.h" | 24 #include "chrome/browser/chromeos/login/user_manager.h" |
| 25 #include "chromeos/dbus/dbus_thread_manager.h" | 25 #include "chromeos/dbus/dbus_thread_manager.h" |
| 26 #include "chromeos/dbus/session_manager_client.h" | 26 #include "chromeos/dbus/session_manager_client.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 namespace extensions { | 29 namespace extensions { |
| 30 namespace { | 30 namespace { |
| 31 | 31 |
| 32 ListValue* GetHostPermissions(const Extension* ext, bool effective_perm) { | 32 base::ListValue* GetHostPermissions(const Extension* ext, bool effective_perm) { |
| 33 extensions::URLPatternSet pattern_set; | 33 extensions::URLPatternSet pattern_set; |
| 34 if (effective_perm) { | 34 if (effective_perm) { |
| 35 pattern_set = | 35 pattern_set = |
| 36 extensions::PermissionsData::GetEffectiveHostPermissions(ext); | 36 extensions::PermissionsData::GetEffectiveHostPermissions(ext); |
| 37 } else { | 37 } else { |
| 38 pattern_set = ext->GetActivePermissions()->explicit_hosts(); | 38 pattern_set = ext->GetActivePermissions()->explicit_hosts(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 ListValue* permissions = new ListValue; | 41 base::ListValue* permissions = new base::ListValue; |
| 42 for (extensions::URLPatternSet::const_iterator perm = pattern_set.begin(); | 42 for (extensions::URLPatternSet::const_iterator perm = pattern_set.begin(); |
| 43 perm != pattern_set.end(); ++perm) { | 43 perm != pattern_set.end(); ++perm) { |
| 44 permissions->Append(new StringValue(perm->GetAsString())); | 44 permissions->Append(new base::StringValue(perm->GetAsString())); |
| 45 } | 45 } |
| 46 | 46 |
| 47 return permissions; | 47 return permissions; |
| 48 } | 48 } |
| 49 | 49 |
| 50 ListValue* GetAPIPermissions(const Extension* ext) { | 50 base::ListValue* GetAPIPermissions(const Extension* ext) { |
| 51 ListValue* permissions = new ListValue; | 51 base::ListValue* permissions = new base::ListValue; |
| 52 std::set<std::string> perm_list = | 52 std::set<std::string> perm_list = |
| 53 ext->GetActivePermissions()->GetAPIsAsStrings(); | 53 ext->GetActivePermissions()->GetAPIsAsStrings(); |
| 54 for (std::set<std::string>::const_iterator perm = perm_list.begin(); | 54 for (std::set<std::string>::const_iterator perm = perm_list.begin(); |
| 55 perm != perm_list.end(); ++perm) { | 55 perm != perm_list.end(); ++perm) { |
| 56 permissions->Append(new StringValue(perm->c_str())); | 56 permissions->Append(new base::StringValue(perm->c_str())); |
| 57 } | 57 } |
| 58 return permissions; | 58 return permissions; |
| 59 } | 59 } |
| 60 | 60 |
| 61 } // namespace | 61 } // namespace |
| 62 | 62 |
| 63 bool AutotestPrivateLogoutFunction::RunImpl() { | 63 bool AutotestPrivateLogoutFunction::RunImpl() { |
| 64 DVLOG(1) << "AutotestPrivateLogoutFunction"; | 64 DVLOG(1) << "AutotestPrivateLogoutFunction"; |
| 65 if (!AutotestPrivateAPIFactory::GetForProfile(GetProfile())->test_mode()) | 65 if (!AutotestPrivateAPIFactory::GetForProfile(GetProfile())->test_mode()) |
| 66 chrome::AttemptUserExit(); | 66 chrome::AttemptUserExit(); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 bool AutotestPrivateGetExtensionsInfoFunction::RunImpl() { | 151 bool AutotestPrivateGetExtensionsInfoFunction::RunImpl() { |
| 152 DVLOG(1) << "AutotestPrivateGetExtensionsInfoFunction"; | 152 DVLOG(1) << "AutotestPrivateGetExtensionsInfoFunction"; |
| 153 | 153 |
| 154 ExtensionService* service = extensions::ExtensionSystem::Get( | 154 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 155 GetProfile())->extension_service(); | 155 GetProfile())->extension_service(); |
| 156 const ExtensionSet* extensions = service->extensions(); | 156 const ExtensionSet* extensions = service->extensions(); |
| 157 const ExtensionSet* disabled_extensions = service->disabled_extensions(); | 157 const ExtensionSet* disabled_extensions = service->disabled_extensions(); |
| 158 ExtensionActionManager* extension_action_manager = | 158 ExtensionActionManager* extension_action_manager = |
| 159 ExtensionActionManager::Get(GetProfile()); | 159 ExtensionActionManager::Get(GetProfile()); |
| 160 | 160 |
| 161 ListValue* extensions_values = new ListValue; | 161 base::ListValue* extensions_values = new base::ListValue; |
| 162 ExtensionList all; | 162 ExtensionList all; |
| 163 all.insert(all.end(), | 163 all.insert(all.end(), |
| 164 extensions->begin(), | 164 extensions->begin(), |
| 165 extensions->end()); | 165 extensions->end()); |
| 166 all.insert(all.end(), | 166 all.insert(all.end(), |
| 167 disabled_extensions->begin(), | 167 disabled_extensions->begin(), |
| 168 disabled_extensions->end()); | 168 disabled_extensions->end()); |
| 169 for (ExtensionList::const_iterator it = all.begin(); | 169 for (ExtensionList::const_iterator it = all.begin(); |
| 170 it != all.end(); ++it) { | 170 it != all.end(); ++it) { |
| 171 const Extension* extension = it->get(); | 171 const Extension* extension = it->get(); |
| 172 std::string id = extension->id(); | 172 std::string id = extension->id(); |
| 173 DictionaryValue* extension_value = new DictionaryValue; | 173 base::DictionaryValue* extension_value = new base::DictionaryValue; |
| 174 extension_value->SetString("id", id); | 174 extension_value->SetString("id", id); |
| 175 extension_value->SetString("version", extension->VersionString()); | 175 extension_value->SetString("version", extension->VersionString()); |
| 176 extension_value->SetString("name", extension->name()); | 176 extension_value->SetString("name", extension->name()); |
| 177 extension_value->SetString("publicKey", extension->public_key()); | 177 extension_value->SetString("publicKey", extension->public_key()); |
| 178 extension_value->SetString("description", extension->description()); | 178 extension_value->SetString("description", extension->description()); |
| 179 extension_value->SetString("backgroundUrl", | 179 extension_value->SetString("backgroundUrl", |
| 180 extensions::BackgroundInfo::GetBackgroundURL(extension).spec()); | 180 extensions::BackgroundInfo::GetBackgroundURL(extension).spec()); |
| 181 extension_value->SetString("optionsUrl", | 181 extension_value->SetString("optionsUrl", |
| 182 extensions::ManifestURL::GetOptionsPage(extension).spec()); | 182 extensions::ManifestURL::GetOptionsPage(extension).spec()); |
| 183 | 183 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 198 extension_value->SetBoolean("isEnabled", service->IsExtensionEnabled(id)); | 198 extension_value->SetBoolean("isEnabled", service->IsExtensionEnabled(id)); |
| 199 extension_value->SetBoolean("allowedInIncognito", | 199 extension_value->SetBoolean("allowedInIncognito", |
| 200 extension_util::IsIncognitoEnabled(id, service)); | 200 extension_util::IsIncognitoEnabled(id, service)); |
| 201 extension_value->SetBoolean( | 201 extension_value->SetBoolean( |
| 202 "hasPageAction", | 202 "hasPageAction", |
| 203 extension_action_manager->GetPageAction(*extension) != NULL); | 203 extension_action_manager->GetPageAction(*extension) != NULL); |
| 204 | 204 |
| 205 extensions_values->Append(extension_value); | 205 extensions_values->Append(extension_value); |
| 206 } | 206 } |
| 207 | 207 |
| 208 DictionaryValue* return_value(new DictionaryValue); | 208 base::DictionaryValue* return_value(new base::DictionaryValue); |
| 209 return_value->Set("extensions", extensions_values); | 209 return_value->Set("extensions", extensions_values); |
| 210 SetResult(return_value); | 210 SetResult(return_value); |
| 211 return true; | 211 return true; |
| 212 } | 212 } |
| 213 | 213 |
| 214 static int AccessArray(const volatile int arr[], const volatile int *index) { | 214 static int AccessArray(const volatile int arr[], const volatile int *index) { |
| 215 return arr[*index]; | 215 return arr[*index]; |
| 216 } | 216 } |
| 217 | 217 |
| 218 bool AutotestPrivateSimulateAsanMemoryBugFunction::RunImpl() { | 218 bool AutotestPrivateSimulateAsanMemoryBugFunction::RunImpl() { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 229 } | 229 } |
| 230 | 230 |
| 231 | 231 |
| 232 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { | 232 AutotestPrivateAPI::AutotestPrivateAPI() : test_mode_(false) { |
| 233 } | 233 } |
| 234 | 234 |
| 235 AutotestPrivateAPI::~AutotestPrivateAPI() { | 235 AutotestPrivateAPI::~AutotestPrivateAPI() { |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace extensions | 238 } // namespace extensions |
| OLD | NEW |