1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_INSTALLER_H_
6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_INSTALLER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h"
11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h"
16 // A helper class to help mimic the timing of installs of synced extensions
17 // from the app store.
19 // Listens for attempts to contact the web store. When it detects such an
20 // attempt (which will fail in tests), it posts a task to fake the installation
21 // of synced extensions.
23 // Also installs any pending synced extensions when this class is instantiated.
24 // This is to avoid a potential races between the emitting of notifications and
25 // the instantation of this class.
26 class SyncedExtensionInstaller
: public content::NotificationObserver
{
28 explicit SyncedExtensionInstaller(Profile
* profile
);
29 ~SyncedExtensionInstaller() override
;
31 // content::NotificationObserver implementation.
32 void Observe(int type
,
33 const content::NotificationSource
& source
,
34 const content::NotificationDetails
& details
) override
;
37 void DoInstallSyncedExtensions();
40 content::NotificationRegistrar registrar_
;
42 base::WeakPtrFactory
<SyncedExtensionInstaller
> weak_ptr_factory_
;
44 DISALLOW_COPY_AND_ASSIGN(SyncedExtensionInstaller
);
47 #endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_INSTALLER_H_