OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_UI_WEBUI_COLLECTED_COOKIES_UI_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_COLLECTED_COOKIES_UI_DELEGATE_H_ |
6 #define CHROME_BROWSER_UI_WEBUI_COLLECTED_COOKIES_UI_DELEGATE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_COLLECTED_COOKIES_UI_DELEGATE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/ui/webui/cookies_tree_model_adapter.h" | 13 #include "chrome/browser/ui/webui/cookies_tree_model_adapter.h" |
14 #include "chrome/browser/ui/webui/html_dialog_ui.h" | 14 #include "chrome/browser/ui/webui/html_dialog_ui.h" |
15 #include "chrome/common/content_settings.h" | 15 #include "chrome/common/content_settings.h" |
16 #include "content/common/notification_observer.h" | 16 #include "content/common/notification_observer.h" |
17 #include "content/common/notification_registrar.h" | 17 #include "content/common/notification_registrar.h" |
18 | 18 |
19 class GURL; | 19 class GURL; |
20 class TabContents; | 20 class TabContents; |
| 21 class TabContentsWrapper; |
21 | 22 |
22 namespace gfx { | 23 namespace gfx { |
23 class Size; | 24 class Size; |
24 } | 25 } |
25 | 26 |
26 class CollectedCookiesUIDelegate : public HtmlDialogUIDelegate, | 27 class CollectedCookiesUIDelegate : public HtmlDialogUIDelegate, |
27 WebUIMessageHandler, | 28 WebUIMessageHandler, |
28 NotificationObserver { | 29 NotificationObserver { |
29 public: | 30 public: |
30 virtual ~CollectedCookiesUIDelegate(); | 31 virtual ~CollectedCookiesUIDelegate(); |
31 | 32 |
32 // static factory method that shows CollectedCookiesUI for |tab_contents|. | 33 // static factory method that shows CollectedCookiesUI for |tab_contents|. |
33 static void Show(TabContents* tab_contents); | 34 static void Show(TabContentsWrapper* wrapper); |
34 | 35 |
35 // HtmlDialogUIDelegate implementation: | 36 // HtmlDialogUIDelegate implementation: |
36 virtual bool IsDialogModal() const OVERRIDE; | 37 virtual bool IsDialogModal() const OVERRIDE; |
37 virtual string16 GetDialogTitle() const OVERRIDE; | 38 virtual string16 GetDialogTitle() const OVERRIDE; |
38 virtual GURL GetDialogContentURL() const OVERRIDE; | 39 virtual GURL GetDialogContentURL() const OVERRIDE; |
39 virtual void GetWebUIMessageHandlers( | 40 virtual void GetWebUIMessageHandlers( |
40 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; | 41 std::vector<WebUIMessageHandler*>* handlers) const OVERRIDE; |
41 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; | 42 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE; |
42 virtual std::string GetDialogArgs() const OVERRIDE; | 43 virtual std::string GetDialogArgs() const OVERRIDE; |
43 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; | 44 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE; |
44 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) | 45 virtual void OnCloseContents(TabContents* source, bool* out_close_dialog) |
45 OVERRIDE {} | 46 OVERRIDE {} |
46 virtual bool ShouldShowDialogTitle() const OVERRIDE; | 47 virtual bool ShouldShowDialogTitle() const OVERRIDE; |
47 | 48 |
48 // WebUIMessageHandler implementation: | 49 // WebUIMessageHandler implementation: |
49 virtual void RegisterMessages(); | 50 virtual void RegisterMessages(); |
50 | 51 |
51 private: | 52 private: |
52 explicit CollectedCookiesUIDelegate(TabContents* tab_contents); | 53 explicit CollectedCookiesUIDelegate(TabContentsWrapper* wrapper); |
53 | 54 |
54 // Closes the dialog from javascript. | 55 // Closes the dialog from javascript. |
55 void CloseDialog(); | 56 void CloseDialog(); |
56 | 57 |
57 // Sets infobar label text. | 58 // Sets infobar label text. |
58 void SetInfobarLabel(const std::string& text); | 59 void SetInfobarLabel(const std::string& text); |
59 | 60 |
60 // Add content exception. | 61 // Add content exception. |
61 void AddContentException(CookieTreeOriginNode* origin_node, | 62 void AddContentException(CookieTreeOriginNode* origin_node, |
62 ContentSetting setting); | 63 ContentSetting setting); |
63 | 64 |
64 // Notification Observer implementation. | 65 // Notification Observer implementation. |
65 virtual void Observe(int type, | 66 virtual void Observe(int type, |
66 const NotificationSource& source, | 67 const NotificationSource& source, |
67 const NotificationDetails& details); | 68 const NotificationDetails& details); |
68 | 69 |
69 // JS callback to bind cookies tree models with JS trees. | 70 // JS callback to bind cookies tree models with JS trees. |
70 void BindCookiesTreeModel(const base::ListValue* args); | 71 void BindCookiesTreeModel(const base::ListValue* args); |
71 | 72 |
72 // JS callback to block/allow cookies from given site. | 73 // JS callback to block/allow cookies from given site. |
73 void Block(const base::ListValue* args); | 74 void Block(const base::ListValue* args); |
74 void Allow(const base::ListValue* args); | 75 void Allow(const base::ListValue* args); |
75 void AllowThisSession(const base::ListValue* args); | 76 void AllowThisSession(const base::ListValue* args); |
76 | 77 |
77 NotificationRegistrar registrar_; | 78 NotificationRegistrar registrar_; |
78 TabContents* tab_contents_; | 79 TabContentsWrapper* wrapper_; |
79 bool closed_; | 80 bool closed_; |
80 | 81 |
81 scoped_ptr<CookiesTreeModel> allowed_cookies_tree_model_; | 82 scoped_ptr<CookiesTreeModel> allowed_cookies_tree_model_; |
82 scoped_ptr<CookiesTreeModel> blocked_cookies_tree_model_; | 83 scoped_ptr<CookiesTreeModel> blocked_cookies_tree_model_; |
83 | 84 |
84 CookiesTreeModelAdapter allowed_cookies_adapter_; | 85 CookiesTreeModelAdapter allowed_cookies_adapter_; |
85 CookiesTreeModelAdapter blocked_cookies_adapter_; | 86 CookiesTreeModelAdapter blocked_cookies_adapter_; |
86 | 87 |
87 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesUIDelegate); | 88 DISALLOW_COPY_AND_ASSIGN(CollectedCookiesUIDelegate); |
88 }; | 89 }; |
89 | 90 |
90 #endif // CHROME_BROWSER_UI_WEBUI_COLLECTED_COOKIES_UI_DELEGATE_H_ | 91 #endif // CHROME_BROWSER_UI_WEBUI_COLLECTED_COOKIES_UI_DELEGATE_H_ |
OLD | NEW |