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