'Open as window' removed when --enable-new-bookmark-apps is disabled.
[chromium-blink-merge.git] / ui / web_dialogs / web_dialog_web_contents_delegate.cc
blobea0006ae79d8e9a20db3fc543db5fdc7faa98ddc
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"
9 #include "third_party/WebKit/public/web/WebInputEvent.h"
11 using content::BrowserContext;
12 using content::OpenURLParams;
13 using content::WebContents;
15 namespace ui {
17 // Incognito profiles are not long-lived, so we always want to store a
18 // non-incognito profile.
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());
31 WebDialogWebContentsDelegate::~WebDialogWebContentsDelegate() {
34 void WebDialogWebContentsDelegate::Detach() {
35 browser_context_ = NULL;
38 WebContents* WebDialogWebContentsDelegate::OpenURLFromTab(
39 WebContents* source, const OpenURLParams& params) {
40 return handler_->OpenURLFromTab(browser_context_, source, params);
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);
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;
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;
68 } // namespace ui