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 #include "ui/web_dialogs/web_dialog_web_contents_delegate.h" 6 7 #include "base/logging.h" 8 #include "content/public/browser/web_contents.h" 9 10 using content::BrowserContext; 11 using content::OpenURLParams; 12 using content::WebContents; 13 14 namespace ui { 15 16 // Incognito profiles are not long-lived, so we always want to store a 17 // non-incognito profile. 18 // 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), 26 handler_(handler) { 27 CHECK(handler_.get()); 28 } 29 30 WebDialogWebContentsDelegate::~WebDialogWebContentsDelegate() { 31 } 32 33 void WebDialogWebContentsDelegate::Detach() { 34 browser_context_ = NULL; 35 } 36 37 WebContents* WebDialogWebContentsDelegate::OpenURLFromTab( 38 WebContents* source, const OpenURLParams& params) { 39 return handler_->OpenURLFromTab(browser_context_, source, params); 40 } 41 42 void WebDialogWebContentsDelegate::AddNewContents( 43 WebContents* source, WebContents* new_contents, 44 WindowOpenDisposition disposition, const gfx::Rect& initial_pos, 45 bool user_gesture, 46 bool* was_blocked) { 47 handler_->AddNewContents(browser_context_, source, new_contents, disposition, 48 initial_pos, user_gesture); 49 } 50 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 54 // contents. 55 return true; 56 } 57 58 } // namespace ui 59