Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(644)

Unified Diff: chrome/browser/chromeos/extensions/wallpaper_manager_api.h

Issue 10754014: Wallpaper manager backend APIs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/extensions/wallpaper_manager_api.h
diff --git a/chrome/browser/chromeos/extensions/wallpaper_manager_api.h b/chrome/browser/chromeos/extensions/wallpaper_manager_api.h
index 8cda7af844fe20ffdd847d8999af84f43a771063..f36fa97f09c47657ecab57701ed9a414a8ab0196 100644
--- a/chrome/browser/chromeos/extensions/wallpaper_manager_api.h
+++ b/chrome/browser/chromeos/extensions/wallpaper_manager_api.h
@@ -8,6 +8,7 @@
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "base/time.h"
#include "chrome/browser/extensions/extension_function.h"
@@ -16,6 +17,31 @@
extern const char kWallpaperManagerDomain[];
+namespace {
+
+enum WallpaperErrorCode {
+ HTTP_SUCCESS = 200,
+ HTTP_CREATED = 201,
+ HTTP_FOUND = 302,
+ HTTP_NOT_MODIFIED = 304,
+ HTTP_RESUME_INCOMPLETE = 308,
+ HTTP_BAD_REQUEST = 400,
+ HTTP_UNAUTHORIZED = 401,
+ HTTP_FORBIDDEN = 403,
+ HTTP_NOT_FOUND = 404,
+ HTTP_CONFLICT = 409,
+ HTTP_LENGTH_REQUIRED = 411,
+ HTTP_PRECONDITION = 412,
+ HTTP_INTERNAL_SERVER_ERROR = 500,
+ HTTP_SERVICE_UNAVAILABLE = 503,
+ WALLPAPER_NO_CONNECTION = -100,
+ WALLPAPER_FILE_ERROR = -101,
+};
+
+const int64 kBytesWallpaperDownloadProgressReportInterval = 10240;
+
+} // namespace
+
namespace wallpaper_manager_util {
// Opens wallpaper manager application.
@@ -23,8 +49,58 @@ void OpenWallpaperManager();
} // namespace wallpaper_manager_util
+// Wallpaper manager strings.
+class WallpaperManagerStringsFunction : public SyncExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.wallpaperManager.getStrings");
+
+ protected:
+ virtual ~WallpaperManagerStringsFunction() {}
+
+ // SyncExtensionFunction overrides.
+ virtual bool RunImpl() OVERRIDE;
+};
+
+// Sets wallpaper to the image downloaded from URL.
+class WallpaperManagerSetWallpaperFunction : public AsyncExtensionFunction,
+ public net::URLFetcherDelegate {
+ public:
+ DECLARE_EXTENSION_FUNCTION_NAME("experimental.wallpaperManager.setWallpaper");
+
+ protected:
+ virtual ~WallpaperManagerSetWallpaperFunction();
+
+ // SyncExtensionFunction overrides.
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+
+ // URLFetcherDelegate overrides:
+ virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
+ virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source,
+ int64 current,
+ int64 total) OVERRIDE;
+
+ // Requests wallpaper from local file if cached.
+ void RequestOnFileThread(const std::string& source_url);
+
+ // Setups the url_fetcher on UI thread.
+ void SetupFetcherOnUIThread(const GURL& wallpaper_url);
+
+ // Returns wallpaper manager specific error code.
+ WallpaperErrorCode GetErrorCode(const net::URLFetcher* source) const;
+
+ // Dispatch DownloadErrorEvent to wallpaper manager extension.
+ void DispatchErrorEvent(WallpaperErrorCode code);
+
+ // Creates directory wallpaper will be downloaded to.
+ bool CreateDirectory(const FilePath& path);
+
+ FilePath wallpaper_dir_;
+ scoped_ptr<net::URLFetcher> fetcher_;
-// Wallpaper manager API functions. Followup CL will add implementations of
-// some API functions.
+ base::TimeTicks tick_wallpaper_download_start_;
+ int64 bytes_wallpaper_download_progress_last_reported_;
+};
#endif // CHROME_BROWSER_CHROMEOS_EXTENSIONS_WALLPAPER_MANAGER_API_H_

Powered by Google App Engine
This is Rietveld 408576698