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 #include "third_party/WebKit/public/web/WebInputEvent.h" 10 11 using content::BrowserContext; 12 using content::OpenURLParams; 13 using content::WebContents; 14 15 namespace ui { 16 17 // Incognito profiles are not long-lived, so we always want to store a 18 // non-incognito profile. 19 // 20 // TODO(akalin): Should we make it so that we have a default incognito 21 // profile that's long-lived? Of course, we'd still have to clear it out 22 // when all incognito browsers close. 23 WebDialogWebContentsDelegate::WebDialogWebContentsDelegate( 24 content::BrowserContext* browser_context, 25 WebContentsHandler* handler) 26 : browser_context_(browser_context), 27 handler_(handler) { 28 CHECK(handler_.get()); 29 } 30 31 WebDialogWebContentsDelegate::~WebDialogWebContentsDelegate() { 32 } 33 34 void WebDialogWebContentsDelegate::Detach() { 35 browser_context_ = NULL; 36 } 37 38 WebContents* WebDialogWebContentsDelegate::OpenURLFromTab( 39 WebContents* source, const OpenURLParams& params) { 40 return handler_->OpenURLFromTab(browser_context_, source, params); 41 } 42 43 void WebDialogWebContentsDelegate::AddNewContents( 44 WebContents* source, WebContents* new_contents, 45 WindowOpenDisposition disposition, const gfx::Rect& initial_pos, 46 bool user_gesture, 47 bool* was_blocked) { 48 handler_->AddNewContents(browser_context_, source, new_contents, disposition, 49 initial_pos, user_gesture); 50 } 51 52 bool WebDialogWebContentsDelegate::IsPopupOrPanel( 53 const WebContents* source) const { 54 // This needs to return true so that we are allowed to be resized by our 55 // contents. 56 return true; 57 } 58 59 bool WebDialogWebContentsDelegate::PreHandleGestureEvent( 60 WebContents* source, 61 const blink::WebGestureEvent& event) { 62 // Disable pinch zooming. 63 return event.type == blink::WebGestureEvent::GesturePinchBegin || 64 event.type == blink::WebGestureEvent::GesturePinchUpdate || 65 event.type == blink::WebGestureEvent::GesturePinchEnd; 66 } 67 68 } // namespace ui 69