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

Side by Side Diff: chrome/browser/android/chrome_web_contents_delegate_android.cc

Issue 23264020: Move Android to use new Popup Blocker API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cleanup Created 7 years, 4 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/android/chrome_web_contents_delegate_android.h" 5 #include "chrome/browser/android/chrome_web_contents_delegate_android.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "base/command_line.h"
9 #include "chrome/browser/android/tab_android.h"
8 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/file_select_helper.h" 11 #include "chrome/browser/file_select_helper.h"
10 #include "chrome/browser/media/media_capture_devices_dispatcher.h" 12 #include "chrome/browser/media/media_capture_devices_dispatcher.h"
13 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h" 14 #include "chrome/browser/ui/app_modal_dialogs/javascript_dialog_manager.h"
15 #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h"
16 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h"
17 #include "chrome/browser/ui/browser_navigator.h"
12 #include "chrome/browser/ui/find_bar/find_notification_details.h" 18 #include "chrome/browser/ui/find_bar/find_notification_details.h"
13 #include "chrome/browser/ui/find_bar/find_tab_helper.h" 19 #include "chrome/browser/ui/find_bar/find_tab_helper.h"
20 #include "chrome/common/chrome_switches.h"
14 #include "content/public/browser/notification_details.h" 21 #include "content/public/browser/notification_details.h"
15 #include "content/public/browser/notification_service.h" 22 #include "content/public/browser/notification_service.h"
16 #include "content/public/browser/notification_source.h" 23 #include "content/public/browser/notification_source.h"
24 #include "content/public/browser/render_view_host.h"
17 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
18 #include "content/public/common/file_chooser_params.h" 26 #include "content/public/common/file_chooser_params.h"
19 #include "jni/ChromeWebContentsDelegateAndroid_jni.h" 27 #include "jni/ChromeWebContentsDelegateAndroid_jni.h"
28 #include "third_party/WebKit/public/web/WebWindowFeatures.h"
20 #include "ui/gfx/rect.h" 29 #include "ui/gfx/rect.h"
21 #include "ui/gfx/rect_f.h" 30 #include "ui/gfx/rect_f.h"
22 31
23 #if defined(ENABLE_PLUGINS) 32 #if defined(ENABLE_PLUGINS)
24 #include "chrome/browser/pepper_broker_infobar_delegate.h" 33 #include "chrome/browser/pepper_broker_infobar_delegate.h"
25 #endif 34 #endif
26 35
27 using base::android::ScopedJavaLocalRef; 36 using base::android::ScopedJavaLocalRef;
28 using content::FileChooserParams; 37 using content::FileChooserParams;
29 using content::WebContents; 38 using content::WebContents;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 const base::Callback<void(bool)>& callback) { 219 const base::Callback<void(bool)>& callback) {
211 #if defined(ENABLE_PLUGINS) 220 #if defined(ENABLE_PLUGINS)
212 PepperBrokerInfoBarDelegate::Create( 221 PepperBrokerInfoBarDelegate::Create(
213 web_contents, url, plugin_path, callback); 222 web_contents, url, plugin_path, callback);
214 return true; 223 return true;
215 #else 224 #else
216 return false; 225 return false;
217 #endif 226 #endif
218 } 227 }
219 228
229 WebContents* ChromeWebContentsDelegateAndroid::OpenURLFromTab(
230 WebContents* source,
231 const content::OpenURLParams& params) {
232 WindowOpenDisposition disposition = params.disposition;
233 if (!source || (disposition != CURRENT_TAB &&
Yaron 2013/08/21 19:07:58 Can source be NULL? Won't we just crash later?
David Trainor- moved to gerrit 2013/08/21 20:21:27 The NULL check for source is done everywhere by br
234 disposition != NEW_FOREGROUND_TAB &&
235 disposition != NEW_BACKGROUND_TAB &&
236 disposition != OFF_THE_RECORD &&
237 disposition != NEW_POPUP &&
238 disposition != NEW_WINDOW)) {
239 // We can't handle this here. Give the parent a chance.
240 return WebContentsDelegateAndroid::OpenURLFromTab(source, params);
241 }
242
243 Profile* profile = Profile::FromBrowserContext(source->GetBrowserContext());
244 chrome::NavigateParams nav_params(profile,
245 params.url,
246 params.transition);
247 FillNavigateParamsFromOpenURLParams(&nav_params, params);
248 nav_params.source_contents = source;
249 nav_params.window_action = chrome::NavigateParams::SHOW_WINDOW;
250 nav_params.user_gesture = params.user_gesture;
251
252 PopupBlockerTabHelper* popup_blocker_helper = NULL;
253 if (source)
Yaron 2013/08/21 19:07:58 You've already de-refed source on L243.
David Trainor- moved to gerrit 2013/08/21 20:21:27 Done.
254 popup_blocker_helper = PopupBlockerTabHelper::FromWebContents(source);
255
256 DCHECK(popup_blocker_helper);
257
258 if (popup_blocker_helper) {
Yaron 2013/08/21 19:07:58 No need for if after DCHECK
David Trainor- moved to gerrit 2013/08/21 20:21:27 Done.
Ted C 2013/08/21 21:06:15 Really? I thought you had to fail gracefully for
Yaron 2013/08/22 00:36:30 Nope. From http://www.chromium.org/developers/codi
259 if ((params.disposition == NEW_POPUP ||
260 params.disposition == NEW_FOREGROUND_TAB ||
261 params.disposition == NEW_BACKGROUND_TAB ||
262 params.disposition == NEW_WINDOW) &&
263 !params.user_gesture &&
264 !CommandLine::ForCurrentProcess()->HasSwitch(
265 switches::kDisablePopupBlocking)) {
266 if (popup_blocker_helper->MaybeBlockPopup(nav_params,
267 WebKit::WebWindowFeatures())) {
268 return NULL;
269 }
270 }
271 }
272
273 return WebContentsDelegateAndroid::OpenURLFromTab(source, params);
274 }
275
276 void ChromeWebContentsDelegateAndroid::AddNewContents(
jochen (gone - plz use gerrit) 2013/08/21 08:05:25 this isn't really related to popup blocking, but f
David Trainor- moved to gerrit 2013/08/21 17:27:03 We were using this code path downstream for popups
277 WebContents* source,
278 WebContents* new_contents,
279 WindowOpenDisposition disposition,
280 const gfx::Rect& initial_pos,
281 bool user_gesture,
282 bool* was_blocked) {
283 // No code for this yet.
284 DCHECK(disposition != SAVE_TO_DISK);
Yaron 2013/08/21 19:07:58 DCHECK_NE
David Trainor- moved to gerrit 2013/08/21 20:21:27 Done.
285 // Can't create a new contents for the current tab - invalid case.
286 DCHECK(disposition != CURRENT_TAB);
Yaron 2013/08/21 19:07:58 DCHECK_NE
David Trainor- moved to gerrit 2013/08/21 20:21:27 Done.
287
288 BlockedContentTabHelper* source_blocked_content = NULL;
289 if (source)
Yaron 2013/08/21 19:07:58 Indentation off and this may be unnecessary?
David Trainor- moved to gerrit 2013/08/21 20:21:27 The code this was built off of checks for source b
290 source_blocked_content = BlockedContentTabHelper::FromWebContents(source);
291
292 TabAndroid::InitTabHelpers(new_contents);
293
294 if (source_blocked_content) {
295 if (source_blocked_content->all_contents_blocked()) {
296 source_blocked_content->AddWebContents(
297 new_contents, disposition, initial_pos, user_gesture);
298 if (was_blocked)
299 *was_blocked = true;
300 return;
301 }
302
303 new_contents->GetRenderViewHost()->DisassociateFromPopupCount();
304 }
305
306 WebContentsDelegateAndroid::AddNewContents(source,
307 new_contents,
308 disposition,
309 initial_pos,
310 user_gesture,
311 was_blocked);
312 }
220 313
221 } // namespace android 314 } // namespace android
222 } // namespace chrome 315 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698