1116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved. 2116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Use of this source code is governed by a BSD-style license that can be 3116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// found in the LICENSE file. 4116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 5116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_INSTALLER_H_ 6116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#define CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_INSTALLER_H_ 7116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 8116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/basictypes.h" 9116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/compiler_specific.h" 10116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/memory/weak_ptr.h" 11116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "content/public/browser/notification_observer.h" 12116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "content/public/browser/notification_registrar.h" 13116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 14116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass Profile; 15116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 16116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// A helper class to help mimic the timing of installs of synced extensions 17116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// from the app store. 18116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// 19116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Listens for attempts to contact the web store. When it detects such an 20116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// attempt (which will fail in tests), it posts a task to fake the installation 21116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// of synced extensions. 22116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// 23116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Also installs any pending synced extensions when this class is instantiated. 24116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// This is to avoid a potential races between the emitting of notifications and 25116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// the instantation of this class. 26116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass SyncedExtensionInstaller : public content::NotificationObserver { 27116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch public: 28116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch explicit SyncedExtensionInstaller(Profile* profile); 29116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual ~SyncedExtensionInstaller(); 30116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 31116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // content::NotificationObserver implementation. 32116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual void Observe(int type, 33116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const content::NotificationSource& source, 34116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const content::NotificationDetails& details) OVERRIDE; 35116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 36116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch private: 37116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void DoInstallSyncedExtensions(); 38116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 39116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch Profile* profile_; 40116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch content::NotificationRegistrar registrar_; 41116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch base::WeakPtrFactory<SyncedExtensionInstaller> weak_ptr_factory_; 43116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 44116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DISALLOW_COPY_AND_ASSIGN(SyncedExtensionInstaller); 45116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}; 46116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 47116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif // CHROME_BROWSER_SYNC_TEST_INTEGRATION_SYNC_EXTENSION_INSTALLER_H_ 48