Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / blocked_content / blocked_window_params.cc
blob03e457f8e855e6f5a52358c660819822290fca22
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 "third_party/WebKit/public/web/WebWindowFeatures.h"
12 #include "url/gurl.h"
14 BlockedWindowParams::BlockedWindowParams(
15 const GURL& target_url,
16 const content::Referrer& referrer,
17 WindowOpenDisposition disposition,
18 const blink::WebWindowFeatures& features,
19 bool user_gesture,
20 bool opener_suppressed,
21 int render_process_id,
22 int opener_render_frame_id)
23 : target_url_(target_url),
24 referrer_(referrer),
25 disposition_(disposition),
26 features_(features),
27 user_gesture_(user_gesture),
28 opener_suppressed_(opener_suppressed),
29 render_process_id_(render_process_id),
30 opener_render_frame_id_(opener_render_frame_id) {
33 chrome::NavigateParams BlockedWindowParams::CreateNavigateParams(
34 content::WebContents* web_contents) const {
35 GURL popup_url(target_url_);
36 web_contents->GetRenderProcessHost()->FilterURL(false, &popup_url);
37 chrome::NavigateParams nav_params(
38 Profile::FromBrowserContext(web_contents->GetBrowserContext()),
39 popup_url,
40 ui::PAGE_TRANSITION_LINK);
41 nav_params.referrer = referrer_;
42 nav_params.source_contents = web_contents;
43 nav_params.is_renderer_initiated = true;
44 nav_params.tabstrip_add_types = TabStripModel::ADD_ACTIVE;
45 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW;
46 nav_params.user_gesture = user_gesture_;
47 nav_params.created_with_opener = !opener_suppressed_;
48 nav_params.window_bounds = web_contents->GetContainerBounds();
49 if (features_.xSet)
50 nav_params.window_bounds.set_x(features_.x);
51 if (features_.ySet)
52 nav_params.window_bounds.set_y(features_.y);
53 if (features_.widthSet)
54 nav_params.window_bounds.set_width(features_.width);
55 if (features_.heightSet)
56 nav_params.window_bounds.set_height(features_.height);
58 nav_params.disposition = disposition_;
60 return nav_params;