Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: chrome/browser/views/html_dialog_view.h

Issue 441011: Created HtmlDialogTabContentsDelegate, which encapsulates the (Closed)
Patch Set: Synced to head. Created 11 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/gtk/html_dialog_gtk.cc ('k') | chrome/browser/views/html_dialog_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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_HTML_DIALOG_VIEW_H_ 5 #ifndef CHROME_BROWSER_VIEWS_HTML_DIALOG_VIEW_H_
6 #define CHROME_BROWSER_VIEWS_HTML_DIALOG_VIEW_H_ 6 #define CHROME_BROWSER_VIEWS_HTML_DIALOG_VIEW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/gfx/size.h" 10 #include "base/gfx/size.h"
11 #include "chrome/browser/dom_ui/html_dialog_ui.h" 11 #include "chrome/browser/dom_ui/html_dialog_ui.h"
12 #include "chrome/browser/tab_contents/tab_contents_delegate.h" 12 #include "chrome/browser/dom_ui/html_dialog_tab_contents_delegate.h"
13 #include "chrome/browser/views/dom_view.h" 13 #include "chrome/browser/views/dom_view.h"
14 #include "views/window/window_delegate.h" 14 #include "views/window/window_delegate.h"
15 15
16 class Browser; 16 class Browser;
17 namespace views { 17 namespace views {
18 class Window; 18 class Window;
19 } 19 }
20 20
21 //////////////////////////////////////////////////////////////////////////////// 21 ////////////////////////////////////////////////////////////////////////////////
22 // 22 //
23 // HtmlDialogView is a view used to display an HTML dialog to the user. The 23 // HtmlDialogView is a view used to display an HTML dialog to the user. The
24 // content of the dialogs is determined by the delegate 24 // content of the dialogs is determined by the delegate
25 // (HtmlDialogUIDelegate), but is basically a file URL along with a 25 // (HtmlDialogUIDelegate), but is basically a file URL along with a
26 // JSON input string. The HTML is supposed to show a UI to the user and is 26 // JSON input string. The HTML is supposed to show a UI to the user and is
27 // expected to send back a JSON file as a return value. 27 // expected to send back a JSON file as a return value.
28 // 28 //
29 //////////////////////////////////////////////////////////////////////////////// 29 ////////////////////////////////////////////////////////////////////////////////
30 //
31 // TODO(akalin): Make HtmlDialogView contain an HtmlDialogTabContentsDelegate
32 // instead of inheriting from it to avoid violating the "no multiple
33 // inheritance" rule.
30 class HtmlDialogView 34 class HtmlDialogView
31 : public DOMView, 35 : public DOMView,
32 public TabContentsDelegate, 36 public HtmlDialogTabContentsDelegate,
33 public HtmlDialogUIDelegate, 37 public HtmlDialogUIDelegate,
34 public views::WindowDelegate { 38 public views::WindowDelegate {
35 public: 39 public:
36 HtmlDialogView(Browser* parent_browser, HtmlDialogUIDelegate* delegate); 40 HtmlDialogView(Profile* profile, HtmlDialogUIDelegate* delegate);
37 virtual ~HtmlDialogView(); 41 virtual ~HtmlDialogView();
38 42
39 // Initializes the contents of the dialog (the DOMView and the callbacks). 43 // Initializes the contents of the dialog (the DOMView and the callbacks).
40 void InitDialog(); 44 void InitDialog();
41 45
42 // Overridden from views::View: 46 // Overridden from views::View:
43 virtual gfx::Size GetPreferredSize(); 47 virtual gfx::Size GetPreferredSize();
44 virtual bool AcceleratorPressed(const views::Accelerator& accelerator); 48 virtual bool AcceleratorPressed(const views::Accelerator& accelerator);
45 49
46 // Overridden from views::WindowDelegate: 50 // Overridden from views::WindowDelegate:
47 virtual bool CanResize() const; 51 virtual bool CanResize() const;
48 virtual bool IsModal() const; 52 virtual bool IsModal() const;
49 virtual std::wstring GetWindowTitle() const; 53 virtual std::wstring GetWindowTitle() const;
50 virtual void WindowClosing(); 54 virtual void WindowClosing();
51 virtual views::View* GetContentsView(); 55 virtual views::View* GetContentsView();
52 virtual views::View* GetInitiallyFocusedView(); 56 virtual views::View* GetInitiallyFocusedView();
53 57
54 // Overridden from HtmlDialogUI::Delegate: 58 // Overridden from HtmlDialogUI::Delegate:
55 virtual bool IsDialogModal() const; 59 virtual bool IsDialogModal() const;
56 virtual std::wstring GetDialogTitle() const; 60 virtual std::wstring GetDialogTitle() const;
57 virtual GURL GetDialogContentURL() const; 61 virtual GURL GetDialogContentURL() const;
58 virtual void GetDOMMessageHandlers( 62 virtual void GetDOMMessageHandlers(
59 std::vector<DOMMessageHandler*>* handlers) const; 63 std::vector<DOMMessageHandler*>* handlers) const;
60 virtual void GetDialogSize(gfx::Size* size) const; 64 virtual void GetDialogSize(gfx::Size* size) const;
61 virtual std::string GetDialogArgs() const; 65 virtual std::string GetDialogArgs() const;
62 virtual void OnDialogClosed(const std::string& json_retval); 66 virtual void OnDialogClosed(const std::string& json_retval);
63 67
64 // Overridden from TabContentsDelegate: 68 // Overridden from TabContentsDelegate:
65 virtual void OpenURLFromTab(TabContents* source,
66 const GURL& url,
67 const GURL& referrer,
68 WindowOpenDisposition disposition,
69 PageTransition::Type transition);
70 virtual void NavigationStateChanged(const TabContents* source,
71 unsigned changed_flags);
72 virtual void ReplaceContents(TabContents* source,
73 TabContents* new_contents);
74 virtual void AddNewContents(TabContents* source,
75 TabContents* new_contents,
76 WindowOpenDisposition disposition,
77 const gfx::Rect& initial_pos,
78 bool user_gesture);
79 virtual void ActivateContents(TabContents* contents);
80 virtual void LoadingStateChanged(TabContents* source);
81 virtual void CloseContents(TabContents* source);
82 virtual void MoveContents(TabContents* source, const gfx::Rect& pos); 69 virtual void MoveContents(TabContents* source, const gfx::Rect& pos);
83 virtual bool IsPopup(TabContents* source);
84 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating); 70 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating);
85 virtual void URLStarredChanged(TabContents* source, bool starred);
86 virtual void UpdateTargetURL(TabContents* source, const GURL& url);
87 71
88 private: 72 private:
89 // The Browser object which created this html dialog; we send all
90 // window opening/navigations to this object.
91 Browser* parent_browser_;
92
93 Profile* profile_;
94
95 // This view is a delegate to the HTML content since it needs to get notified 73 // This view is a delegate to the HTML content since it needs to get notified
96 // about when the dialog is closing. For all other actions (besides dialog 74 // about when the dialog is closing. For all other actions (besides dialog
97 // closing) we delegate to the creator of this view, which we keep track of 75 // closing) we delegate to the creator of this view, which we keep track of
98 // using this variable. 76 // using this variable.
99 HtmlDialogUIDelegate* delegate_; 77 HtmlDialogUIDelegate* delegate_;
100 78
101 DISALLOW_COPY_AND_ASSIGN(HtmlDialogView); 79 DISALLOW_COPY_AND_ASSIGN(HtmlDialogView);
102 }; 80 };
103 81
104 #endif // CHROME_BROWSER_VIEWS_HTML_DIALOG_VIEW_H_ 82 #endif // CHROME_BROWSER_VIEWS_HTML_DIALOG_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/gtk/html_dialog_gtk.cc ('k') | chrome/browser/views/html_dialog_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698