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_COOKIE_MODAL_DIALOG_H_ | 5 #ifndef CHROME_BROWSER_COOKIE_MODAL_DIALOG_H_ |
6 #define CHROME_BROWSER_COOKIE_MODAL_DIALOG_H_ | 6 #define CHROME_BROWSER_COOKIE_MODAL_DIALOG_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #include "base/ref_counted.h" |
10 #include "chrome/browser/app_modal_dialog.h" | 11 #include "chrome/browser/app_modal_dialog.h" |
11 #include "chrome/browser/browsing_data_local_storage_helper.h" | 12 #include "chrome/browser/browsing_data_local_storage_helper.h" |
12 #include "chrome/browser/cookie_prompt_modal_dialog_delegate.h" | 13 #include "chrome/browser/cookie_prompt_modal_dialog_delegate.h" |
13 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
14 | 15 |
| 16 class HostContentSettingsMap; |
15 class PrefService; | 17 class PrefService; |
16 | 18 |
17 // A controller+model class for cookie and local storage warning prompt. | 19 // A controller+model class for cookie and local storage warning prompt. |
18 // |NativeDialog| is a platform specific view. | 20 // |NativeDialog| is a platform specific view. |
19 class CookiePromptModalDialog : public AppModalDialog { | 21 class CookiePromptModalDialog : public AppModalDialog { |
20 public: | 22 public: |
21 enum DialogType { | 23 enum DialogType { |
22 DIALOG_TYPE_COOKIE = 0, | 24 DIALOG_TYPE_COOKIE = 0, |
23 DIALOG_TYPE_LOCAL_STORAGE, | 25 DIALOG_TYPE_LOCAL_STORAGE, |
24 DIALOG_TYPE_DATABASE | 26 DIALOG_TYPE_DATABASE |
25 // TODO(michaeln): AppCache | 27 // TODO(michaeln): AppCache |
26 }; | 28 }; |
27 | 29 |
28 // A union of data necessary to determine the type of message box to | 30 // A union of data necessary to determine the type of message box to |
29 // show. | 31 // show. |
30 CookiePromptModalDialog(TabContents* tab_contents, | 32 CookiePromptModalDialog(TabContents* tab_contents, |
| 33 HostContentSettingsMap* host_content_settings_map, |
31 const GURL& origin, | 34 const GURL& origin, |
32 const std::string& cookie_line, | 35 const std::string& cookie_line, |
33 CookiePromptModalDialogDelegate* delegate); | 36 CookiePromptModalDialogDelegate* delegate); |
34 CookiePromptModalDialog(TabContents* tab_contents, | 37 CookiePromptModalDialog(TabContents* tab_contents, |
| 38 HostContentSettingsMap* host_content_settings_map, |
35 const GURL& origin, | 39 const GURL& origin, |
36 const string16& key, | 40 const string16& key, |
37 const string16& value, | 41 const string16& value, |
38 CookiePromptModalDialogDelegate* delegate); | 42 CookiePromptModalDialogDelegate* delegate); |
39 CookiePromptModalDialog(TabContents* tab_contents, | 43 CookiePromptModalDialog(TabContents* tab_contents, |
| 44 HostContentSettingsMap* host_content_settings_map, |
40 const GURL& origin, | 45 const GURL& origin, |
41 const string16& database_name, | 46 const string16& database_name, |
42 CookiePromptModalDialogDelegate* delegate); | 47 CookiePromptModalDialogDelegate* delegate); |
43 virtual ~CookiePromptModalDialog() {} | 48 virtual ~CookiePromptModalDialog(); |
44 | 49 |
45 static void RegisterPrefs(PrefService* prefs); | 50 static void RegisterPrefs(PrefService* prefs); |
46 | 51 |
47 // AppModalDialog overrides. | 52 // AppModalDialog overrides. |
48 virtual int GetDialogButtons(); | 53 virtual int GetDialogButtons(); |
49 virtual void AcceptWindow(); | 54 virtual void AcceptWindow(); |
50 virtual void CancelWindow(); | 55 virtual void CancelWindow(); |
51 virtual bool IsValid(); | 56 virtual bool IsValid(); |
52 | 57 |
53 DialogType dialog_type() const { return dialog_type_; } | 58 DialogType dialog_type() const { return dialog_type_; } |
54 const GURL& origin() const { return origin_; } | 59 const GURL& origin() const { return origin_; } |
55 const std::string& cookie_line() const { return cookie_line_; } | 60 const std::string& cookie_line() const { return cookie_line_; } |
56 const string16& local_storage_key() const { return local_storage_key_; } | 61 const string16& local_storage_key() const { return local_storage_key_; } |
57 const string16& local_storage_value() const { return local_storage_value_; } | 62 const string16& local_storage_value() const { return local_storage_value_; } |
58 const string16& database_name() const { return database_name_; } | 63 const string16& database_name() const { return database_name_; } |
59 TabContents* tab_contents() const { return tab_contents_; } | 64 TabContents* tab_contents() const { return tab_contents_; } |
60 | 65 |
61 // Implement CookiePromptModalDialogDelegate. | 66 // Implement CookiePromptModalDialogDelegate. |
62 void AllowSiteData(bool remember, bool session_expire); | 67 void AllowSiteData(bool remember, bool session_expire); |
63 void BlockSiteData(bool remember); | 68 void BlockSiteData(bool remember); |
64 | 69 |
65 protected: | 70 protected: |
66 // AppModalDialog overrides. | 71 // AppModalDialog overrides. |
67 virtual NativeDialog CreateNativeDialog(); | 72 virtual NativeDialog CreateNativeDialog(); |
68 #if defined(OS_LINUX) | 73 #if defined(OS_LINUX) |
69 virtual void HandleDialogResponse(GtkDialog* dialog, gint response_id); | 74 virtual void HandleDialogResponse(GtkDialog* dialog, gint response_id); |
70 #endif | 75 #endif |
71 | 76 |
72 private: | 77 private: |
| 78 // Used to verify our request is still necessary and when the response should |
| 79 // persist. |
| 80 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; |
| 81 |
73 const DialogType dialog_type_; | 82 const DialogType dialog_type_; |
74 | 83 |
75 // The origin connected to this request. | 84 // The origin connected to this request. |
76 GURL origin_; | 85 GURL origin_; |
77 | 86 |
78 // Cookie to display. | 87 // Cookie to display. |
79 const std::string cookie_line_; | 88 const std::string cookie_line_; |
80 | 89 |
81 // LocalStorage key/value. | 90 // LocalStorage key/value. |
82 const string16 local_storage_key_; | 91 const string16 local_storage_key_; |
83 const string16 local_storage_value_; | 92 const string16 local_storage_value_; |
84 | 93 |
85 // Database name. | 94 // Database name. |
86 const string16 database_name_; | 95 const string16 database_name_; |
87 | 96 |
88 // Delegate. The caller should provide one in order to receive results | 97 // Delegate. The caller should provide one in order to receive results |
89 // from this delegate. Any time after calling one of these methods, the | 98 // from this delegate. Any time after calling one of these methods, the |
90 // delegate could be deleted | 99 // delegate could be deleted |
91 CookiePromptModalDialogDelegate* delegate_; | 100 CookiePromptModalDialogDelegate* delegate_; |
92 | 101 |
93 DISALLOW_COPY_AND_ASSIGN(CookiePromptModalDialog); | 102 DISALLOW_COPY_AND_ASSIGN(CookiePromptModalDialog); |
94 }; | 103 }; |
95 | 104 |
96 #endif // CHROME_BROWSER_COOKIE_MODAL_DIALOG_H_ | 105 #endif // CHROME_BROWSER_COOKIE_MODAL_DIALOG_H_ |
97 | 106 |
OLD | NEW |