| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_VIEWS_COOKIE_PROMPT_VIEW_H_ | |
| 6 #define CHROME_BROWSER_VIEWS_COOKIE_PROMPT_VIEW_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/task.h" | |
| 12 #include "chrome/browser/browsing_data_local_storage_helper.h" | |
| 13 #include "chrome/browser/cookie_prompt_modal_dialog_delegate.h" | |
| 14 #include "chrome/browser/views/cookie_info_view.h" | |
| 15 #include "chrome/browser/views/modal_dialog_delegate.h" | |
| 16 #include "googleurl/src/gurl.h" | |
| 17 #include "views/controls/button/button.h" | |
| 18 #include "views/controls/link.h" | |
| 19 #include "views/view.h" | |
| 20 #include "views/window/dialog_delegate.h" | |
| 21 #include "views/window/window.h" | |
| 22 | |
| 23 namespace views { | |
| 24 class NativeButton; | |
| 25 class RadioButton; | |
| 26 } | |
| 27 | |
| 28 class CookieInfoView; | |
| 29 class CookiePromptModalDialog; | |
| 30 class LocalStorageInfoView; | |
| 31 class Profile; | |
| 32 class Timer; | |
| 33 | |
| 34 // Cookie alert dialog UI. | |
| 35 class CookiePromptView : public views::View, | |
| 36 public ModalDialogDelegate, | |
| 37 public views::ButtonListener, | |
| 38 public views::LinkController, | |
| 39 public CookieInfoViewDelegate { | |
| 40 public: | |
| 41 // Creates a new CookiePromptView. We take ownership of |parent|. | |
| 42 CookiePromptView( | |
| 43 CookiePromptModalDialog* parent, | |
| 44 gfx::NativeWindow root_window, | |
| 45 Profile* profile); | |
| 46 | |
| 47 virtual ~CookiePromptView(); | |
| 48 | |
| 49 protected: | |
| 50 // views::View overrides. | |
| 51 virtual gfx::Size GetPreferredSize(); | |
| 52 virtual void ViewHierarchyChanged(bool is_add, | |
| 53 views::View* parent, | |
| 54 views::View* child); | |
| 55 | |
| 56 // ModalDialogDelegate overrides. | |
| 57 virtual gfx::NativeWindow GetDialogRootWindow(); | |
| 58 | |
| 59 // views::DialogDelegate overrides. | |
| 60 virtual bool CanResize() const { return false; } | |
| 61 virtual std::wstring GetWindowTitle() const; | |
| 62 virtual void WindowClosing(); | |
| 63 virtual views::View* GetContentsView(); | |
| 64 virtual bool IsModal() const { return true; } | |
| 65 virtual bool Accept(); | |
| 66 | |
| 67 // views::ButtonListener overrides. | |
| 68 virtual void ButtonPressed(views::Button* sender, const views::Event& event); | |
| 69 | |
| 70 // views::LinkController overrides. | |
| 71 virtual void LinkActivated(views::Link* source, int event_flags); | |
| 72 | |
| 73 // views::WindowDelegate overrides. | |
| 74 virtual int GetDialogButtons() const { | |
| 75 return MessageBoxFlags::DIALOGBUTTON_NONE; | |
| 76 } | |
| 77 | |
| 78 // CookieInfoViewDelegate overrides: | |
| 79 virtual void ModifyExpireDate(bool session_expire); | |
| 80 | |
| 81 private: | |
| 82 // Initialize the dialog layout. | |
| 83 void Init(); | |
| 84 | |
| 85 // Shows or hides cooke info view and changes parent. | |
| 86 void ToggleDetailsViewExpand(); | |
| 87 | |
| 88 // Calculates view size offset depending on visibility of cookie details. | |
| 89 int GetExtendedViewHeight(); | |
| 90 | |
| 91 // Initializes text resources needed to display this view. | |
| 92 void InitializeViewResources(); | |
| 93 | |
| 94 views::RadioButton* remember_radio_; | |
| 95 views::RadioButton* ask_radio_; | |
| 96 views::NativeButton* allow_button_; | |
| 97 views::NativeButton* block_button_; | |
| 98 views::Link* show_cookie_link_; | |
| 99 views::View* info_view_; | |
| 100 | |
| 101 // True if cookie should expire with this session. | |
| 102 bool session_expire_; | |
| 103 | |
| 104 // True if cookie info view is currently shown and window expanded. | |
| 105 bool expanded_view_; | |
| 106 | |
| 107 // True if the outcome of this dialog has been signaled to the delegate. | |
| 108 bool signaled_; | |
| 109 | |
| 110 // Prompt window title. | |
| 111 std::wstring title_; | |
| 112 | |
| 113 // A pointer to the AppModalDialog that created us. We own this. | |
| 114 scoped_ptr<CookiePromptModalDialog> parent_; | |
| 115 | |
| 116 gfx::NativeWindow root_window_; | |
| 117 | |
| 118 Profile* profile_; | |
| 119 | |
| 120 DISALLOW_COPY_AND_ASSIGN(CookiePromptView); | |
| 121 }; | |
| 122 | |
| 123 #endif // CHROME_BROWSER_VIEWS_COOKIE_PROMPT_VIEW_H_ | |
| OLD | NEW |