Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / blocked_content / blocked_window_params.cc
blob69fdaeab1f46da1e270ba3bf8f4eab48f89bfcea
1 // Copyright 2013 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 "chrome/browser/ui/blocked_content/blocked_window_params.h"
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "content/public/browser/render_process_host.h"
10 #include "content/public/browser/web_contents.h"
11 #include "content/public/browser/web_contents_view.h"
12 #include "third_party/WebKit/public/web/WebWindowFeatures.h"
13 #include "url/gurl.h"
15 BlockedWindowParams::BlockedWindowParams(
16 const GURL& target_url,
17 const content::Referrer& referrer,
18 WindowOpenDisposition disposition,
19 const blink::WebWindowFeatures& features,
20 bool user_gesture,
21 bool opener_suppressed,
22 int render_process_id,
23 int opener_id)
24 : target_url_(target_url),
25 referrer_(referrer),
26 disposition_(disposition),
27 features_(features),
28 user_gesture_(user_gesture),
29 opener_suppressed_(opener_suppressed),
30 render_process_id_(render_process_id),
31 opener_id_(opener_id) {
34 chrome::NavigateParams BlockedWindowParams::CreateNavigateParams(
35 content::WebContents* web_contents) const {
36 GURL popup_url(target_url_);
37 web_contents->GetRenderProcessHost()->FilterURL(false, &popup_url);
38 chrome::NavigateParams nav_params(
39 Profile::FromBrowserContext(web_contents->GetBrowserContext()),
40 popup_url,
41 content::PAGE_TRANSITION_LINK);
42 nav_params.referrer = referrer_;
43 nav_params.source_contents = web_contents;
44 nav_params.is_renderer_initiated = true;
45 nav_params.tabstrip_add_types = TabStripModel::ADD_ACTIVE;
46 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW;
47 nav_params.user_gesture = user_gesture_;
48 nav_params.should_set_opener = !opener_suppressed_;
49 web_contents->GetView()->GetContainerBounds(&nav_params.window_bounds);
50 if (features_.xSet)
51 nav_params.window_bounds.set_x(features_.x);
52 if (features_.ySet)
53 nav_params.window_bounds.set_y(features_.y);
54 if (features_.widthSet)
55 nav_params.window_bounds.set_width(features_.width);
56 if (features_.heightSet)
57 nav_params.window_bounds.set_height(features_.height);
59 // Compare RenderViewImpl::show().
60 if (!user_gesture_ && disposition_ != NEW_BACKGROUND_TAB)
61 nav_params.disposition = NEW_POPUP;
62 else
63 nav_params.disposition = disposition_;
65 return nav_params;