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

Side by Side Diff: chrome/browser/ui/webui/constrained_html_ui.h

Issue 8220026: Add new methods to create constrained windows for print preview and release the internal TabConte... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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_UI_WEBUI_CONSTRAINED_HTML_UI_H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_
6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ 6 #define CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/ui/webui/chrome_web_ui.h" 9 #include "chrome/browser/ui/webui/chrome_web_ui.h"
10 #include "content/common/property_bag.h" 10 #include "content/common/property_bag.h"
11 11
12 class ConstrainedWindow; 12 class ConstrainedWindow;
13 class HtmlDialogUIDelegate; 13 class HtmlDialogUIDelegate;
14 class Profile; 14 class Profile;
15 class RenderViewHost; 15 class RenderViewHost;
16 class TabContents; 16 class TabContents;
17 class TabContentsWrapper; 17 class TabContentsWrapper;
18 18
19 class ConstrainedHtmlUIDelegate { 19 class ConstrainedHtmlUIDelegate {
20 public: 20 public:
21 virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() = 0; 21 virtual HtmlDialogUIDelegate* GetHtmlDialogUIDelegate() = 0;
22 22
23 // Called when the dialog is being closed in response to a "DialogClose" 23 // Called when the dialog is being closed in response to a "DialogClose"
24 // message from WebUI. 24 // message from WebUI.
25 virtual void OnDialogCloseFromWebUI() = 0; 25 virtual void OnDialogCloseFromWebUI() = 0;
26
27 // If called, on dialog closure, the dialog will release its TabContents
28 // instead of destroying it. After which point, the caller will own the
29 // released TabContents.
30 virtual void ReleaseTabContentsOnDialogClose() = 0;
31
32 protected:
33 virtual ~ConstrainedHtmlUIDelegate() {}
26 }; 34 };
27 35
28 // ConstrainedHtmlUI is a facility to show HTML WebUI content 36 // ConstrainedHtmlUI is a facility to show HTML WebUI content
29 // in a tab-modal constrained dialog. It is implemented as an adapter 37 // in a tab-modal constrained dialog. It is implemented as an adapter
30 // between an HtmlDialogUI object and a ConstrainedWindow object. 38 // between an HtmlDialogUI object and a ConstrainedWindow object.
31 // 39 //
32 // Since ConstrainedWindow requires platform-specific delegate 40 // Since ConstrainedWindow requires platform-specific delegate
33 // implementations, this class is just a factory stub. 41 // implementations, this class is just a factory stub.
34 class ConstrainedHtmlUI : public ChromeWebUI { 42 class ConstrainedHtmlUI : public ChromeWebUI {
35 public: 43 public:
36 explicit ConstrainedHtmlUI(TabContents* contents); 44 explicit ConstrainedHtmlUI(TabContents* contents);
37 virtual ~ConstrainedHtmlUI(); 45 virtual ~ConstrainedHtmlUI();
38 46
39 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE; 47 virtual void RenderViewCreated(RenderViewHost* render_view_host) OVERRIDE;
40 48
41 // Create a constrained HTML dialog. The actual object that gets created 49 // Create a constrained HTML dialog. The actual object that gets created
42 // is a ConstrainedHtmlUIDelegate, which later triggers construction of a 50 // is a ConstrainedHtmlUIDelegate, which later triggers construction of a
43 // ConstrainedHtmlUI object. 51 // ConstrainedHtmlUI object.
44 static ConstrainedWindow* CreateConstrainedHtmlDialog( 52 static ConstrainedWindow* CreateConstrainedHtmlDialog(
45 Profile* profile, 53 Profile* profile,
46 HtmlDialogUIDelegate* delegate, 54 HtmlDialogUIDelegate* delegate,
47 TabContentsWrapper* overshadowed); 55 TabContentsWrapper* overshadowed);
48 56
57 // Similar to CreateConstrainedHtmlDialog() but specifically for print
58 // preview, where we care about the constrained TabContentsWrapper rather
59 // than the ConstrainedWindow.
60 static TabContentsWrapper* CreateConstrainedPrintPreviewHtmlUI(
61 Profile* profile,
62 HtmlDialogUIDelegate* delegate,
63 TabContentsWrapper* overshadowed);
64
49 // Returns a property accessor that can be used to set the 65 // Returns a property accessor that can be used to set the
50 // ConstrainedHtmlUIDelegate property on a TabContents. 66 // ConstrainedHtmlUIDelegate property on a TabContents.
51 static PropertyAccessor<ConstrainedHtmlUIDelegate*>& 67 static PropertyAccessor<ConstrainedHtmlUIDelegate*>&
52 GetPropertyAccessor(); 68 GetPropertyAccessor();
53 69
54 private: 70 private:
71 FRIEND_TEST_ALL_PREFIXES(ConstrainedHtmlDialogBrowserTest,
72 ReleaseTabContentsOnDialogClose);
73
55 // Returns the TabContents' PropertyBag's ConstrainedHtmlUIDelegate. 74 // Returns the TabContents' PropertyBag's ConstrainedHtmlUIDelegate.
56 // Returns NULL if that property is not set. 75 // Returns NULL if that property is not set.
57 ConstrainedHtmlUIDelegate* GetConstrainedDelegate(); 76 ConstrainedHtmlUIDelegate* GetConstrainedDelegate();
58 77
59 // JS Message Handler 78 // JS Message Handler
60 void OnDialogCloseMessage(const base::ListValue* args); 79 void OnDialogCloseMessage(const base::ListValue* args);
61 80
62 DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUI); 81 DISALLOW_COPY_AND_ASSIGN(ConstrainedHtmlUI);
63 }; 82 };
64 83
65 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_ 84 #endif // CHROME_BROWSER_UI_WEBUI_CONSTRAINED_HTML_UI_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698