1 // Copyright (c) 2012 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_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_DELEGATE_H_
6 #define CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_DELEGATE_H_
11 #include "base/time/time.h"
12 #include "chrome/browser/extensions/updater/manifest_fetch_data.h"
20 namespace extensions
{
22 class ExtensionDownloaderDelegate
{
24 virtual ~ExtensionDownloaderDelegate();
26 // Passed as an argument to ExtensionDownloader::OnExtensionDownloadFailed()
27 // to detail the reason for the failure.
29 // Background networking is disabled.
32 // Failed to fetch the manifest for this extension.
33 MANIFEST_FETCH_FAILED
,
35 // The manifest couldn't be parsed.
38 // The manifest was fetched and parsed, and there are no updates for
42 // There was an update for this extension but the download of the crx
47 // Passed as an argument to the completion callbacks to signal whether
48 // the extension update sent a ping.
53 // Whether a ping was sent.
56 // The start of day, from the server's perspective. This is only valid
57 // when |did_ping| is true.
61 // One of the following 3 methods is always invoked for a given extension
62 // id, if AddExtension() or AddPendingExtension() returned true when that
63 // extension was added to the ExtensionDownloader.
64 // To avoid duplicate work, ExtensionDownloader might merge multiple identical
65 // requests, so there is not necessarily a separate invocation of one of these
66 // methods for each call to AddExtension/AddPendingExtension. If it is
67 // important to be able to match up AddExtension calls with
68 // OnExtensionDownload callbacks, you need to make sure that for every call to
69 // AddExtension/AddPendingExtension the combination of extension id and
70 // request id is unique. The OnExtensionDownload related callbacks will then
71 // be called with all request ids that resulted in that extension being
74 // Invoked if the extension couldn't be downloaded. |error| contains the
76 virtual void OnExtensionDownloadFailed(const std::string
& id
,
78 const PingResult
& ping_result
,
79 const std::set
<int>& request_ids
);
81 // Invoked if the extension had an update available and its crx was
82 // successfully downloaded to |path|. Ownership of that file is transferred
84 virtual void OnExtensionDownloadFinished(
85 const std::string
& id
,
86 const base::FilePath
& path
,
87 const GURL
& download_url
,
88 const std::string
& version
,
89 const PingResult
& ping_result
,
90 const std::set
<int>& request_ids
) = 0;
92 // The remaining methods are used by the ExtensionDownloader to retrieve
93 // information about extensions from the delegate.
95 // Invoked to fill the PingData for the given extension id. Returns false
96 // if PingData should not be included for this extension's update check
97 // (this is the default).
98 virtual bool GetPingDataForExtension(const std::string
& id
,
99 ManifestFetchData::PingData
* ping
);
101 // Invoked to get the update url data for this extension's update url, if
102 // there is any. The default implementation returns an empty string.
103 virtual std::string
GetUpdateUrlData(const std::string
& id
);
105 // Invoked to determine whether extension |id| is currently
106 // pending installation.
107 virtual bool IsExtensionPending(const std::string
& id
) = 0;
109 // Invoked to get the current version of extension |id|. Returns false if
110 // that extension is not installed.
111 virtual bool GetExtensionExistingVersion(const std::string
& id
,
112 std::string
* version
) = 0;
115 } // namespace extensions
117 #endif // CHROME_BROWSER_EXTENSIONS_UPDATER_EXTENSION_DOWNLOADER_DELEGATE_H_