Add ICU message format support
[chromium-blink-merge.git] / extensions / browser / api / runtime / runtime_api_delegate.h
blob21e9a6e271c92ac7ff601d66be9af8fef3bee8bc
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 EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_API_DELEGATE_H
6 #define EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_API_DELEGATE_H
8 #include "base/callback.h"
9 #include "base/version.h"
11 class GURL;
13 namespace extensions {
15 namespace api {
16 namespace runtime {
17 struct PlatformInfo;
21 class Extension;
22 class UpdateObserver;
24 // This is a delegate interface for chrome.runtime API behavior. Clients must
25 // vend some implementation of this interface through
26 // ExtensionsBrowserClient::CreateRuntimeAPIDelegate.
27 class RuntimeAPIDelegate {
28 public:
29 struct UpdateCheckResult {
30 bool success;
31 std::string response;
32 std::string version;
34 UpdateCheckResult(bool success,
35 const std::string& response,
36 const std::string& version);
39 virtual ~RuntimeAPIDelegate() {}
41 // The callback given to RequestUpdateCheck.
42 typedef base::Callback<void(const UpdateCheckResult&)> UpdateCheckCallback;
44 // Registers an UpdateObserver on behalf of the runtime API.
45 virtual void AddUpdateObserver(UpdateObserver* observer) = 0;
47 // Unregisters an UpdateObserver on behalf of the runtime API.
48 virtual void RemoveUpdateObserver(UpdateObserver* observer) = 0;
50 // Determines an extension's previously installed version if applicable.
51 virtual base::Version GetPreviousExtensionVersion(
52 const Extension* extension) = 0;
54 // Reloads an extension.
55 virtual void ReloadExtension(const std::string& extension_id) = 0;
57 // Requests an extensions update update check. Returns |false| if updates
58 // are disabled. Otherwise |callback| is called with the result of the
59 // update check.
60 virtual bool CheckForUpdates(const std::string& extension_id,
61 const UpdateCheckCallback& callback) = 0;
63 // Navigates the browser to a URL on behalf of the runtime API.
64 virtual void OpenURL(const GURL& uninstall_url) = 0;
66 // Populates platform info to be provided by the getPlatformInfo function.
67 // Returns false iff no info is provided.
68 virtual bool GetPlatformInfo(api::runtime::PlatformInfo* info) = 0;
70 // Request a restart of the host device. Returns false iff the device
71 // will not be restarted.
72 virtual bool RestartDevice(std::string* error_message) = 0;
74 // Open |extension|'s options page, if it has one. Returns true if an
75 // options page was opened, false otherwise. See the docs of the
76 // chrome.runtime.openOptionsPage function for the gritty details.
77 virtual bool OpenOptionsPage(const Extension* extension);
80 } // namespace extensions
82 #endif // EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_API_DELEGATE_H