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

Side by Side Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2784843002: Reading List: Mark entry read when opening external app. (Closed)
Patch Set: feedback Created 3 years, 8 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
« no previous file with comments | « ios/web/public/web_state/ui/crw_web_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/web/web_state/ui/crw_web_controller.h" 5 #import "ios/web/web_state/ui/crw_web_controller.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #import <objc/runtime.h> 9 #import <objc/runtime.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 3045 matching lines...) Expand 10 before | Expand all | Expand 10 after
3056 } 3056 }
3057 3057
3058 // If the URL doesn't look like one we can show, try to open the link with an 3058 // If the URL doesn't look like one we can show, try to open the link with an
3059 // external application. 3059 // external application.
3060 // TODO(droger): Check transition type before opening an external 3060 // TODO(droger): Check transition type before opening an external
3061 // application? For example, only allow it for TYPED and LINK transitions. 3061 // application? For example, only allow it for TYPED and LINK transitions.
3062 if (![CRWWebController webControllerCanShow:requestURL]) { 3062 if (![CRWWebController webControllerCanShow:requestURL]) {
3063 if (![self shouldOpenExternalURLForNavigationAction:action]) { 3063 if (![self shouldOpenExternalURLForNavigationAction:action]) {
3064 return NO; 3064 return NO;
3065 } 3065 }
3066 web::NavigationItem* item = self.currentNavItem;
3067 GURL sourceURL = item ? item->GetOriginalRequestURL() : GURL::EmptyGURL();
3066 3068
3067 // Stop load if navigation is believed to be happening on the main frame. 3069 // Stop load if navigation is believed to be happening on the main frame.
3068 if ([self isMainFrameNavigationAction:action]) 3070 if ([self isMainFrameNavigationAction:action])
3069 [self stopLoading]; 3071 [self stopLoading];
3070 3072
3071 // Purge web view if last committed URL is different from the document URL. 3073 // Purge web view if last committed URL is different from the document URL.
3072 // This can happen if external URL was added to the navigation stack and was 3074 // This can happen if external URL was added to the navigation stack and was
3073 // loaded using Go Back or Go Forward navigation (in which case document URL 3075 // loaded using Go Back or Go Forward navigation (in which case document URL
3074 // will point to the previous page). If this is the first load for a 3076 // will point to the previous page). If this is the first load for a
3075 // NavigationManager, there will be no last committed item, so check here. 3077 // NavigationManager, there will be no last committed item, so check here.
3076 web::NavigationItem* lastCommittedItem = 3078 web::NavigationItem* lastCommittedItem =
3077 self.webState->GetNavigationManager()->GetLastCommittedItem(); 3079 self.webState->GetNavigationManager()->GetLastCommittedItem();
3078 if (lastCommittedItem) { 3080 if (lastCommittedItem) {
3079 GURL lastCommittedURL = lastCommittedItem->GetURL(); 3081 GURL lastCommittedURL = lastCommittedItem->GetURL();
3080 if (lastCommittedURL != _documentURL) { 3082 if (lastCommittedURL != _documentURL) {
3081 [self requirePageReconstruction]; 3083 [self requirePageReconstruction];
3082 [self setDocumentURL:lastCommittedURL]; 3084 [self setDocumentURL:lastCommittedURL];
3083 } 3085 }
3084 } 3086 }
3085 3087
3086 if ([_delegate openExternalURL:requestURL 3088 if ([_delegate openExternalURL:requestURL
3089 sourceURL:sourceURL
3087 linkClicked:isNavigationTypeLinkActivated]) { 3090 linkClicked:isNavigationTypeLinkActivated]) {
3088 // Record the URL so that errors reported following the 'NO' reply can be 3091 // Record the URL so that errors reported following the 'NO' reply can be
3089 // safely ignored. 3092 // safely ignored.
3090 [_openedApplicationURL addObject:request.URL]; 3093 [_openedApplicationURL addObject:request.URL];
3091 if ([self shouldClosePageOnNativeApplicationLoad]) 3094 if ([self shouldClosePageOnNativeApplicationLoad])
3092 _webStateImpl->CloseWebState(); 3095 _webStateImpl->CloseWebState();
3093 } 3096 }
3094 return NO; 3097 return NO;
3095 } 3098 }
3096 3099
(...skipping 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after
5087 - (void)simulateLoadRequestWithURL:(const GURL&)URL { 5090 - (void)simulateLoadRequestWithURL:(const GURL&)URL {
5088 _lastRegisteredRequestURL = URL; 5091 _lastRegisteredRequestURL = URL;
5089 _loadPhase = web::LOAD_REQUESTED; 5092 _loadPhase = web::LOAD_REQUESTED;
5090 } 5093 }
5091 5094
5092 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action { 5095 - (NSString*)referrerFromNavigationAction:(WKNavigationAction*)action {
5093 return [action.request valueForHTTPHeaderField:kReferrerHeaderName]; 5096 return [action.request valueForHTTPHeaderField:kReferrerHeaderName];
5094 } 5097 }
5095 5098
5096 @end 5099 @end
OLDNEW
« no previous file with comments | « ios/web/public/web_state/ui/crw_web_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698