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

Side by Side Diff: chrome/browser/ui/views/web_dialog_view.h

Issue 10805047: Move WebDialogView to ui/views/controls/webview. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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_VIEWS_WEB_DIALOG_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_WEB_DIALOG_VIEW_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/gtest_prod_util.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "ui/gfx/size.h"
14 #include "ui/views/widget/widget_delegate.h"
15 #include "ui/views/window/client_view.h"
16 #include "ui/web_dialogs/web_dialog_delegate.h"
17 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h"
18
19 namespace content {
20 class BrowserContext;
21 }
22
23 namespace views {
24 class WebView;
25 }
26
27 ////////////////////////////////////////////////////////////////////////////////
28 //
29 // WebDialogView is a view used to display an web dialog to the user. The
30 // content of the dialogs is determined by the delegate
31 // (ui::WebDialogDelegate), but is basically a file URL along with a
32 // JSON input string. The HTML is supposed to show a UI to the user and is
33 // expected to send back a JSON file as a return value.
34 //
35 ////////////////////////////////////////////////////////////////////////////////
36 //
37 // TODO(akalin): Make WebDialogView contain an WebDialogWebContentsDelegate
38 // instead of inheriting from it to avoid violating the "no multiple
39 // inheritance" rule.
40 class WebDialogView : public views::ClientView,
41 public ui::WebDialogWebContentsDelegate,
42 public ui::WebDialogDelegate,
43 public views::WidgetDelegate {
44 public:
45 // |handler| must not be NULL and this class takes the ownership.
46 WebDialogView(content::BrowserContext* context,
47 ui::WebDialogDelegate* delegate,
48 WebContentsHandler* handler);
49 virtual ~WebDialogView();
50
51 // For testing.
52 content::WebContents* web_contents();
53
54 // Overridden from views::ClientView:
55 virtual gfx::Size GetPreferredSize() OVERRIDE;
56 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator)
57 OVERRIDE;
58 virtual void ViewHierarchyChanged(bool is_add,
59 views::View* parent,
60 views::View* child) OVERRIDE;
61 virtual bool CanClose() OVERRIDE;
62
63 // Overridden from views::WidgetDelegate:
64 virtual bool CanResize() const OVERRIDE;
65 virtual ui::ModalType GetModalType() const OVERRIDE;
66 virtual string16 GetWindowTitle() const OVERRIDE;
67 virtual std::string GetWindowName() const OVERRIDE;
68 virtual void WindowClosing() OVERRIDE;
69 virtual views::View* GetContentsView() OVERRIDE;
70 virtual ClientView* CreateClientView(views::Widget* widget) OVERRIDE;
71 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
72 virtual bool ShouldShowWindowTitle() const OVERRIDE;
73 virtual views::Widget* GetWidget() OVERRIDE;
74 virtual const views::Widget* GetWidget() const OVERRIDE;
75
76 // Overridden from ui::WebDialogDelegate:
77 virtual ui::ModalType GetDialogModalType() const OVERRIDE;
78 virtual string16 GetDialogTitle() const OVERRIDE;
79 virtual GURL GetDialogContentURL() const OVERRIDE;
80 virtual void GetWebUIMessageHandlers(
81 std::vector<content::WebUIMessageHandler*>* handlers) const OVERRIDE;
82 virtual void GetDialogSize(gfx::Size* size) const OVERRIDE;
83 virtual void GetMinimumDialogSize(gfx::Size* size) const OVERRIDE;
84 virtual std::string GetDialogArgs() const OVERRIDE;
85 virtual void OnDialogShown(
86 content::WebUI* webui,
87 content::RenderViewHost* render_view_host) OVERRIDE;
88 virtual void OnDialogClosed(const std::string& json_retval) OVERRIDE;
89 virtual void OnCloseContents(content::WebContents* source,
90 bool* out_close_dialog) OVERRIDE;
91 virtual bool ShouldShowDialogTitle() const OVERRIDE;
92 virtual bool HandleContextMenu(
93 const content::ContextMenuParams& params) OVERRIDE;
94
95 // Overridden from content::WebContentsDelegate:
96 virtual void MoveContents(content::WebContents* source,
97 const gfx::Rect& pos) OVERRIDE;
98 virtual void HandleKeyboardEvent(
99 const content::NativeWebKeyboardEvent& event) OVERRIDE;
100 virtual void CloseContents(content::WebContents* source) OVERRIDE;
101 virtual content::WebContents* OpenURLFromTab(
102 content::WebContents* source,
103 const content::OpenURLParams& params) OVERRIDE;
104 virtual void AddNewContents(content::WebContents* source,
105 content::WebContents* new_contents,
106 WindowOpenDisposition disposition,
107 const gfx::Rect& initial_pos,
108 bool user_gesture) OVERRIDE;
109 virtual void LoadingStateChanged(content::WebContents* source) OVERRIDE;
110
111 private:
112 FRIEND_TEST_ALL_PREFIXES(WebDialogBrowserTest, WebContentRendered);
113
114 // Initializes the contents of the dialog.
115 void InitDialog();
116
117 // Whether the view is initialized. That is, dialog accelerators is registered
118 // and FreezeUpdates property is set to prevent WM from showing the window
119 // until the property is removed.
120 bool initialized_;
121
122 // This view is a delegate to the HTML content since it needs to get notified
123 // about when the dialog is closing. For all other actions (besides dialog
124 // closing) we delegate to the creator of this view, which we keep track of
125 // using this variable.
126 ui::WebDialogDelegate* delegate_;
127
128 views::WebView* web_view_;
129
130 DISALLOW_COPY_AND_ASSIGN(WebDialogView);
131 };
132
133 #endif // CHROME_BROWSER_UI_VIEWS_WEB_DIALOG_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/keyboard_overlay_dialog_view.cc ('k') | chrome/browser/ui/views/web_dialog_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698