| 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_VIEWS_COOKIE_PROMPT_VIEW_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_COOKIE_PROMPT_VIEW_H_ |
| 6 #define CHROME_BROWSER_VIEWS_COOKIE_PROMPT_VIEW_H_ | 6 #define CHROME_BROWSER_VIEWS_COOKIE_PROMPT_VIEW_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/task.h" | 10 #include "base/task.h" |
| 11 #include "chrome/browser/browsing_data_local_storage_helper.h" | 11 #include "chrome/browser/browsing_data_local_storage_helper.h" |
| 12 #include "chrome/browser/cookie_prompt_modal_dialog_delegate.h" |
| 12 #include "chrome/browser/views/cookie_info_view.h" | 13 #include "chrome/browser/views/cookie_info_view.h" |
| 13 #include "net/base/cookie_monster.h" | 14 #include "chrome/browser/views/modal_dialog_delegate.h" |
| 15 #include "googleurl/src/gurl.h" |
| 14 #include "views/controls/button/button.h" | 16 #include "views/controls/button/button.h" |
| 15 #include "views/controls/link.h" | 17 #include "views/controls/link.h" |
| 16 #include "views/view.h" | 18 #include "views/view.h" |
| 17 #include "views/window/dialog_delegate.h" | 19 #include "views/window/dialog_delegate.h" |
| 18 #include "views/window/window.h" | 20 #include "views/window/window.h" |
| 19 | 21 |
| 20 namespace views { | 22 namespace views { |
| 21 class NativeButton; | 23 class NativeButton; |
| 22 class RadioButton; | 24 class RadioButton; |
| 23 } | 25 } |
| 24 | 26 |
| 25 class CookieInfoView; | 27 class CookieInfoView; |
| 28 class CookiePromptModalDialog; |
| 26 class LocalStorageInfoView; | 29 class LocalStorageInfoView; |
| 27 class Profile; | 30 class Profile; |
| 28 class Timer; | 31 class Timer; |
| 29 | 32 |
| 30 class CookiesPromptViewDelegate { | |
| 31 public: | |
| 32 // Allow site data to be set. If |remember| is true, record this decision | |
| 33 // for this host. | |
| 34 virtual void AllowSiteData(bool remember, bool session_expire) = 0; | |
| 35 | |
| 36 // Block site data from being stored. If |remember| is true, record this | |
| 37 // decision for this host. | |
| 38 virtual void BlockSiteData(bool remember) = 0; | |
| 39 | |
| 40 protected: | |
| 41 virtual ~CookiesPromptViewDelegate() {} | |
| 42 }; | |
| 43 | |
| 44 // Cookie alert dialog UI. | 33 // Cookie alert dialog UI. |
| 45 class CookiesPromptView : public views::View, | 34 class CookiePromptView : public views::View, |
| 46 public views::DialogDelegate, | 35 public ModalDialogDelegate, |
| 47 public views::ButtonListener, | 36 public views::ButtonListener, |
| 48 public views::LinkController, | 37 public views::LinkController, |
| 49 public CookieInfoViewDelegate { | 38 public CookieInfoViewDelegate { |
| 50 public: | 39 public: |
| 51 // Show the Cookies Window, creating one if necessary. | 40 // Show the Cookies Window, creating one if necessary. |
| 52 static void ShowCookiePromptWindow( | 41 CookiePromptView( |
| 53 gfx::NativeWindow parent, | 42 CookiePromptModalDialog* parent, |
| 43 gfx::NativeWindow root_window, |
| 54 Profile* profile, | 44 Profile* profile, |
| 55 const std::string& domain, | 45 const GURL& url, |
| 56 const net::CookieMonster::CanonicalCookie& cookie, | 46 const std::string& cookie_line, |
| 57 CookiesPromptViewDelegate* delegate); | 47 CookiePromptModalDialogDelegate* delegate); |
| 58 | 48 |
| 59 static void CookiesPromptView::ShowLocalStoragePromptWindow( | 49 CookiePromptView( |
| 60 gfx::NativeWindow parent, | 50 CookiePromptModalDialog* parent, |
| 51 gfx::NativeWindow root_window, |
| 61 Profile* profile, | 52 Profile* profile, |
| 62 const std::string& domain, | |
| 63 const BrowsingDataLocalStorageHelper::LocalStorageInfo& | 53 const BrowsingDataLocalStorageHelper::LocalStorageInfo& |
| 64 local_storage_info, | 54 local_storage_info, |
| 65 CookiesPromptViewDelegate* delegate); | 55 CookiePromptModalDialogDelegate* delegate); |
| 66 | 56 |
| 67 virtual ~CookiesPromptView(); | 57 virtual ~CookiePromptView(); |
| 68 | |
| 69 // Initializes component for displaying cookie information. | |
| 70 void SetCookie(const std::string& domain, | |
| 71 const net::CookieMonster::CanonicalCookie& cookie_node); | |
| 72 | |
| 73 // Initializes component for displaying locale storage information. | |
| 74 void SetLocalStorage(const std::string& domain, | |
| 75 const BrowsingDataLocalStorageHelper::LocalStorageInfo); | |
| 76 | 58 |
| 77 protected: | 59 protected: |
| 78 // views::View overrides. | 60 // views::View overrides. |
| 79 virtual gfx::Size GetPreferredSize(); | 61 virtual gfx::Size GetPreferredSize(); |
| 80 virtual void ViewHierarchyChanged(bool is_add, | 62 virtual void ViewHierarchyChanged(bool is_add, |
| 81 views::View* parent, | 63 views::View* parent, |
| 82 views::View* child); | 64 views::View* child); |
| 83 | 65 |
| 66 // ModalDialogDelegate overrides. |
| 67 virtual gfx::NativeWindow GetDialogRootWindow(); |
| 68 |
| 84 // views::DialogDelegate overrides. | 69 // views::DialogDelegate overrides. |
| 85 virtual bool CanResize() const { return false; } | 70 virtual bool CanResize() const { return false; } |
| 86 virtual std::wstring GetWindowTitle() const; | 71 virtual std::wstring GetWindowTitle() const; |
| 87 virtual void WindowClosing(); | 72 virtual void WindowClosing(); |
| 88 virtual views::View* GetContentsView(); | 73 virtual views::View* GetContentsView(); |
| 74 virtual bool IsModal() const { return true; } |
| 89 | 75 |
| 90 // views::ButtonListener overrides. | 76 // views::ButtonListener overrides. |
| 91 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | 77 virtual void ButtonPressed(views::Button* sender, const views::Event& event); |
| 92 | 78 |
| 93 // views::LinkController overrides. | 79 // views::LinkController overrides. |
| 94 virtual void LinkActivated(views::Link* source, int event_flags); | 80 virtual void LinkActivated(views::Link* source, int event_flags); |
| 95 | 81 |
| 96 // views::WindowDelegate overrides. | 82 // views::WindowDelegate overrides. |
| 97 virtual int GetDialogButtons() const { | 83 virtual int GetDialogButtons() const { |
| 98 return MessageBoxFlags::DIALOGBUTTON_NONE; | 84 return MessageBoxFlags::DIALOGBUTTON_NONE; |
| 99 } | 85 } |
| 100 | 86 |
| 101 // CookieInfoViewDelegate overrides: | 87 // CookieInfoViewDelegate overrides: |
| 102 virtual void ModifyExpireDate(bool session_expire); | 88 virtual void ModifyExpireDate(bool session_expire); |
| 103 | 89 |
| 104 private: | 90 private: |
| 105 // Use the static factory method to show. | 91 // Use the static factory method to show. |
| 106 explicit CookiesPromptView(Profile* profile, | 92 explicit CookiePromptView(Profile* profile, |
| 107 CookiesPromptViewDelegate* delegate); | 93 CookiePromptModalDialogDelegate* delegate); |
| 108 | 94 |
| 109 // Initialize the dialog layout. | 95 // Initialize the dialog layout. |
| 110 void Init(); | 96 void Init(); |
| 111 | 97 |
| 112 // Shows or hides cooke info view and changes parent. | 98 // Shows or hides cooke info view and changes parent. |
| 113 void ToggleDetailsViewExpand(); | 99 void ToggleDetailsViewExpand(); |
| 114 | 100 |
| 115 // Calculates view size offset depending on visibility of cookie details. | 101 // Calculates view size offset depending on visibility of cookie details. |
| 116 int GetExtendedViewHeight(); | 102 int GetExtendedViewHeight(); |
| 117 | 103 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 134 | 120 |
| 135 // True if the outcome of this dialog has been signaled to the delegate. | 121 // True if the outcome of this dialog has been signaled to the delegate. |
| 136 bool signaled_; | 122 bool signaled_; |
| 137 | 123 |
| 138 // Prompt window title. | 124 // Prompt window title. |
| 139 std::wstring title_; | 125 std::wstring title_; |
| 140 | 126 |
| 141 // Whether we're showing cookie UI as opposed to other site data. | 127 // Whether we're showing cookie UI as opposed to other site data. |
| 142 bool cookie_ui_; | 128 bool cookie_ui_; |
| 143 | 129 |
| 144 CookiesPromptViewDelegate* delegate_; | 130 // A pointer to the AppModalDialog that owns us. |
| 131 CookiePromptModalDialog* parent_; |
| 145 | 132 |
| 146 // Cookie domain. | 133 gfx::NativeWindow root_window_; |
| 134 |
| 135 // The Profile for which Cookies are displayed. |
| 136 Profile* profile_; |
| 137 |
| 138 // Cookie / local storage domain. |
| 147 std::string domain_; | 139 std::string domain_; |
| 148 | 140 |
| 149 // Cookie domain formatted for displaying (removed leading '.'). | 141 // Domain name formatted for displaying (removed leading '.'). |
| 150 std::wstring display_domain_; | 142 std::wstring display_domain_; |
| 151 | 143 |
| 152 // Displayed cookie. Only used when |cookie_ui_| is true. | 144 // Displayed cookie. Only used when |cookie_ui_| is true. |
| 153 net::CookieMonster::CanonicalCookie cookie_; | 145 std::string cookie_line_; |
| 154 | 146 |
| 155 // Displayed local storage info. Only used when |cookie_ui_| is false. | 147 // Displayed local storage info. Only used when |cookie_ui_| is false. |
| 156 BrowsingDataLocalStorageHelper::LocalStorageInfo local_storage_info_; | 148 BrowsingDataLocalStorageHelper::LocalStorageInfo local_storage_info_; |
| 157 | 149 |
| 158 // The Profile for which Cookies are displayed. | 150 CookiePromptModalDialogDelegate* delegate_; |
| 159 Profile* profile_; | |
| 160 | 151 |
| 161 DISALLOW_COPY_AND_ASSIGN(CookiesPromptView); | 152 DISALLOW_COPY_AND_ASSIGN(CookiePromptView); |
| 162 }; | 153 }; |
| 163 | 154 |
| 164 #endif // CHROME_BROWSER_VIEWS_COOKIE_PROMPT_VIEW_H_ | 155 #endif // CHROME_BROWSER_VIEWS_COOKIE_PROMPT_VIEW_H_ |
| 165 | 156 |
| OLD | NEW |