| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 #include "ios/chrome/browser/pref_names.h" | 70 #include "ios/chrome/browser/pref_names.h" |
| 71 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h" | 71 #include "ios/chrome/browser/reading_list/reading_list_model_factory.h" |
| 72 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" | 72 #include "ios/chrome/browser/search_engines/template_url_service_factory.h" |
| 73 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" | 73 #include "ios/chrome/browser/sessions/ios_chrome_tab_restore_service_factory.h" |
| 74 #include "ios/chrome/browser/sessions/tab_restore_service_delegate_impl_ios.h" | 74 #include "ios/chrome/browser/sessions/tab_restore_service_delegate_impl_ios.h" |
| 75 #include "ios/chrome/browser/sessions/tab_restore_service_delegate_impl_ios_fact
ory.h" | 75 #include "ios/chrome/browser/sessions/tab_restore_service_delegate_impl_ios_fact
ory.h" |
| 76 #import "ios/chrome/browser/snapshots/snapshot_cache.h" | 76 #import "ios/chrome/browser/snapshots/snapshot_cache.h" |
| 77 #import "ios/chrome/browser/snapshots/snapshot_overlay.h" | 77 #import "ios/chrome/browser/snapshots/snapshot_overlay.h" |
| 78 #import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h" | 78 #import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h" |
| 79 #import "ios/chrome/browser/storekit_launcher.h" | 79 #import "ios/chrome/browser/storekit_launcher.h" |
| 80 #import "ios/chrome/browser/tabs/legacy_tab_helper.h" |
| 80 #import "ios/chrome/browser/tabs/tab.h" | 81 #import "ios/chrome/browser/tabs/tab.h" |
| 81 #import "ios/chrome/browser/tabs/tab_dialog_delegate.h" | 82 #import "ios/chrome/browser/tabs/tab_dialog_delegate.h" |
| 82 #import "ios/chrome/browser/tabs/tab_headers_delegate.h" | 83 #import "ios/chrome/browser/tabs/tab_headers_delegate.h" |
| 83 #import "ios/chrome/browser/tabs/tab_model.h" | 84 #import "ios/chrome/browser/tabs/tab_model.h" |
| 84 #import "ios/chrome/browser/tabs/tab_model_observer.h" | 85 #import "ios/chrome/browser/tabs/tab_model_observer.h" |
| 85 #import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h" | 86 #import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h" |
| 86 #import "ios/chrome/browser/ui/activity_services/chrome_activity_item_thumbnail_
generator.h" | 87 #import "ios/chrome/browser/ui/activity_services/chrome_activity_item_thumbnail_
generator.h" |
| 87 #import "ios/chrome/browser/ui/activity_services/share_protocol.h" | 88 #import "ios/chrome/browser/ui/activity_services/share_protocol.h" |
| 88 #import "ios/chrome/browser/ui/activity_services/share_to_data.h" | 89 #import "ios/chrome/browser/ui/activity_services/share_to_data.h" |
| 89 #import "ios/chrome/browser/ui/activity_services/share_to_data_builder.h" | 90 #import "ios/chrome/browser/ui/activity_services/share_to_data_builder.h" |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 // Shows an alert with the given title and message id. | 669 // Shows an alert with the given title and message id. |
| 669 - (void)showErrorAlert:(int)titleMessageId message:(int)messageId; | 670 - (void)showErrorAlert:(int)titleMessageId message:(int)messageId; |
| 670 // Helper method displaying an alert with the given title and message. | 671 // Helper method displaying an alert with the given title and message. |
| 671 // Dismisses previous alert if it has not been dismissed yet. | 672 // Dismisses previous alert if it has not been dismissed yet. |
| 672 - (void)showErrorAlertWithStringTitle:(NSString*)title | 673 - (void)showErrorAlertWithStringTitle:(NSString*)title |
| 673 message:(NSString*)message; | 674 message:(NSString*)message; |
| 674 // Shows a self-dismissing snackbar displaying |message|. | 675 // Shows a self-dismissing snackbar displaying |message|. |
| 675 - (void)showSnackbar:(NSString*)message; | 676 - (void)showSnackbar:(NSString*)message; |
| 676 // Induces an intentional crash in the browser process. | 677 // Induces an intentional crash in the browser process. |
| 677 - (void)induceBrowserCrash; | 678 - (void)induceBrowserCrash; |
| 678 // Returns Tab that corresponds to the given |webState|. | |
| 679 - (Tab*)tabForWebState:(web::WebState*)webState; | |
| 680 // Saves the image or display error message, based on privacy settings. | 679 // Saves the image or display error message, based on privacy settings. |
| 681 - (void)managePermissionAndSaveImage:(NSData*)data; | 680 - (void)managePermissionAndSaveImage:(NSData*)data; |
| 682 // Saves the image. In order to keep the metadata of the image, the image is | 681 // Saves the image. In order to keep the metadata of the image, the image is |
| 683 // saved as a temporary file on disk then saved in photos. | 682 // saved as a temporary file on disk then saved in photos. |
| 684 // This should be called on FILE thread. | 683 // This should be called on FILE thread. |
| 685 - (void)saveImage:(NSData*)data; | 684 - (void)saveImage:(NSData*)data; |
| 686 // Called when Chrome has been denied access to the photos or videos and the | 685 // Called when Chrome has been denied access to the photos or videos and the |
| 687 // user can change it. | 686 // user can change it. |
| 688 // Shows a privacy alert on the main queue, allowing the user to go to Chrome's | 687 // Shows a privacy alert on the main queue, allowing the user to go to Chrome's |
| 689 // settings. Dismiss previous alert if it has not been dismissed yet. | 688 // settings. Dismiss previous alert if it has not been dismissed yet. |
| (...skipping 1636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2326 - (web::WebState*)webState:(web::WebState*)webState | 2325 - (web::WebState*)webState:(web::WebState*)webState |
| 2327 openURLWithParams:(const web::WebState::OpenURLParams&)params { | 2326 openURLWithParams:(const web::WebState::OpenURLParams&)params { |
| 2328 switch (params.disposition) { | 2327 switch (params.disposition) { |
| 2329 case WindowOpenDisposition::NEW_FOREGROUND_TAB: | 2328 case WindowOpenDisposition::NEW_FOREGROUND_TAB: |
| 2330 case WindowOpenDisposition::NEW_BACKGROUND_TAB: { | 2329 case WindowOpenDisposition::NEW_BACKGROUND_TAB: { |
| 2331 Tab* tab = [[self tabModel] | 2330 Tab* tab = [[self tabModel] |
| 2332 insertOrUpdateTabWithURL:params.url | 2331 insertOrUpdateTabWithURL:params.url |
| 2333 referrer:params.referrer | 2332 referrer:params.referrer |
| 2334 transition:params.transition | 2333 transition:params.transition |
| 2335 windowName:nil | 2334 windowName:nil |
| 2336 opener:[self tabForWebState:webState] | 2335 opener:LegacyTabHelper::GetTabForWebState(webState) |
| 2337 openedByDOM:NO | 2336 openedByDOM:NO |
| 2338 atIndex:TabModelConstants::kTabPositionAutomatically | 2337 atIndex:TabModelConstants::kTabPositionAutomatically |
| 2339 inBackground:(params.disposition == | 2338 inBackground:(params.disposition == |
| 2340 WindowOpenDisposition::NEW_BACKGROUND_TAB)]; | 2339 WindowOpenDisposition::NEW_BACKGROUND_TAB)]; |
| 2341 return tab.webState; | 2340 return tab.webState; |
| 2342 } | 2341 } |
| 2343 case WindowOpenDisposition::CURRENT_TAB: { | 2342 case WindowOpenDisposition::CURRENT_TAB: { |
| 2344 web::NavigationManager::WebLoadParams loadParams(params.url); | 2343 web::NavigationManager::WebLoadParams loadParams(params.url); |
| 2345 loadParams.referrer = params.referrer; | 2344 loadParams.referrer = params.referrer; |
| 2346 loadParams.transition_type = params.transition; | 2345 loadParams.transition_type = params.transition; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2501 } | 2500 } |
| 2502 | 2501 |
| 2503 [_contextMenuCoordinator start]; | 2502 [_contextMenuCoordinator start]; |
| 2504 return YES; | 2503 return YES; |
| 2505 } | 2504 } |
| 2506 | 2505 |
| 2507 - (void)webState:(web::WebState*)webState | 2506 - (void)webState:(web::WebState*)webState |
| 2508 runRepostFormDialogWithCompletionHandler:(void (^)(BOOL))handler { | 2507 runRepostFormDialogWithCompletionHandler:(void (^)(BOOL))handler { |
| 2509 // Display the action sheet with the arrow pointing at the top center of the | 2508 // Display the action sheet with the arrow pointing at the top center of the |
| 2510 // web contents. | 2509 // web contents. |
| 2510 Tab* tab = LegacyTabHelper::GetTabForWebState(webState); |
| 2511 UIView* view = webState->GetView(); | 2511 UIView* view = webState->GetView(); |
| 2512 CGPoint dialogLocation = | 2512 CGPoint dialogLocation = |
| 2513 CGPointMake(CGRectGetMidX(view.frame), | 2513 CGPointMake(CGRectGetMidX(view.frame), |
| 2514 CGRectGetMinY(view.frame) + | 2514 CGRectGetMinY(view.frame) + [self headerHeightForTab:tab]); |
| 2515 [self headerHeightForTab:[self tabForWebState:webState]]); | |
| 2516 auto helper = RepostFormTabHelper::FromWebState(webState); | 2515 auto helper = RepostFormTabHelper::FromWebState(webState); |
| 2517 helper->PresentDialog(dialogLocation, base::BindBlock(^(bool shouldContinue) { | 2516 helper->PresentDialog(dialogLocation, base::BindBlock(^(bool shouldContinue) { |
| 2518 handler(shouldContinue); | 2517 handler(shouldContinue); |
| 2519 })); | 2518 })); |
| 2520 } | 2519 } |
| 2521 | 2520 |
| 2522 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState: | 2521 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState: |
| 2523 (web::WebState*)webState { | 2522 (web::WebState*)webState { |
| 2524 return _javaScriptDialogPresenter.get(); | 2523 return _javaScriptDialogPresenter.get(); |
| 2525 } | 2524 } |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3585 [_preloadController cancelPrerender]; | 3584 [_preloadController cancelPrerender]; |
| 3586 DCHECK([_model currentTab]); | 3585 DCHECK([_model currentTab]); |
| 3587 [[_model currentTab].webController executeUserJavaScript:script | 3586 [[_model currentTab].webController executeUserJavaScript:script |
| 3588 completionHandler:nil]; | 3587 completionHandler:nil]; |
| 3589 } | 3588 } |
| 3590 | 3589 |
| 3591 - (web::WebState*)currentWebState { | 3590 - (web::WebState*)currentWebState { |
| 3592 return [[_model currentTab] webState]; | 3591 return [[_model currentTab] webState]; |
| 3593 } | 3592 } |
| 3594 | 3593 |
| 3595 - (Tab*)tabForWebState:(web::WebState*)webState { | |
| 3596 for (Tab* tab in _model.get()) { | |
| 3597 if (tab.webState == webState) | |
| 3598 return tab; | |
| 3599 } | |
| 3600 return nil; | |
| 3601 } | |
| 3602 | |
| 3603 // This is called from within an animation block. | 3594 // This is called from within an animation block. |
| 3604 - (void)toolbarHeightChanged { | 3595 - (void)toolbarHeightChanged { |
| 3605 if ([self headerHeight] != 0) { | 3596 if ([self headerHeight] != 0) { |
| 3606 // Ensure full screen height is updated. | 3597 // Ensure full screen height is updated. |
| 3607 Tab* currentTab = [_model currentTab]; | 3598 Tab* currentTab = [_model currentTab]; |
| 3608 BOOL visible = self.isToolbarOnScreen; | 3599 BOOL visible = self.isToolbarOnScreen; |
| 3609 [currentTab updateFullscreenWithToolbarVisible:visible]; | 3600 [currentTab updateFullscreenWithToolbarVisible:visible]; |
| 3610 } | 3601 } |
| 3611 } | 3602 } |
| 3612 | 3603 |
| (...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4962 | 4953 |
| 4963 - (UIView*)voiceSearchButton { | 4954 - (UIView*)voiceSearchButton { |
| 4964 return _voiceSearchButton; | 4955 return _voiceSearchButton; |
| 4965 } | 4956 } |
| 4966 | 4957 |
| 4967 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 4958 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
| 4968 return [self currentLogoAnimationControllerOwner]; | 4959 return [self currentLogoAnimationControllerOwner]; |
| 4969 } | 4960 } |
| 4970 | 4961 |
| 4971 @end | 4962 @end |
| OLD | NEW |