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

Side by Side Diff: ios/chrome/browser/ui/browser_view_controller.mm

Issue 2737943003: Moved window opening callback to WebStateDelegate. (Closed)
Patch Set: Self review Created 3 years, 9 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #import "ios/chrome/browser/ui/browser_view_controller.h" 5 #import "ios/chrome/browser/ui/browser_view_controller.h"
6 6
7 #import <AssetsLibrary/AssetsLibrary.h> 7 #import <AssetsLibrary/AssetsLibrary.h>
8 #import <MobileCoreServices/MobileCoreServices.h> 8 #import <MobileCoreServices/MobileCoreServices.h>
9 #import <PassKit/PassKit.h> 9 #import <PassKit/PassKit.h>
10 #import <Photos/Photos.h> 10 #import <Photos/Photos.h>
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 #include "ios/chrome/browser/ui/toolbar/toolbar_model_delegate_ios.h" 148 #include "ios/chrome/browser/ui/toolbar/toolbar_model_delegate_ios.h"
149 #include "ios/chrome/browser/ui/toolbar/toolbar_model_ios.h" 149 #include "ios/chrome/browser/ui/toolbar/toolbar_model_ios.h"
150 #import "ios/chrome/browser/ui/tools_menu/tools_menu_context.h" 150 #import "ios/chrome/browser/ui/tools_menu/tools_menu_context.h"
151 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_item.h" 151 #import "ios/chrome/browser/ui/tools_menu/tools_menu_view_item.h"
152 #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h" 152 #import "ios/chrome/browser/ui/tools_menu/tools_popup_controller.h"
153 #include "ios/chrome/browser/ui/ui_util.h" 153 #include "ios/chrome/browser/ui/ui_util.h"
154 #import "ios/chrome/browser/ui/uikit_ui_util.h" 154 #import "ios/chrome/browser/ui/uikit_ui_util.h"
155 #import "ios/chrome/browser/ui/util/pasteboard_util.h" 155 #import "ios/chrome/browser/ui/util/pasteboard_util.h"
156 #import "ios/chrome/browser/ui/voice/text_to_speech_player.h" 156 #import "ios/chrome/browser/ui/voice/text_to_speech_player.h"
157 #include "ios/chrome/browser/upgrade/upgrade_center.h" 157 #include "ios/chrome/browser/upgrade/upgrade_center.h"
158 #import "ios/chrome/browser/web/blocked_popup_tab_helper.h"
158 #import "ios/chrome/browser/web/error_page_content.h" 159 #import "ios/chrome/browser/web/error_page_content.h"
159 #import "ios/chrome/browser/web/passkit_dialog_provider.h" 160 #import "ios/chrome/browser/web/passkit_dialog_provider.h"
160 #import "ios/chrome/browser/web/repost_form_tab_helper.h" 161 #import "ios/chrome/browser/web/repost_form_tab_helper.h"
161 #import "ios/chrome/browser/xcallback_parameters.h" 162 #import "ios/chrome/browser/xcallback_parameters.h"
162 #import "ios/chrome/common/material_timing.h" 163 #import "ios/chrome/common/material_timing.h"
163 #include "ios/chrome/grit/ios_chromium_strings.h" 164 #include "ios/chrome/grit/ios_chromium_strings.h"
164 #include "ios/chrome/grit/ios_strings.h" 165 #include "ios/chrome/grit/ios_strings.h"
165 #import "ios/net/request_tracker.h" 166 #import "ios/net/request_tracker.h"
166 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h" 167 #include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
167 #include "ios/public/provider/chrome/browser/ui/app_rating_prompt.h" 168 #include "ios/public/provider/chrome/browser/ui/app_rating_prompt.h"
(...skipping 2184 matching lines...) Expand 10 before | Expand all | Expand 10 after
2352 } 2353 }
2353 2354
2354 - (UIStatusBarStyle)preferredStatusBarStyle { 2355 - (UIStatusBarStyle)preferredStatusBarStyle {
2355 return (IsIPadIdiom() || _isOffTheRecord) ? UIStatusBarStyleLightContent 2356 return (IsIPadIdiom() || _isOffTheRecord) ? UIStatusBarStyleLightContent
2356 : UIStatusBarStyleDefault; 2357 : UIStatusBarStyleDefault;
2357 } 2358 }
2358 2359
2359 #pragma mark - CRWWebStateDelegate methods. 2360 #pragma mark - CRWWebStateDelegate methods.
2360 2361
2361 - (web::WebState*)webState:(web::WebState*)webState 2362 - (web::WebState*)webState:(web::WebState*)webState
2363 createNewWebStateForURL:(const GURL&)URL
2364 openerURL:(const GURL&)openerURL
2365 initiatedByUser:(BOOL)initiatedByUser {
2366 // Check if requested web state is a popup and block it if necessary.
2367 if (!initiatedByUser) {
2368 auto* helper = BlockedPopupTabHelper::FromWebState(webState);
2369 if (helper->ShouldBlockPopup(openerURL)) {
2370 web::NavigationItem* item =
2371 webState->GetNavigationManager()->GetLastCommittedItem();
2372 web::Referrer referrer(openerURL, item->GetReferrer().policy);
2373 helper->HandlePopup(URL, referrer);
2374 return nil;
2375 }
2376 }
2377
2378 // Requested web state should not be blocked from opening.
2379 Tab* currentTab = LegacyTabHelper::GetTabForWebState(webState);
2380 [currentTab updateSnapshotWithOverlay:YES visibleFrameOnly:YES];
2381
2382 // Tabs open by DOM are always renderer initiated.
2383 web::NavigationManager::WebLoadParams params(GURL{});
2384 params.transition_type = ui::PAGE_TRANSITION_LINK;
2385 params.is_renderer_initiated = true;
2386 Tab* childTab = [[self tabModel]
2387 insertTabWithLoadParams:params
2388 opener:currentTab
2389 openedByDOM:YES
2390 atIndex:TabModelConstants::kTabPositionAutomatically
2391 inBackground:NO];
2392 return childTab.webState;
2393 }
2394
2395 - (web::WebState*)webState:(web::WebState*)webState
2362 openURLWithParams:(const web::WebState::OpenURLParams&)params { 2396 openURLWithParams:(const web::WebState::OpenURLParams&)params {
2363 switch (params.disposition) { 2397 switch (params.disposition) {
2364 case WindowOpenDisposition::NEW_FOREGROUND_TAB: 2398 case WindowOpenDisposition::NEW_FOREGROUND_TAB:
2365 case WindowOpenDisposition::NEW_BACKGROUND_TAB: { 2399 case WindowOpenDisposition::NEW_BACKGROUND_TAB: {
2366 Tab* tab = [[self tabModel] 2400 Tab* tab = [[self tabModel]
2367 insertTabWithURL:params.url 2401 insertTabWithURL:params.url
2368 referrer:params.referrer 2402 referrer:params.referrer
2369 transition:params.transition 2403 transition:params.transition
2370 opener:LegacyTabHelper::GetTabForWebState(webState) 2404 opener:LegacyTabHelper::GetTabForWebState(webState)
2371 openedByDOM:NO 2405 openedByDOM:NO
(...skipping 2647 matching lines...) Expand 10 before | Expand all | Expand 10 after
5019 5053
5020 - (UIView*)voiceSearchButton { 5054 - (UIView*)voiceSearchButton {
5021 return _voiceSearchButton; 5055 return _voiceSearchButton;
5022 } 5056 }
5023 5057
5024 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { 5058 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
5025 return [self currentLogoAnimationControllerOwner]; 5059 return [self currentLogoAnimationControllerOwner];
5026 } 5060 }
5027 5061
5028 @end 5062 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698