1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_COOKIE_MODAL_DIALOG_H_
#define CHROME_BROWSER_COOKIE_MODAL_DIALOG_H_
#include <string>
#include "base/ref_counted.h"
#include "chrome/browser/app_modal_dialog.h"
#include "chrome/browser/browsing_data_local_storage_helper.h"
#include "chrome/browser/cookie_prompt_modal_dialog_delegate.h"
#include "googleurl/src/gurl.h"
#if defined(OS_LINUX)
#include "app/gtk_signal.h"
#endif
#if defined(OS_MACOSX)
#if __OBJC__
@class NSWindow;
#else
class NSWindow;
#endif
#endif
class HostContentSettingsMap;
class PrefService;
#if defined(OS_LINUX)
typedef struct _GtkWidget GtkWidget;
typedef struct _GParamSpec GParamSpec;
#endif
// A controller+model class for cookie and local storage warning prompt.
// |NativeDialog| is a platform specific view.
class CookiePromptModalDialog : public AppModalDialog {
public:
enum DialogType {
DIALOG_TYPE_COOKIE = 0,
DIALOG_TYPE_LOCAL_STORAGE,
DIALOG_TYPE_DATABASE,
DIALOG_TYPE_APPCACHE
};
// A union of data necessary to determine the type of message box to
// show.
CookiePromptModalDialog(TabContents* tab_contents,
HostContentSettingsMap* host_content_settings_map,
const GURL& origin,
const std::string& cookie_line,
CookiePromptModalDialogDelegate* delegate);
CookiePromptModalDialog(TabContents* tab_contents,
HostContentSettingsMap* host_content_settings_map,
const GURL& origin,
const string16& key,
const string16& value,
CookiePromptModalDialogDelegate* delegate);
CookiePromptModalDialog(TabContents* tab_contents,
HostContentSettingsMap* host_content_settings_map,
const GURL& origin,
const string16& database_name,
const string16& display_name,
unsigned long estimated_size,
CookiePromptModalDialogDelegate* delegate);
CookiePromptModalDialog(TabContents* tab_contents,
HostContentSettingsMap* host_content_settings_map,
const GURL& appcache_manifest_url,
CookiePromptModalDialogDelegate* delegate);
virtual ~CookiePromptModalDialog();
static void RegisterUserPrefs(PrefService* prefs);
// AppModalDialog overrides.
#if defined(OS_LINUX) || defined(OS_MACOSX)
virtual void CreateAndShowDialog();
#endif
virtual int GetDialogButtons();
virtual void AcceptWindow();
virtual void CancelWindow();
virtual bool IsValid();
#if defined(OS_MACOSX)
virtual void CloseModalDialog();
#endif
DialogType dialog_type() const { return dialog_type_; }
const GURL& origin() const { return origin_; }
const std::string& cookie_line() const { return cookie_line_; }
const string16& local_storage_key() const { return local_storage_key_; }
const string16& local_storage_value() const { return local_storage_value_; }
const string16& database_name() const { return database_name_; }
const string16& display_name() const { return display_name_; }
unsigned long estimated_size() const { return estimated_size_; }
const GURL& appcache_manifest_url() const { return appcache_manifest_url_; }
TabContents* tab_contents() const { return tab_contents_; }
// Implement CookiePromptModalDialogDelegate.
virtual void AllowSiteData(bool remember, bool session_expire);
virtual void BlockSiteData(bool remember);
protected:
// AppModalDialog overrides.
virtual NativeDialog CreateNativeDialog();
#if defined(OS_LINUX)
virtual void HandleDialogResponse(GtkDialog* dialog, gint response_id);
CHROMEGTK_CALLBACK_1(CookiePromptModalDialog,
void,
OnExpanderActivate,
GParamSpec*);
#endif
private:
#if defined(OS_MACOSX)
NSWindow* dialog_;
#endif
// Used to verify our request is still necessary and when the response should
// persist.
scoped_refptr<HostContentSettingsMap> host_content_settings_map_;
const DialogType dialog_type_;
// The origin connected to this request.
const GURL origin_;
// Which data members are relevant depends on the dialog_type.
const std::string cookie_line_;
const string16 local_storage_key_;
const string16 local_storage_value_;
const string16 database_name_;
const string16 display_name_;
unsigned long estimated_size_;
const GURL appcache_manifest_url_;
// The caller should provide a delegate in order to receive results
// from this delegate. Any time after calling one of these methods, the
// delegate could be deleted
CookiePromptModalDialogDelegate* delegate_;
#if defined(OS_LINUX)
// The "remember this choice" radio button in the dialog.
GtkWidget* remember_radio_;
// The cookie view; we keep this to querry the result combobox.
GtkWidget* cookie_view_;
#endif
DISALLOW_COPY_AND_ASSIGN(CookiePromptModalDialog);
};
#endif // CHROME_BROWSER_COOKIE_MODAL_DIALOG_H_
|