| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_PERMISSION_REQUEST_H_ | 5 #ifndef CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_PERMISSION_REQUEST_H_ |
| 6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_PERMISSION_REQUEST_H_ | 6 #define CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_PERMISSION_REQUEST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/ref_counted.h" | 10 #include "base/ref_counted.h" |
| 11 #include "base/time.h" | 11 #include "base/time.h" |
| 12 #include "base/waitable_event.h" | 12 #include "base/waitable_event.h" |
| 13 #include "chrome/browser/host_content_settings_map.h" | 13 #include "chrome/browser/host_content_settings_map.h" |
| 14 #include "chrome/browser/cookie_prompt_modal_dialog_delegate.h" | 14 #include "chrome/browser/cookie_prompt_modal_dialog_delegate.h" |
| 15 #include "chrome/common/content_settings.h" | 15 #include "chrome/common/content_settings.h" |
| 16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
| 17 | 17 |
| 18 // This class is used to request content setting related permission for local | 18 // This class is used to request content setting related permission for local |
| 19 // storage. It should only be used for one such event and then discarded. | 19 // storage. It should only be used for one such event and then discarded. |
| 20 class DOMStoragePermissionRequest : public CookiePromptModalDialogDelegate { | 20 class DOMStoragePermissionRequest : public CookiePromptModalDialogDelegate { |
| 21 public: | 21 public: |
| 22 DOMStoragePermissionRequest(const GURL& url, | 22 DOMStoragePermissionRequest(const GURL& url, |
| 23 bool file_exists, | 23 const string16& key, |
| 24 int64 size, | 24 const string16& value, |
| 25 base::Time last_modified, | |
| 26 HostContentSettingsMap* settings); | 25 HostContentSettingsMap* settings); |
| 27 | 26 |
| 28 | 27 |
| 29 ContentSetting WaitOnResponse(); | 28 ContentSetting WaitOnResponse(); |
| 30 void SendResponse(ContentSetting content_setting, bool remember); | 29 void SendResponse(ContentSetting content_setting, bool remember); |
| 31 | 30 |
| 32 const GURL& url() const { return url_; } | 31 const GURL& url() const { return url_; } |
| 33 bool file_exists() const { return file_exists_; } | 32 const string16& key() const { return key_; } |
| 34 int64 size() const { return size_; } | 33 const string16& value() const { return value_; } |
| 35 const base::Time last_modified() const { return last_modified_; } | |
| 36 | 34 |
| 37 // Called on the UI thread. | 35 // Called on the UI thread. |
| 38 static void PromptUser(DOMStoragePermissionRequest* request); | 36 static void PromptUser(DOMStoragePermissionRequest* request); |
| 39 | 37 |
| 40 // CookiesPromptViewDelegate methods: | 38 // CookiesPromptViewDelegate methods: |
| 41 virtual void AllowSiteData(bool remember, bool session_expire); | 39 virtual void AllowSiteData(bool remember, bool session_expire); |
| 42 virtual void BlockSiteData(bool remember); | 40 virtual void BlockSiteData(bool remember); |
| 43 | 41 |
| 44 private: | 42 private: |
| 45 // The URL we need to get permission for. | 43 // The URL we need to get permission for. |
| 46 const GURL url_; | 44 const GURL url_; |
| 47 | 45 |
| 48 // Is there any information on disk currently? | 46 // The key we're trying to set. |
| 49 bool file_exists_; | 47 const string16 key_; |
| 50 | 48 |
| 51 // If file_exists_, what's the size? | 49 // The value we're trying to set. |
| 52 int64 size_; | 50 const string16 value_; |
| 53 | |
| 54 // If file_exists_, what's the size? | |
| 55 const base::Time last_modified_; | |
| 56 | 51 |
| 57 // The response to the permission request. | 52 // The response to the permission request. |
| 58 ContentSetting response_content_setting_; | 53 ContentSetting response_content_setting_; |
| 59 | 54 |
| 60 // One time use. Never reset. | 55 // One time use. Never reset. |
| 61 base::WaitableEvent event_; | 56 base::WaitableEvent event_; |
| 62 | 57 |
| 63 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | 58 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
| 64 | 59 |
| 65 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStoragePermissionRequest); | 60 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStoragePermissionRequest); |
| 66 }; | 61 }; |
| 67 | 62 |
| 68 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_PERMISSION_REQUEST_H_ | 63 #endif // CHROME_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_PERMISSION_REQUEST_H_ |
| OLD | NEW |