| OLD | NEW |
| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 Hideable = 0, | 265 Hideable = 0, |
| 266 // This header stays on screen and doesn't overlap with the content. | 266 // This header stays on screen and doesn't overlap with the content. |
| 267 Visible, | 267 Visible, |
| 268 // This header stay on screen and covers part of the content. | 268 // This header stay on screen and covers part of the content. |
| 269 Overlap | 269 Overlap |
| 270 }; | 270 }; |
| 271 | 271 |
| 272 const CGFloat kIPadFindBarOverlap = 11; | 272 const CGFloat kIPadFindBarOverlap = 11; |
| 273 | 273 |
| 274 bool IsURLAllowedInIncognito(const GURL& url) { | 274 bool IsURLAllowedInIncognito(const GURL& url) { |
| 275 // Most URLs are allowed in incognito; the following are exceptions. | 275 // Most URLs are allowed in incognito; the following is an exception. |
| 276 if (!url.SchemeIs(kChromeUIScheme)) | 276 return !(url.SchemeIs(kChromeUIScheme) && url.host() == kChromeUIHistoryHost); |
| 277 return true; | |
| 278 std::string url_host = url.host(); | |
| 279 return url_host != kChromeUIHistoryHost && | |
| 280 url_host != kChromeUIHistoryFrameHost; | |
| 281 } | 277 } |
| 282 | 278 |
| 283 // Temporary key to use when storing native controllers vended to tabs before | 279 // Temporary key to use when storing native controllers vended to tabs before |
| 284 // they are added to the tab model. | 280 // they are added to the tab model. |
| 285 NSString* const kNativeControllerTemporaryKey = @"NativeControllerTemporaryKey"; | 281 NSString* const kNativeControllerTemporaryKey = @"NativeControllerTemporaryKey"; |
| 286 | 282 |
| 287 } // namespace | 283 } // namespace |
| 288 | 284 |
| 289 #pragma mark - HeaderDefinition helper | 285 #pragma mark - HeaderDefinition helper |
| 290 | 286 |
| (...skipping 2788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3079 NSString* filePath = [ExternalFileController pathForExternalFileURL:url]; | 3075 NSString* filePath = [ExternalFileController pathForExternalFileURL:url]; |
| 3080 if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { | 3076 if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { |
| 3081 nativeController = | 3077 nativeController = |
| 3082 [[ExternalFileController alloc] initWithURL:url | 3078 [[ExternalFileController alloc] initWithURL:url |
| 3083 browserState:_browserState]; | 3079 browserState:_browserState]; |
| 3084 } | 3080 } |
| 3085 } else { | 3081 } else { |
| 3086 DCHECK(![self hasControllerForURL:url]); | 3082 DCHECK(![self hasControllerForURL:url]); |
| 3087 // In any other case the PageNotAvailableController is returned. | 3083 // In any other case the PageNotAvailableController is returned. |
| 3088 nativeController = [[PageNotAvailableController alloc] initWithUrl:url]; | 3084 nativeController = [[PageNotAvailableController alloc] initWithUrl:url]; |
| 3089 if (url_host == kChromeUIHistoryFrameHost) { | |
| 3090 base::mac::ObjCCastStrict<PageNotAvailableController>(nativeController) | |
| 3091 .descriptionText = l10n_util::GetNSStringFWithFixup( | |
| 3092 IDS_IOS_HISTORY_URL_NOT_AVAILABLE, | |
| 3093 base::UTF8ToUTF16(kChromeUIHistoryURL), | |
| 3094 l10n_util::GetStringUTF16(IDS_HISTORY_SHOW_HISTORY)); | |
| 3095 } | |
| 3096 } | 3085 } |
| 3097 // If a native controller is vended before its tab is added to the tab model, | 3086 // If a native controller is vended before its tab is added to the tab model, |
| 3098 // use the temporary key and add it under the new tab's tabId in the | 3087 // use the temporary key and add it under the new tab's tabId in the |
| 3099 // TabModelObserver callback. This happens: | 3088 // TabModelObserver callback. This happens: |
| 3100 // - when there is no current tab (occurs when vending the NTP controller for | 3089 // - when there is no current tab (occurs when vending the NTP controller for |
| 3101 // the first tab that is opened), | 3090 // the first tab that is opened), |
| 3102 // - when the current tab's url doesn't match |url| (occurs when a native | 3091 // - when the current tab's url doesn't match |url| (occurs when a native |
| 3103 // controller is opened in a new tab) | 3092 // controller is opened in a new tab) |
| 3104 // - when the current tab's url matches |url| and there is already a native | 3093 // - when the current tab's url matches |url| and there is already a native |
| 3105 // controller of the appropriate type vended to it (occurs when a native | 3094 // controller of the appropriate type vended to it (occurs when a native |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3685 locationBarDidSubmitURL:url | 3674 locationBarDidSubmitURL:url |
| 3686 transition:transition | 3675 transition:transition |
| 3687 browserState:_browserState]; | 3676 browserState:_browserState]; |
| 3688 | 3677 |
| 3689 [_bookmarkInteractionController dismissBookmarkModalControllerAnimated:YES]; | 3678 [_bookmarkInteractionController dismissBookmarkModalControllerAnimated:YES]; |
| 3690 if (transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) { | 3679 if (transition & ui::PAGE_TRANSITION_FROM_ADDRESS_BAR) { |
| 3691 new_tab_page_uma::RecordActionFromOmnibox(_browserState, url, transition); | 3680 new_tab_page_uma::RecordActionFromOmnibox(_browserState, url, transition); |
| 3692 } | 3681 } |
| 3693 | 3682 |
| 3694 // NOTE: This check for the Crash Host URL is here to avoid the URL from | 3683 // NOTE: This check for the Crash Host URL is here to avoid the URL from |
| 3695 // ending up in the history causign the app to crash at every subsequent | 3684 // ending up in the history causing the app to crash at every subsequent |
| 3696 // restart. | 3685 // restart. |
| 3697 if (url.host() == kChromeUIBrowserCrashHost) { | 3686 if (url.host() == kChromeUIBrowserCrashHost) { |
| 3698 [self induceBrowserCrash]; | 3687 [self induceBrowserCrash]; |
| 3699 // In debug the app can continue working even after the CHECK. Adding a | 3688 // In debug the app can continue working even after the CHECK. Adding a |
| 3700 // return avoids the crash url to be added to the history. | 3689 // return avoids the crash url to be added to the history. |
| 3701 return; | 3690 return; |
| 3702 } | 3691 } |
| 3703 | 3692 |
| 3704 if (url == [_preloadController prerenderedURL]) { | 3693 if (url == [_preloadController prerenderedURL]) { |
| 3705 std::unique_ptr<web::WebState> newWebState = | 3694 std::unique_ptr<web::WebState> newWebState = |
| (...skipping 1461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5167 | 5156 |
| 5168 - (UIView*)voiceSearchButton { | 5157 - (UIView*)voiceSearchButton { |
| 5169 return _voiceSearchButton; | 5158 return _voiceSearchButton; |
| 5170 } | 5159 } |
| 5171 | 5160 |
| 5172 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5161 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
| 5173 return [self currentLogoAnimationControllerOwner]; | 5162 return [self currentLogoAnimationControllerOwner]; |
| 5174 } | 5163 } |
| 5175 | 5164 |
| 5176 @end | 5165 @end |
| OLD | NEW |