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

Unified Diff: chrome/browser/extensions/extension_settings_test_util.cc

Issue 8375047: Separate the syncing of extension settings and app settings into separate data (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_settings_test_util.cc
diff --git a/chrome/browser/extensions/extension_settings_test_util.cc b/chrome/browser/extensions/extension_settings_test_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8ed7cdc927e5d81ae1f260368fc416ed7a3e1219
--- /dev/null
+++ b/chrome/browser/extensions/extension_settings_test_util.cc
@@ -0,0 +1,95 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/extensions/extension_settings_test_util.h"
+
+#include "base/file_path.h"
+#include "chrome/common/extensions/extension.h"
+
+namespace extension_settings_test_util {
+
+// Intended as a StorageCallback from GetStorage.
+static void AssignStorage(
+ ExtensionSettingsStorage** dst, ExtensionSettingsStorage* src) {
+ *dst = src;
+}
+
+ExtensionSettingsStorage* GetStorage(
+ const std::string& extension_id, ExtensionSettingsFrontend* frontend) {
+ ExtensionSettingsStorage* storage = NULL;
+ frontend->RunWithStorage(
+ extension_id,
+ base::Bind(&AssignStorage, &storage));
+ MessageLoop::current()->RunAllPending();
+ return storage;
+}
+
+MockExtensionService::MockExtensionService() {}
+
+MockExtensionService::~MockExtensionService() {}
+
+const Extension* MockExtensionService::GetExtensionById(
+ const std::string& id, bool include_disabled) const {
+ std::map<std::string, scoped_refptr<Extension> >::const_iterator
+ maybe_extension = extensions_.find(id);
+ return maybe_extension == extensions_.end() ?
+ NULL : maybe_extension->second.get();
+}
+
+void MockExtensionService::AddExtension(
+ const std::string& id, Extension::Type type) {
+ DictionaryValue manifest;
+ manifest.SetString("name", std::string("Test extension ") + id);
+ manifest.SetString("version", "1.0");
+
+ switch (type) {
+ case Extension::TYPE_EXTENSION:
+ break;
+
+ case Extension::TYPE_PACKAGED_APP: {
+ DictionaryValue* app = new DictionaryValue();
+ DictionaryValue* app_launch = new DictionaryValue();
+ app_launch->SetString("local_path", "fake.html");
+ app->Set("launch", app_launch);
+ manifest.Set("app", app);
+ break;
+ }
+
+ default:
+ NOTREACHED();
+ }
+
+ std::string error;
+ extensions_[id] = Extension::CreateWithId(
+ FilePath(),
+ Extension::INTERNAL,
+ manifest,
+ Extension::NO_FLAGS,
+ id,
+ &error);
+ DCHECK(error.empty());
+}
+
+MockProfile::MockProfile(const FilePath& file_path)
+ : TestingProfile(file_path) {
+ event_router_.reset(new ExtensionEventRouter(this));
+}
+
+MockProfile::~MockProfile() {}
+
+MockExtensionService* MockProfile::GetMockExtensionService() {
+ return &extension_service_;
+}
+
+ExtensionService* MockProfile::GetExtensionService() {
+ ExtensionServiceInterface* as_interface =
+ static_cast<ExtensionServiceInterface*>(&extension_service_);
+ return static_cast<ExtensionService*>(as_interface);
+}
+
+ExtensionEventRouter* MockProfile::GetExtensionEventRouter() {
+ return event_router_.get();
+}
+
+} // namespace extension_settings_test_util

Powered by Google App Engine
This is Rietveld 408576698