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

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

Issue 2800673002: [iOS Reading List] Only allow offline URL when the offline file exists. (Closed)
Patch Set: Add comment 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
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 2952 matching lines...) Expand 10 before | Expand all | Expand 10 after
2963 url:url 2963 url:url
2964 error:error 2964 error:error
2965 isPost:isPost 2965 isPost:isPost
2966 isIncognito:_isOffTheRecord] autorelease]; 2966 isIncognito:_isOffTheRecord] autorelease];
2967 [self setOverScrollActionControllerToStaticNativeContent:errorPageContent]; 2967 [self setOverScrollActionControllerToStaticNativeContent:errorPageContent];
2968 return errorPageContent; 2968 return errorPageContent;
2969 } 2969 }
2970 2970
2971 - (BOOL)hasControllerForURL:(const GURL&)url { 2971 - (BOOL)hasControllerForURL:(const GURL&)url {
2972 std::string host(url.host()); 2972 std::string host(url.host());
2973 if (host == kChromeUIOfflineHost) {
2974 // Only allow offline URL that are fully specified.
2975 return reading_list::IsOfflineURLValid(
2976 url, ReadingListModelFactory::GetForBrowserState(_browserState));
2977 }
2973 2978
2974 return host == kChromeUINewTabHost || host == kChromeUIBookmarksHost || 2979 return host == kChromeUINewTabHost || host == kChromeUIBookmarksHost ||
2975 host == kChromeUITermsHost || host == kChromeUIOfflineHost; 2980 host == kChromeUITermsHost;
2976 } 2981 }
2977 2982
2978 - (id<CRWNativeContent>)controllerForURL:(const GURL&)url 2983 - (id<CRWNativeContent>)controllerForURL:(const GURL&)url
2979 webState:(web::WebState*)webState { 2984 webState:(web::WebState*)webState {
2980 DCHECK(url.SchemeIs(kChromeUIScheme)); 2985 DCHECK(url.SchemeIs(kChromeUIScheme));
2981 2986
2982 id<CRWNativeContent> nativeController = nil; 2987 id<CRWNativeContent> nativeController = nil;
2983 std::string url_host = url.host(); 2988 std::string url_host = url.host();
2984 if (url_host == kChromeUINewTabHost || url_host == kChromeUIBookmarksHost) { 2989 if (url_host == kChromeUINewTabHost || url_host == kChromeUIBookmarksHost) {
2985 NewTabPageController* pageController = 2990 NewTabPageController* pageController =
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3018 3023
3019 StaticHtmlNativeContent* staticNativeController = 3024 StaticHtmlNativeContent* staticNativeController =
3020 [[[StaticHtmlNativeContent alloc] 3025 [[[StaticHtmlNativeContent alloc]
3021 initWithResourcePathResource:base::SysUTF8ToNSString(filename) 3026 initWithResourcePathResource:base::SysUTF8ToNSString(filename)
3022 loader:self 3027 loader:self
3023 browserState:_browserState 3028 browserState:_browserState
3024 url:GURL(kChromeUITermsURL)] autorelease]; 3029 url:GURL(kChromeUITermsURL)] autorelease];
3025 [self setOverScrollActionControllerToStaticNativeContent: 3030 [self setOverScrollActionControllerToStaticNativeContent:
3026 staticNativeController]; 3031 staticNativeController];
3027 nativeController = staticNativeController; 3032 nativeController = staticNativeController;
3028 } else if (url_host == kChromeUIOfflineHost) { 3033 } else if (url_host == kChromeUIOfflineHost &&
3034 [self hasControllerForURL:url]) {
Eugene But (OOO till 7-30) 2017/04/07 15:17:52 Should |[self hasControllerForURL:url]| be inside
Olivier 2017/04/07 15:44:27 This is possible if the user taps a wrong URL. In
3029 StaticHtmlNativeContent* staticNativeController = 3035 StaticHtmlNativeContent* staticNativeController =
3030 [[[OfflinePageNativeContent alloc] initWithLoader:self 3036 [[[OfflinePageNativeContent alloc] initWithLoader:self
3031 browserState:_browserState 3037 browserState:_browserState
3032 webState:webState 3038 webState:webState
3033 URL:url] autorelease]; 3039 URL:url] autorelease];
3034 [self setOverScrollActionControllerToStaticNativeContent: 3040 [self setOverScrollActionControllerToStaticNativeContent:
3035 staticNativeController]; 3041 staticNativeController];
3036 nativeController = staticNativeController; 3042 nativeController = staticNativeController;
3037 } else if (url_host == kChromeUIExternalFileHost) { 3043 } else if (url_host == kChromeUIExternalFileHost) {
3038 // Return an instance of the |ExternalFileController| only if the file is 3044 // Return an instance of the |ExternalFileController| only if the file is
(...skipping 2085 matching lines...) Expand 10 before | Expand all | Expand 10 after
5124 5130
5125 - (UIView*)voiceSearchButton { 5131 - (UIView*)voiceSearchButton {
5126 return _voiceSearchButton; 5132 return _voiceSearchButton;
5127 } 5133 }
5128 5134
5129 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { 5135 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
5130 return [self currentLogoAnimationControllerOwner]; 5136 return [self currentLogoAnimationControllerOwner];
5131 } 5137 }
5132 5138
5133 @end 5139 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698