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" | 19 #include "chrome/common/extensions/extension_manifest_constants.h" |
20 #include "extensions/common/id_util.h" | |
20 #include "sync/api/string_ordinal.h" | 21 #include "sync/api/string_ordinal.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
22 | 23 |
23 using extensions::Extension; | 24 using extensions::Extension; |
24 using extensions::Manifest; | 25 using extensions::Manifest; |
25 | 26 |
26 SyncExtensionHelper::ExtensionState::ExtensionState() | 27 SyncExtensionHelper::ExtensionState::ExtensionState() |
27 : enabled_state(ENABLED), incognito_enabled(false) {} | 28 : enabled_state(ENABLED), incognito_enabled(false) {} |
28 | 29 |
29 SyncExtensionHelper::ExtensionState::~ExtensionState() {} | 30 SyncExtensionHelper::ExtensionState::~ExtensionState() {} |
30 | 31 |
31 bool SyncExtensionHelper::ExtensionState::Equals( | 32 bool SyncExtensionHelper::ExtensionState::Equals( |
32 const SyncExtensionHelper::ExtensionState &other) const { | 33 const SyncExtensionHelper::ExtensionState &other) const { |
33 return ((enabled_state == other.enabled_state) && | 34 return ((enabled_state == other.enabled_state) && |
34 (incognito_enabled == other.incognito_enabled)); | 35 (incognito_enabled == other.incognito_enabled)); |
35 } | 36 } |
36 | 37 |
37 // static | 38 // static |
38 SyncExtensionHelper* SyncExtensionHelper::GetInstance() { | 39 SyncExtensionHelper* SyncExtensionHelper::GetInstance() { |
39 SyncExtensionHelper* instance = Singleton<SyncExtensionHelper>::get(); | 40 SyncExtensionHelper* instance = Singleton<SyncExtensionHelper>::get(); |
40 instance->SetupIfNecessary(sync_datatype_helper::test()); | 41 instance->SetupIfNecessary(sync_datatype_helper::test()); |
41 return instance; | 42 return instance; |
42 } | 43 } |
43 | 44 |
44 SyncExtensionHelper::SyncExtensionHelper() : setup_completed_(false) {} | 45 SyncExtensionHelper::SyncExtensionHelper() : setup_completed_(false) {} |
45 | 46 |
46 SyncExtensionHelper::~SyncExtensionHelper() {} | 47 SyncExtensionHelper::~SyncExtensionHelper() {} |
47 | 48 |
48 // static | 49 // static |
49 std::string SyncExtensionHelper::NameToId(const std::string& name) { | 50 std::string SyncExtensionHelper::NameToId(const std::string& name) { |
Jeffrey Yasskin
2013/03/22 20:26:50
Inline this now?
Yoyo Zhou
2013/03/22 21:33:32
Done.
| |
50 std::string id; | 51 return extensions::id_util::GenerateId(name); |
51 EXPECT_TRUE(Extension::GenerateId(name, &id)); | |
52 return id; | |
53 } | 52 } |
54 | 53 |
55 void SyncExtensionHelper::SetupIfNecessary(SyncTest* test) { | 54 void SyncExtensionHelper::SetupIfNecessary(SyncTest* test) { |
56 if (setup_completed_) | 55 if (setup_completed_) |
57 return; | 56 return; |
58 | 57 |
59 for (int i = 0; i < test->num_clients(); ++i) { | 58 for (int i = 0; i < test->num_clients(); ++i) { |
60 SetupProfile(test->GetProfile(i)); | 59 SetupProfile(test->GetProfile(i)); |
61 } | 60 } |
62 SetupProfile(test->verifier()); | 61 SetupProfile(test->verifier()); |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
366 EXPECT_EQ(expected_id, extension->id()); | 365 EXPECT_EQ(expected_id, extension->id()); |
367 return NULL; | 366 return NULL; |
368 } | 367 } |
369 DVLOG(2) << "created extension with name = " | 368 DVLOG(2) << "created extension with name = " |
370 << name << ", id = " << expected_id; | 369 << name << ", id = " << expected_id; |
371 (it->second)[name] = extension; | 370 (it->second)[name] = extension; |
372 id_to_name_[expected_id] = name; | 371 id_to_name_[expected_id] = name; |
373 id_to_type_[expected_id] = type; | 372 id_to_type_[expected_id] = type; |
374 return extension; | 373 return extension; |
375 } | 374 } |
OLD | NEW |