summaryrefslogtreecommitdiff
path: root/chromium/extensions/browser/uninstall_ping_sender.cc
blob: 865c01cd1d60b75b800d5c9f4c885b9ea0e161a2 (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
// Copyright 2016 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 "extensions/browser/uninstall_ping_sender.h"

#include "base/version.h"
#include "extensions/browser/updater/update_service.h"

namespace extensions {

UninstallPingSender::UninstallPingSender(ExtensionRegistry* registry,
                                         const Filter& filter)
    : filter_(filter) {
  observer_.Add(registry);
}

UninstallPingSender::~UninstallPingSender() {}

void UninstallPingSender::OnExtensionUninstalled(
    content::BrowserContext* browser_context,
    const Extension* extension,
    UninstallReason reason) {
  if (filter_.Run(extension, reason) == SEND_PING) {
    UpdateService* updater = UpdateService::Get(browser_context);
    updater->SendUninstallPing(extension->id(), extension->version(), reason);
  }
}

}  // namespace extensions