blob: 9d08d1a51ea787c3d9621fba832282c100d924b9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// Copyright 2014 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/sync/test/integration/sync_extension_installer.h"
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/sync/test/integration/sync_extension_helper.h"
#include "content/public/browser/notification_source.h"
SyncedExtensionInstaller::SyncedExtensionInstaller(Profile* profile)
: profile_(profile),
weak_ptr_factory_(this) {
DoInstallSyncedExtensions();
registrar_.Add(this,
extensions::NOTIFICATION_EXTENSION_UPDATING_STARTED,
content::Source<Profile>(profile_));
}
SyncedExtensionInstaller::~SyncedExtensionInstaller() {
}
void SyncedExtensionInstaller::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_UPDATING_STARTED, type);
// The extension system is trying to check for updates. In the real world,
// this would be where synced extensions are asynchronously downloaded from
// the web store and installed. In this test framework, we use this event as
// a signal that it's time to asynchronously fake the installation of these
// extensions.
base::MessageLoop::current()->PostTask(
FROM_HERE,
base::Bind(&SyncedExtensionInstaller::DoInstallSyncedExtensions,
weak_ptr_factory_.GetWeakPtr()));
}
void SyncedExtensionInstaller::DoInstallSyncedExtensions() {
SyncExtensionHelper::GetInstance()->InstallExtensionsPendingForSync(profile_);
}
|