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

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

Issue 10353007: Extract a minimal subset of WebDialogUI/WebDialogDelegate from src/chrome -> src/ui/web_dialogs Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years, 7 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_WEBUI_CHROME_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_
6 #define CHROME_BROWSER_UI_WEBUI_CHROME_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_
7 #pragma once
8
9 #include "base/compiler_specific.h"
10 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h"
11
12 class Browser;
13 class Profile;
14
15 // This class implements (and mostly ignores) most of
16 // content::WebContentsDelegate for use in a Web dialog. Subclasses need only
17 // override a few methods instead of the everything from
18 // content::WebContentsDelegate; this way, implementations on all platforms
19 // behave consistently.
20 class ChromeWebDialogWebContentsDelegate
21 : public web_dialogs::WebDialogWebContentsDelegate {
22 public:
23 // Opens a new URL inside |source| (if source is NULL open in the current
24 // front-most tab). |profile| is the profile that the browser should be owened
25 // by. |params| contains the URL to open and various attributes such as
26 // disposition. On return |out_new_contents| contains the WebContents the
27 // URL is opened in. Returns the browser spawned by the operation.
28 static Browser* StaticOpenURLFromTab(Profile* profile,
29 content::WebContents* source,
30 const content::OpenURLParams& params,
31 content::WebContents** out_new_contents);
32
33 // Creates a new tab with |new_contents|. |profile| is the profile that the
34 // browser should be owned by. |source| is the WebContent where the operation
35 // originated. |disposition| controls how the new tab should be opened.
36 // |initial_pos| is the position of the window if a new window is created.
37 // |user_gesture| is true if the operation was started by a user gesture.
38 // Returns the browser spawned by the operation.
39 static Browser* StaticAddNewContents(Profile* profile,
40 content::WebContents* source,
41 content::WebContents* new_contents,
42 WindowOpenDisposition disposition,
43 const gfx::Rect& initial_pos,
44 bool user_gesture);
45
46 // Profile must be non-NULL.
47 explicit ChromeWebDialogWebContentsDelegate(Profile* profile);
48
49 virtual ~ChromeWebDialogWebContentsDelegate();
50
51 // The returned profile is guaranteed to be original if non-NULL.
52 Profile* profile() const;
53
54 // Calling this causes all following events sent from the
55 // WebContents object to be ignored. It also makes all following
56 // calls to profile() return NULL.
57 void Detach();
58
59 // content::WebContentsDelegate declarations.
60 virtual content::WebContents* OpenURLFromTab(
61 content::WebContents* source,
62 const content::OpenURLParams& params) OVERRIDE;
63
64 virtual void AddNewContents(content::WebContents* source,
65 content::WebContents* new_contents,
66 WindowOpenDisposition disposition,
67 const gfx::Rect& initial_pos,
68 bool user_gesture) OVERRIDE;
69
70 private:
71 Profile* profile_; // Weak pointer. Always an original profile.
72
73 DISALLOW_COPY_AND_ASSIGN(ChromeWebDialogWebContentsDelegate);
74 };
75
76 #endif // CHROME_BROWSER_UI_WEBUI_CHROME_WEB_DIALOG_WEB_CONTENTS_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698