| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 // Chromium settings and storage represent user-selected preferences and | |
| 6 // information and MUST not be extracted, overwritten or modified except | |
| 7 // through Chromium defined APIs. | |
| 8 | |
| 9 #ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ | |
| 10 #define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ | |
| 11 | |
| 12 #include <vector> | |
| 13 | |
| 14 #include "base/memory/ref_counted.h" | |
| 15 #include "base/sequenced_task_runner_helpers.h" | |
| 16 #include "components/webdata/common/web_data_results.h" | |
| 17 #include "components/webdata/common/web_data_service_base.h" | |
| 18 #include "components/webdata/common/web_data_service_consumer.h" | |
| 19 #include "components/webdata/common/web_database.h" | |
| 20 | |
| 21 struct DefaultWebIntentService; | |
| 22 class GURL; | |
| 23 #if defined(OS_WIN) | |
| 24 struct IE7PasswordInfo; | |
| 25 #endif | |
| 26 class Profile; | |
| 27 class SkBitmap; | |
| 28 class WebDatabaseService; | |
| 29 | |
| 30 namespace base { | |
| 31 class Thread; | |
| 32 } | |
| 33 | |
| 34 namespace content { | |
| 35 class BrowserContext; | |
| 36 } | |
| 37 | |
| 38 namespace webkit_glue { | |
| 39 struct WebIntentServiceData; | |
| 40 } | |
| 41 | |
| 42 //////////////////////////////////////////////////////////////////////////////// | |
| 43 // | |
| 44 // WebDataService is a generic data repository for meta data associated with | |
| 45 // web pages. All data is retrieved and archived in an asynchronous way. | |
| 46 // | |
| 47 // All requests return a handle. The handle can be used to cancel the request. | |
| 48 // | |
| 49 //////////////////////////////////////////////////////////////////////////////// | |
| 50 | |
| 51 | |
| 52 //////////////////////////////////////////////////////////////////////////////// | |
| 53 // | |
| 54 // WebDataService results | |
| 55 // | |
| 56 //////////////////////////////////////////////////////////////////////////////// | |
| 57 | |
| 58 // Result from GetWebAppImages. | |
| 59 struct WDAppImagesResult { | |
| 60 WDAppImagesResult(); | |
| 61 ~WDAppImagesResult(); | |
| 62 | |
| 63 // True if SetWebAppHasAllImages(true) was invoked. | |
| 64 bool has_all_images; | |
| 65 | |
| 66 // The images, may be empty. | |
| 67 std::vector<SkBitmap> images; | |
| 68 }; | |
| 69 | |
| 70 class WebDataServiceConsumer; | |
| 71 | |
| 72 class WebDataService : public WebDataServiceBase { | |
| 73 public: | |
| 74 // Retrieve a WebDataService for the given context. | |
| 75 static scoped_refptr<WebDataService> FromBrowserContext( | |
| 76 content::BrowserContext* context); | |
| 77 | |
| 78 WebDataService(scoped_refptr<WebDatabaseService> wdbs, | |
| 79 const ProfileErrorCallback& callback); | |
| 80 | |
| 81 ////////////////////////////////////////////////////////////////////////////// | |
| 82 // | |
| 83 // Web Apps | |
| 84 // | |
| 85 ////////////////////////////////////////////////////////////////////////////// | |
| 86 | |
| 87 // Sets the image for the specified web app. A web app can have any number of | |
| 88 // images, but only one at a particular size. If there was an image for the | |
| 89 // web app at the size of the given image it is replaced. | |
| 90 void SetWebAppImage(const GURL& app_url, const SkBitmap& image); | |
| 91 | |
| 92 // Sets whether all the images have been downloaded for the specified web app. | |
| 93 void SetWebAppHasAllImages(const GURL& app_url, bool has_all_images); | |
| 94 | |
| 95 // Removes all images for the specified web app. | |
| 96 void RemoveWebApp(const GURL& app_url); | |
| 97 | |
| 98 // Fetches the images and whether all images have been downloaded for the | |
| 99 // specified web app. | |
| 100 Handle GetWebAppImages(const GURL& app_url, WebDataServiceConsumer* consumer); | |
| 101 | |
| 102 #if defined(OS_WIN) | |
| 103 ////////////////////////////////////////////////////////////////////////////// | |
| 104 // | |
| 105 // IE7/8 Password Access (used by PasswordStoreWin - do not use elsewhere) | |
| 106 // | |
| 107 ////////////////////////////////////////////////////////////////////////////// | |
| 108 | |
| 109 // Adds |info| to the list of imported passwords from ie7/ie8. | |
| 110 void AddIE7Login(const IE7PasswordInfo& info); | |
| 111 | |
| 112 // Removes |info| from the list of imported passwords from ie7/ie8. | |
| 113 void RemoveIE7Login(const IE7PasswordInfo& info); | |
| 114 | |
| 115 // Get the login matching the information in |info|. |consumer| will be | |
| 116 // notified when the request is done. The result is of type | |
| 117 // WDResult<IE7PasswordInfo>. | |
| 118 // If there is no match, the fields of the IE7PasswordInfo will be empty. | |
| 119 Handle GetIE7Login(const IE7PasswordInfo& info, | |
| 120 WebDataServiceConsumer* consumer); | |
| 121 #endif // defined(OS_WIN) | |
| 122 | |
| 123 protected: | |
| 124 // For unit tests, passes a null callback. | |
| 125 WebDataService(); | |
| 126 | |
| 127 virtual ~WebDataService(); | |
| 128 | |
| 129 private: | |
| 130 ////////////////////////////////////////////////////////////////////////////// | |
| 131 // | |
| 132 // The following methods are only invoked on the DB thread. | |
| 133 // | |
| 134 ////////////////////////////////////////////////////////////////////////////// | |
| 135 | |
| 136 ////////////////////////////////////////////////////////////////////////////// | |
| 137 // | |
| 138 // Web Apps. | |
| 139 // | |
| 140 ////////////////////////////////////////////////////////////////////////////// | |
| 141 | |
| 142 WebDatabase::State SetWebAppImageImpl(const GURL& app_url, | |
| 143 const SkBitmap& image, WebDatabase* db); | |
| 144 WebDatabase::State SetWebAppHasAllImagesImpl(const GURL& app_url, | |
| 145 bool has_all_images, WebDatabase* db); | |
| 146 WebDatabase::State RemoveWebAppImpl(const GURL& app_url, WebDatabase* db); | |
| 147 scoped_ptr<WDTypedResult> GetWebAppImagesImpl( | |
| 148 const GURL& app_url, WebDatabase* db); | |
| 149 | |
| 150 #if defined(ENABLE_WEB_INTENTS) | |
| 151 ////////////////////////////////////////////////////////////////////////////// | |
| 152 // | |
| 153 // Web Intents. | |
| 154 // | |
| 155 ////////////////////////////////////////////////////////////////////////////// | |
| 156 WebDatabase::State AddWebIntentServiceImpl( | |
| 157 const webkit_glue::WebIntentServiceData& service); | |
| 158 WebDatabase::State RemoveWebIntentServiceImpl( | |
| 159 const webkit_glue::WebIntentServiceData& service); | |
| 160 scoped_ptr<WDTypedResult> GetWebIntentServicesImpl( | |
| 161 const base::string16& action); | |
| 162 scoped_ptr<WDTypedResult> GetWebIntentServicesForURLImpl( | |
| 163 const base::string16& service_url); | |
| 164 scoped_ptr<WDTypedResult> GetAllWebIntentServicesImpl(); | |
| 165 WebDatabase::State AddDefaultWebIntentServiceImpl( | |
| 166 const DefaultWebIntentService& service); | |
| 167 WebDatabase::State RemoveDefaultWebIntentServiceImpl( | |
| 168 const DefaultWebIntentService& service); | |
| 169 WebDatabase::State RemoveWebIntentServiceDefaultsImpl( | |
| 170 const GURL& service_url); | |
| 171 scoped_ptr<WDTypedResult> GetDefaultWebIntentServicesForActionImpl( | |
| 172 const base::string16& action); | |
| 173 scoped_ptr<WDTypedResult> GetAllDefaultWebIntentServicesImpl(); | |
| 174 #endif | |
| 175 | |
| 176 #if defined(OS_WIN) | |
| 177 ////////////////////////////////////////////////////////////////////////////// | |
| 178 // | |
| 179 // Password manager. | |
| 180 // | |
| 181 ////////////////////////////////////////////////////////////////////////////// | |
| 182 WebDatabase::State AddIE7LoginImpl( | |
| 183 const IE7PasswordInfo& info, WebDatabase* db); | |
| 184 WebDatabase::State RemoveIE7LoginImpl( | |
| 185 const IE7PasswordInfo& info, WebDatabase* db); | |
| 186 scoped_ptr<WDTypedResult> GetIE7LoginImpl( | |
| 187 const IE7PasswordInfo& info, WebDatabase* db); | |
| 188 #endif // defined(OS_WIN) | |
| 189 | |
| 190 DISALLOW_COPY_AND_ASSIGN(WebDataService); | |
| 191 }; | |
| 192 | |
| 193 #endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__ | |
| OLD | NEW |