Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: chrome/browser/ui/webui/chrome_web_contents_handler.cc

Issue 10868116: Pass result of blockage across content API when new tab blocked. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h" 5 #include "chrome/browser/ui/webui/chrome_web_contents_handler.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_finder.h" 9 #include "chrome/browser/ui/browser_finder.h"
10 #include "chrome/browser/ui/browser_navigator.h" 10 #include "chrome/browser/ui/browser_navigator.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 return nav_params.target_contents ? 60 return nav_params.target_contents ?
61 nav_params.target_contents->web_contents() : NULL; 61 nav_params.target_contents->web_contents() : NULL;
62 } 62 }
63 63
64 // Creates a new tab with |new_contents|. |context| is the browser context that 64 // Creates a new tab with |new_contents|. |context| is the browser context that
65 // the browser should be owned by. |source| is the WebContent where the 65 // the browser should be owned by. |source| is the WebContent where the
66 // operation originated. |disposition| controls how the new tab should be 66 // operation originated. |disposition| controls how the new tab should be
67 // opened. |initial_pos| is the position of the window if a new window is 67 // opened. |initial_pos| is the position of the window if a new window is
68 // created. |user_gesture| is true if the operation was started by a user 68 // created. |user_gesture| is true if the operation was started by a user
69 // gesture. 69 // gesture. Returns false if the tab was blocked.
70 void ChromeWebContentsHandler::AddNewContents( 70 bool ChromeWebContentsHandler::AddNewContents(
71 content::BrowserContext* context, 71 content::BrowserContext* context,
72 WebContents* source, 72 WebContents* source,
73 WebContents* new_contents, 73 WebContents* new_contents,
74 WindowOpenDisposition disposition, 74 WindowOpenDisposition disposition,
75 const gfx::Rect& initial_pos, 75 const gfx::Rect& initial_pos,
76 bool user_gesture) { 76 bool user_gesture) {
77 if (!context) 77 if (!context)
78 return; 78 return false;
79 79
80 Profile* profile = Profile::FromBrowserContext(context); 80 Profile* profile = Profile::FromBrowserContext(context);
81 Browser* browser = browser::FindTabbedBrowser(profile, false); 81 Browser* browser = browser::FindTabbedBrowser(profile, false);
82 const bool browser_created = !browser; 82 const bool browser_created = !browser;
83 if (!browser) 83 if (!browser)
84 browser = new Browser(Browser::CreateParams(profile)); 84 browser = new Browser(Browser::CreateParams(profile));
85 TabContents* tab_contents = 85 TabContents* tab_contents =
86 TabContents::Factory::CreateTabContents(new_contents); 86 TabContents::Factory::CreateTabContents(new_contents);
87 chrome::NavigateParams params(browser, tab_contents); 87 chrome::NavigateParams params(browser, tab_contents);
88 // TODO(pinkerton): no way to get a TabContents for this. 88 // TODO(pinkerton): no way to get a TabContents for this.
89 // params.source_contents = source; 89 // params.source_contents = source;
90 params.disposition = disposition; 90 params.disposition = disposition;
91 params.window_bounds = initial_pos; 91 params.window_bounds = initial_pos;
92 params.window_action = chrome::NavigateParams::SHOW_WINDOW; 92 params.window_action = chrome::NavigateParams::SHOW_WINDOW;
93 params.user_gesture = true; 93 params.user_gesture = true;
94 chrome::Navigate(&params); 94 chrome::Navigate(&params);
95 95
96 // Close the browser if chrome::Navigate created a new one. 96 // Close the browser if chrome::Navigate created a new one.
97 if (browser_created && (browser != params.browser)) 97 if (browser_created && (browser != params.browser))
98 browser->window()->Close(); 98 browser->window()->Close();
99
100 return true;
99 } 101 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698