| 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/sync/test/integration/sync_extension_helper.h" | 5 #include "chrome/browser/sync/test/integration/sync_extension_helper.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/extensions/extension_service.h" | 11 #include "chrome/browser/extensions/extension_service.h" |
| 12 #include "chrome/browser/extensions/extension_system.h" | 12 #include "chrome/browser/extensions/extension_system.h" |
| 13 #include "chrome/browser/extensions/pending_extension_info.h" | 13 #include "chrome/browser/extensions/pending_extension_info.h" |
| 14 #include "chrome/browser/extensions/pending_extension_manager.h" | 14 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 16 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
| 17 #include "chrome/browser/sync/test/integration/sync_test.h" | 17 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 18 #include "chrome/common/extensions/extension.h" | 18 #include "chrome/common/extensions/extension.h" |
| 19 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 20 #include "extensions/common/id_util.h" | 19 #include "extensions/common/id_util.h" |
| 20 #include "extensions/common/manifest_constants.h" |
| 21 #include "sync/api/string_ordinal.h" | 21 #include "sync/api/string_ordinal.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 23 |
| 24 using extensions::Extension; | 24 using extensions::Extension; |
| 25 using extensions::Manifest; | 25 using extensions::Manifest; |
| 26 | 26 |
| 27 SyncExtensionHelper::ExtensionState::ExtensionState() | 27 SyncExtensionHelper::ExtensionState::ExtensionState() |
| 28 : enabled_state(ENABLED), incognito_enabled(false) {} | 28 : enabled_state(ENABLED), incognito_enabled(false) {} |
| 29 | 29 |
| 30 SyncExtensionHelper::ExtensionState::~ExtensionState() {} | 30 SyncExtensionHelper::ExtensionState::~ExtensionState() {} |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 true /* is_public */)); | 266 true /* is_public */)); |
| 267 return public_key; | 267 return public_key; |
| 268 } | 268 } |
| 269 | 269 |
| 270 // TODO(akalin): Somehow unify this with MakeExtension() in | 270 // TODO(akalin): Somehow unify this with MakeExtension() in |
| 271 // extension_util_unittest.cc. | 271 // extension_util_unittest.cc. |
| 272 scoped_refptr<Extension> CreateExtension(const base::FilePath& base_dir, | 272 scoped_refptr<Extension> CreateExtension(const base::FilePath& base_dir, |
| 273 const std::string& name, | 273 const std::string& name, |
| 274 Manifest::Type type) { | 274 Manifest::Type type) { |
| 275 DictionaryValue source; | 275 DictionaryValue source; |
| 276 source.SetString(extension_manifest_keys::kName, name); | 276 source.SetString(extensions::manifest_keys::kName, name); |
| 277 const std::string& public_key = NameToPublicKey(name); | 277 const std::string& public_key = NameToPublicKey(name); |
| 278 source.SetString(extension_manifest_keys::kPublicKey, public_key); | 278 source.SetString(extensions::manifest_keys::kPublicKey, public_key); |
| 279 source.SetString(extension_manifest_keys::kVersion, "0.0.0.0"); | 279 source.SetString(extensions::manifest_keys::kVersion, "0.0.0.0"); |
| 280 switch (type) { | 280 switch (type) { |
| 281 case Manifest::TYPE_EXTENSION: | 281 case Manifest::TYPE_EXTENSION: |
| 282 // Do nothing. | 282 // Do nothing. |
| 283 break; | 283 break; |
| 284 case Manifest::TYPE_THEME: | 284 case Manifest::TYPE_THEME: |
| 285 source.Set(extension_manifest_keys::kTheme, new DictionaryValue()); | 285 source.Set(extensions::manifest_keys::kTheme, new DictionaryValue()); |
| 286 break; | 286 break; |
| 287 case Manifest::TYPE_HOSTED_APP: | 287 case Manifest::TYPE_HOSTED_APP: |
| 288 case Manifest::TYPE_LEGACY_PACKAGED_APP: | 288 case Manifest::TYPE_LEGACY_PACKAGED_APP: |
| 289 source.Set(extension_manifest_keys::kApp, new DictionaryValue()); | 289 source.Set(extensions::manifest_keys::kApp, new DictionaryValue()); |
| 290 source.SetString(extension_manifest_keys::kLaunchWebURL, | 290 source.SetString(extensions::manifest_keys::kLaunchWebURL, |
| 291 "http://www.example.com"); | 291 "http://www.example.com"); |
| 292 break; | 292 break; |
| 293 case Manifest::TYPE_PLATFORM_APP: { | 293 case Manifest::TYPE_PLATFORM_APP: { |
| 294 source.Set(extension_manifest_keys::kApp, new DictionaryValue()); | 294 source.Set(extensions::manifest_keys::kApp, new DictionaryValue()); |
| 295 source.Set(extension_manifest_keys::kPlatformAppBackground, | 295 source.Set(extensions::manifest_keys::kPlatformAppBackground, |
| 296 new DictionaryValue()); | 296 new DictionaryValue()); |
| 297 ListValue* scripts = new ListValue(); | 297 ListValue* scripts = new ListValue(); |
| 298 scripts->AppendString("main.js"); | 298 scripts->AppendString("main.js"); |
| 299 source.Set(extension_manifest_keys::kPlatformAppBackgroundScripts, | 299 source.Set(extensions::manifest_keys::kPlatformAppBackgroundScripts, |
| 300 scripts); | 300 scripts); |
| 301 break; | 301 break; |
| 302 } | 302 } |
| 303 default: | 303 default: |
| 304 ADD_FAILURE(); | 304 ADD_FAILURE(); |
| 305 return NULL; | 305 return NULL; |
| 306 } | 306 } |
| 307 const base::FilePath sub_dir = base::FilePath().AppendASCII(name); | 307 const base::FilePath sub_dir = base::FilePath().AppendASCII(name); |
| 308 base::FilePath extension_dir; | 308 base::FilePath extension_dir; |
| 309 if (!base::PathExists(base_dir) && | 309 if (!base::PathExists(base_dir) && |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 EXPECT_EQ(expected_id, extension->id()); | 369 EXPECT_EQ(expected_id, extension->id()); |
| 370 return NULL; | 370 return NULL; |
| 371 } | 371 } |
| 372 DVLOG(2) << "created extension with name = " | 372 DVLOG(2) << "created extension with name = " |
| 373 << name << ", id = " << expected_id; | 373 << name << ", id = " << expected_id; |
| 374 (it->second)[name] = extension; | 374 (it->second)[name] = extension; |
| 375 id_to_name_[expected_id] = name; | 375 id_to_name_[expected_id] = name; |
| 376 id_to_type_[expected_id] = type; | 376 id_to_type_[expected_id] = type; |
| 377 return extension; | 377 return extension; |
| 378 } | 378 } |
| OLD | NEW |