Home | History | Annotate | Download | only in webdata
      1 // Copyright (c) 2011 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 CHROME_BROWSER_WEBDATA_WEB_APPS_TABLE_H_
      6 #define CHROME_BROWSER_WEBDATA_WEB_APPS_TABLE_H_
      7 
      8 #include <vector>
      9 
     10 #include "base/compiler_specific.h"
     11 #include "components/webdata/common/web_database_table.h"
     12 
     13 class GURL;
     14 class SkBitmap;
     15 class WebDatabase;
     16 
     17 // This class manages the WebApps tables within the SQLite database passed to
     18 // the constructor. It expects the following schema:
     19 //
     20 // Note: The database stores time in seconds, UTC.
     21 //
     22 // web_apps
     23 //   url                 URL of the web app.
     24 //   has_all_images      Do we have all the images?
     25 //
     26 // web_app_icons
     27 //   url         URL of the web app.
     28 //   width       Width of the image.
     29 //   height      Height of the image.
     30 //   image       PNG encoded image data.
     31 //
     32 class WebAppsTable : public WebDatabaseTable {
     33  public:
     34   WebAppsTable() {}
     35   virtual ~WebAppsTable() {}
     36 
     37   // Retrieves the WebAppsTable* owned by |database|.
     38   static WebAppsTable* FromWebDatabase(WebDatabase* database);
     39 
     40   virtual WebDatabaseTable::TypeKey GetTypeKey() const OVERRIDE;
     41   virtual bool Init(sql::Connection* db, sql::MetaTable* meta_table) OVERRIDE;
     42   virtual bool IsSyncable() OVERRIDE;
     43   virtual bool MigrateToVersion(int version,
     44                                 bool* update_compatible_version) OVERRIDE;
     45 
     46   bool SetWebAppImage(const GURL& url, const SkBitmap& image);
     47 
     48   // Returns true if all images are retrieved. Returns false if there is a
     49   // database error. In this case, the state of images is undefined; it may have
     50   // partial results or no results from the call.
     51   bool GetWebAppImages(const GURL& url, std::vector<SkBitmap>* images);
     52 
     53   bool SetWebAppHasAllImages(const GURL& url, bool has_all_images);
     54   bool GetWebAppHasAllImages(const GURL& url);
     55 
     56   bool RemoveWebApp(const GURL& url);
     57 
     58  private:
     59   bool InitWebAppIconsTable();
     60   bool InitWebAppsTable();
     61 
     62   DISALLOW_COPY_AND_ASSIGN(WebAppsTable);
     63 };
     64 
     65 #endif  // CHROME_BROWSER_WEBDATA_WEB_APPS_TABLE_H_
     66