Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: chrome/browser/extensions/api/storage/settings_test_util.cc

Issue 12093036: Move Extension Location and Type enums to Manifest, and move InstallWarning to its own file. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/storage/settings_test_util.h" 5 #include "chrome/browser/extensions/api/storage/settings_test_util.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "chrome/browser/extensions/api/storage/settings_frontend.h" 8 #include "chrome/browser/extensions/api/storage/settings_frontend.h"
9 #include "chrome/browser/extensions/extension_system_factory.h" 9 #include "chrome/browser/extensions/extension_system_factory.h"
10 #include "chrome/common/extensions/extension.h" 10 #include "chrome/common/extensions/extension.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 const Extension* MockExtensionService::GetExtensionById( 45 const Extension* MockExtensionService::GetExtensionById(
46 const std::string& id, bool include_disabled) const { 46 const std::string& id, bool include_disabled) const {
47 std::map<std::string, scoped_refptr<Extension> >::const_iterator 47 std::map<std::string, scoped_refptr<Extension> >::const_iterator
48 maybe_extension = extensions_.find(id); 48 maybe_extension = extensions_.find(id);
49 return maybe_extension == extensions_.end() ? 49 return maybe_extension == extensions_.end() ?
50 NULL : maybe_extension->second.get(); 50 NULL : maybe_extension->second.get();
51 } 51 }
52 52
53 void MockExtensionService::AddExtensionWithId( 53 void MockExtensionService::AddExtensionWithId(
54 const std::string& id, Extension::Type type) { 54 const std::string& id, Manifest::Type type) {
55 std::set<std::string> empty_permissions; 55 std::set<std::string> empty_permissions;
56 AddExtensionWithIdAndPermissions(id, type, empty_permissions); 56 AddExtensionWithIdAndPermissions(id, type, empty_permissions);
57 } 57 }
58 58
59 void MockExtensionService::AddExtensionWithIdAndPermissions( 59 void MockExtensionService::AddExtensionWithIdAndPermissions(
60 const std::string& id, 60 const std::string& id,
61 Extension::Type type, 61 Manifest::Type type,
62 const std::set<std::string>& permissions_set) { 62 const std::set<std::string>& permissions_set) {
63 DictionaryValue manifest; 63 DictionaryValue manifest;
64 manifest.SetString("name", std::string("Test extension ") + id); 64 manifest.SetString("name", std::string("Test extension ") + id);
65 manifest.SetString("version", "1.0"); 65 manifest.SetString("version", "1.0");
66 66
67 scoped_ptr<ListValue> permissions(new ListValue()); 67 scoped_ptr<ListValue> permissions(new ListValue());
68 for (std::set<std::string>::const_iterator it = permissions_set.begin(); 68 for (std::set<std::string>::const_iterator it = permissions_set.begin();
69 it != permissions_set.end(); ++it) { 69 it != permissions_set.end(); ++it) {
70 permissions->Append(Value::CreateStringValue(*it)); 70 permissions->Append(Value::CreateStringValue(*it));
71 } 71 }
72 manifest.Set("permissions", permissions.release()); 72 manifest.Set("permissions", permissions.release());
73 73
74 switch (type) { 74 switch (type) {
75 case Extension::TYPE_EXTENSION: 75 case Manifest::TYPE_EXTENSION:
76 break; 76 break;
77 77
78 case Extension::TYPE_LEGACY_PACKAGED_APP: { 78 case Manifest::TYPE_LEGACY_PACKAGED_APP: {
79 DictionaryValue* app = new DictionaryValue(); 79 DictionaryValue* app = new DictionaryValue();
80 DictionaryValue* app_launch = new DictionaryValue(); 80 DictionaryValue* app_launch = new DictionaryValue();
81 app_launch->SetString("local_path", "fake.html"); 81 app_launch->SetString("local_path", "fake.html");
82 app->Set("launch", app_launch); 82 app->Set("launch", app_launch);
83 manifest.Set("app", app); 83 manifest.Set("app", app);
84 break; 84 break;
85 } 85 }
86 86
87 default: 87 default:
88 NOTREACHED(); 88 NOTREACHED();
89 } 89 }
90 90
91 std::string error; 91 std::string error;
92 scoped_refptr<Extension> extension(Extension::Create( 92 scoped_refptr<Extension> extension(Extension::Create(
93 FilePath(), 93 FilePath(),
94 Extension::INTERNAL, 94 Manifest::INTERNAL,
95 manifest, 95 manifest,
96 Extension::NO_FLAGS, 96 Extension::NO_FLAGS,
97 id, 97 id,
98 &error)); 98 &error));
99 DCHECK(extension.get()); 99 DCHECK(extension.get());
100 DCHECK(error.empty()); 100 DCHECK(error.empty());
101 extensions_[id] = extension; 101 extensions_[id] = extension;
102 102
103 for (std::set<std::string>::const_iterator it = permissions_set.begin(); 103 for (std::set<std::string>::const_iterator it = permissions_set.begin();
104 it != permissions_set.end(); ++it) { 104 it != permissions_set.end(); ++it) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 ValueStore* ScopedSettingsStorageFactory::Create( 156 ValueStore* ScopedSettingsStorageFactory::Create(
157 const FilePath& base_path, 157 const FilePath& base_path,
158 const std::string& extension_id) { 158 const std::string& extension_id) {
159 DCHECK(delegate_.get()); 159 DCHECK(delegate_.get());
160 return delegate_->Create(base_path, extension_id); 160 return delegate_->Create(base_path, extension_id);
161 } 161 }
162 162
163 } // namespace settings_test_util 163 } // namespace settings_test_util
164 164
165 } // namespace extensions 165 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/storage/settings_test_util.h ('k') | chrome/browser/extensions/app_process_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698