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.
5 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h"
7 #include "base/logging.h"
8 #include "content/public/browser/web_contents.h"
10 using content::BrowserContext
;
11 using content::OpenURLParams
;
12 using content::WebContents
;
16 // Incognito profiles are not long-lived, so we always want to store a
17 // non-incognito profile.
19 // TODO(akalin): Should we make it so that we have a default incognito
20 // profile that's long-lived? Of course, we'd still have to clear it out
21 // when all incognito browsers close.
22 WebDialogWebContentsDelegate::WebDialogWebContentsDelegate(
23 content::BrowserContext
* browser_context
,
24 WebContentsHandler
* handler
)
25 : browser_context_(browser_context
),
27 CHECK(handler_
.get());
30 WebDialogWebContentsDelegate::~WebDialogWebContentsDelegate() {
33 void WebDialogWebContentsDelegate::Detach() {
34 browser_context_
= NULL
;
37 WebContents
* WebDialogWebContentsDelegate::OpenURLFromTab(
38 WebContents
* source
, const OpenURLParams
& params
) {
39 return handler_
->OpenURLFromTab(browser_context_
, source
, params
);
42 void WebDialogWebContentsDelegate::AddNewContents(
43 WebContents
* source
, WebContents
* new_contents
,
44 WindowOpenDisposition disposition
, const gfx::Rect
& initial_pos
,
47 handler_
->AddNewContents(browser_context_
, source
, new_contents
, disposition
,
48 initial_pos
, user_gesture
);
51 bool WebDialogWebContentsDelegate::IsPopupOrPanel(
52 const WebContents
* source
) const {
53 // This needs to return true so that we are allowed to be resized by our