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

Unified Diff: chrome/browser/extensions/api/file_system/file_system_apitest.cc

Issue 330383003: Remove deprecated extension notifications from APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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/api/file_system/file_system_apitest.cc
diff --git a/chrome/browser/extensions/api/file_system/file_system_apitest.cc b/chrome/browser/extensions/api/file_system/file_system_apitest.cc
index ac32e37224f3ef2878cd25df10c35859b4f803dc..6fbdd7ff426d84ff37edd2887380a04a8c76611c 100644
--- a/chrome/browser/extensions/api/file_system/file_system_apitest.cc
+++ b/chrome/browser/extensions/api/file_system/file_system_apitest.cc
@@ -5,41 +5,38 @@
#include "apps/saved_files_service.h"
#include "base/file_util.h"
#include "base/path_service.h"
+#include "base/scoped_observer.h"
#include "build/build_config.h"
#include "chrome/browser/apps/app_browsertest_util.h"
-#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/extensions/api/file_system/file_system_api.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_paths.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_service.h"
#include "extensions/browser/extension_prefs.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/browser/extension_registry_observer.h"
namespace extensions {
namespace {
-class AppInstallObserver : public content::NotificationObserver {
+class AppLoadObserver : public ExtensionRegistryObserver {
public:
- AppInstallObserver(
- base::Callback<void(const Extension*)> callback)
- : callback_(callback) {
- registrar_.Add(this,
- chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
- content::NotificationService::AllSources());
+ AppLoadObserver(Profile* profile,
Devlin 2014/06/17 16:28:31 nit: This could actually just be a BrowserContext.
limasdf 2014/06/17 18:25:43 Done.
+ base::Callback<void(const Extension*)> callback)
+ : callback_(callback), extension_registry_observer_(this) {
+ extension_registry_observer_.Add(ExtensionRegistry::Get(profile));
}
- virtual void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) OVERRIDE {
- EXPECT_EQ(chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, type);
- callback_.Run(content::Details<const Extension>(details).ptr());
+ virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
+ const Extension* extension) OVERRIDE {
Devlin 2014/06/17 16:28:31 nit: indentation is off
limasdf 2014/06/17 18:25:43 Done.
+ callback_.Run(extension);
}
private:
- content::NotificationRegistrar registrar_;
base::Callback<void(const Extension*)> callback_;
- DISALLOW_COPY_AND_ASSIGN(AppInstallObserver);
+ ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
+ extension_registry_observer_;
+ DISALLOW_COPY_AND_ASSIGN(AppLoadObserver);
};
void SetLastChooseEntryDirectory(const base::FilePath& choose_entry_directory,
@@ -197,10 +194,10 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
FileSystemChooseEntryFunction::
SkipPickerAndSelectSuggestedPathForTest();
{
- AppInstallObserver observer(
- base::Bind(SetLastChooseEntryDirectory,
- test_file.DirName(),
- ExtensionPrefs::Get(profile())));
+ AppLoadObserver observer(profile(),
limasdf 2014/06/17 18:25:43 I'm actually like to pass something like a browser
Devlin 2014/06/18 16:04:34 Yeah, that's kind of annoying. What we could (and
limasdf 2014/06/19 01:48:42 one day I'll do it!
+ base::Bind(SetLastChooseEntryDirectory,
+ test_file.DirName(),
+ ExtensionPrefs::Get(profile())));
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_existing"))
<< message_;
}
@@ -216,11 +213,12 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
FileSystemChooseEntryFunction::
SkipPickerAndSelectSuggestedPathForTest();
{
- AppInstallObserver observer(base::Bind(
- SetLastChooseEntryDirectory,
- test_file.DirName().Append(
- base::FilePath::FromUTF8Unsafe("fake_directory_does_not_exist")),
- ExtensionPrefs::Get(profile())));
+ AppLoadObserver observer(
+ profile(),
+ base::Bind(SetLastChooseEntryDirectory,
+ test_file.DirName().Append(base::FilePath::FromUTF8Unsafe(
+ "fake_directory_does_not_exist")),
+ ExtensionPrefs::Get(profile())));
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_existing"))
<< message_;
}
@@ -608,11 +606,11 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiRestoreEntry) {
ASSERT_FALSE(test_file.empty());
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_file);
- AppInstallObserver observer(
- base::Bind(AddSavedEntry,
- test_file,
- false,
- apps::SavedFilesService::Get(profile())));
+ AppLoadObserver observer(profile(),
+ base::Bind(AddSavedEntry,
+ test_file,
+ false,
+ apps::SavedFilesService::Get(profile())));
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/restore_entry"))
<< message_;
}
@@ -623,11 +621,11 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiRestoreDirectoryEntry) {
base::FilePath test_directory = test_file.DirName();
FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
&test_file);
- AppInstallObserver observer(
- base::Bind(AddSavedEntry,
- test_directory,
- true,
- apps::SavedFilesService::Get(profile())));
+ AppLoadObserver observer(profile(),
+ base::Bind(AddSavedEntry,
+ test_directory,
+ true,
+ apps::SavedFilesService::Get(profile())));
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/restore_directory"))
<< message_;
}

Powered by Google App Engine
This is Rietveld 408576698