web_dialog_web_contents_delegate.cc revision 5d1f7b1de12d16ceb2c938c56701a3e8bfa558f7
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 11using content::BrowserContext; 12using content::OpenURLParams; 13using content::WebContents; 14 15namespace 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. 23WebDialogWebContentsDelegate::WebDialogWebContentsDelegate( 24 content::BrowserContext* browser_context, 25 WebContentsHandler* handler) 26 : browser_context_(browser_context), 27 handler_(handler) { 28 CHECK(handler_.get()); 29} 30 31WebDialogWebContentsDelegate::~WebDialogWebContentsDelegate() { 32} 33 34void WebDialogWebContentsDelegate::Detach() { 35 browser_context_ = NULL; 36} 37 38WebContents* WebDialogWebContentsDelegate::OpenURLFromTab( 39 WebContents* source, const OpenURLParams& params) { 40 return handler_->OpenURLFromTab(browser_context_, source, params); 41} 42 43void 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 52bool 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 59bool 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