OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_API_DELEGATE_H |
| 6 #define EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_API_DELEGATE_H |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/version.h" |
| 10 #include "extensions/common/api/runtime.h" |
| 11 |
| 12 class GURL; |
| 13 |
| 14 namespace extensions { |
| 15 |
| 16 class Extension; |
| 17 class UpdateObserver; |
| 18 |
| 19 // This is a delegate interface for chrome.runtime API behavior. Clients must |
| 20 // vend some implementation of this interface through |
| 21 // ExtensionsBrowserClient::CreateRuntimeAPIDelegate. |
| 22 class RuntimeAPIDelegate { |
| 23 public: |
| 24 struct UpdateCheckResult { |
| 25 bool success; |
| 26 std::string response; |
| 27 std::string version; |
| 28 |
| 29 UpdateCheckResult(bool success, |
| 30 const std::string& response, |
| 31 const std::string& version); |
| 32 }; |
| 33 |
| 34 // The callback given to RequestUpdateCheck. |
| 35 typedef base::Callback<void(const UpdateCheckResult&)> UpdateCheckCallback; |
| 36 |
| 37 // Registers an UpdateObserver on behalf of the runtime API. |
| 38 virtual void AddUpdateObserver(UpdateObserver* observer) = 0; |
| 39 |
| 40 // Unregisters an UpdateObserver on behalf of the runtime API. |
| 41 virtual void RemoveUpdateObserver(UpdateObserver* observer) = 0; |
| 42 |
| 43 // Determines an extension's previously installed version if applicable. |
| 44 virtual base::Version GetPreviousExtensionVersion( |
| 45 const Extension* extension) = 0; |
| 46 |
| 47 // Reloads an extension. |
| 48 virtual void ReloadExtension(const std::string& extension_id) = 0; |
| 49 |
| 50 // Requests an extensions update update check. Returns |false| if updates |
| 51 // are disabled. Otherwise |callback| is called with the result of the |
| 52 // update check. |
| 53 virtual bool CheckForUpdates(const std::string& extension_id, |
| 54 const UpdateCheckCallback& callback) = 0; |
| 55 |
| 56 // Navigates the browser to a URL on behalf of the runtime API. |
| 57 virtual void OpenURL(const GURL& uninstall_url) = 0; |
| 58 |
| 59 // Populates platform info to be provided by the getPlatformInfo function. |
| 60 // Returns false iff no info is provided. |
| 61 virtual bool GetPlatformInfo( |
| 62 core_api::runtime::GetPlatformInfo::Results::PlatformInfo* info) = 0; |
| 63 |
| 64 // Request a restart of the host device. Returns false iff the device |
| 65 // will not be restarted. |
| 66 virtual bool RestartDevice(std::string* error_message) = 0; |
| 67 }; |
| 68 |
| 69 } // namespace extensions |
| 70 |
| 71 #endif // EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_API_DELEGATE_H |
OLD | NEW |