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> |
11 #import <QuartzCore/QuartzCore.h> | 11 #import <QuartzCore/QuartzCore.h> |
12 | 12 |
13 #include <stdint.h> | 13 #include <stdint.h> |
14 #include <cmath> | 14 #include <cmath> |
15 #include <memory> | 15 #include <memory> |
16 | 16 |
17 #include "base/base64.h" | 17 #include "base/base64.h" |
18 #include "base/command_line.h" | 18 #include "base/command_line.h" |
19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
20 #include "base/format_macros.h" | 20 #include "base/format_macros.h" |
21 #include "base/i18n/rtl.h" | 21 #include "base/i18n/rtl.h" |
22 #include "base/ios/block_types.h" | 22 #include "base/ios/block_types.h" |
23 #include "base/ios/ios_util.h" | 23 #include "base/ios/ios_util.h" |
24 #include "base/ios/weak_nsobject.h" | 24 #include "base/ios/weak_nsobject.h" |
25 #include "base/logging.h" | 25 #include "base/logging.h" |
26 #include "base/mac/bind_objc_block.h" | 26 #include "base/mac/bind_objc_block.h" |
27 #include "base/mac/bundle_locations.h" | 27 #include "base/mac/bundle_locations.h" |
28 #include "base/mac/foundation_util.h" | 28 #include "base/mac/foundation_util.h" |
29 #include "base/mac/objc_property_releaser.h" | 29 |
30 #import "base/mac/scoped_block.h" | 30 #import "base/mac/scoped_block.h" |
31 #import "base/mac/scoped_nsobject.h" | 31 #import "base/mac/scoped_nsobject.h" |
32 #include "base/macros.h" | 32 #include "base/macros.h" |
33 #include "base/memory/ptr_util.h" | 33 #include "base/memory/ptr_util.h" |
34 #include "base/metrics/histogram_macros.h" | 34 #include "base/metrics/histogram_macros.h" |
35 #include "base/metrics/user_metrics.h" | 35 #include "base/metrics/user_metrics.h" |
36 #include "base/metrics/user_metrics_action.h" | 36 #include "base/metrics/user_metrics_action.h" |
37 #include "base/strings/sys_string_conversions.h" | 37 #include "base/strings/sys_string_conversions.h" |
38 #include "base/strings/utf_string_conversions.h" | 38 #include "base/strings/utf_string_conversions.h" |
39 #include "base/threading/sequenced_worker_pool.h" | 39 #include "base/threading/sequenced_worker_pool.h" |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 #include "net/base/mime_util.h" | 193 #include "net/base/mime_util.h" |
194 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 194 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
195 #include "net/ssl/ssl_info.h" | 195 #include "net/ssl/ssl_info.h" |
196 #include "net/url_request/url_request_context_getter.h" | 196 #include "net/url_request/url_request_context_getter.h" |
197 #include "third_party/google_toolbox_for_mac/src/iPhone/GTMUIImage+Resize.h" | 197 #include "third_party/google_toolbox_for_mac/src/iPhone/GTMUIImage+Resize.h" |
198 #include "ui/base/l10n/l10n_util.h" | 198 #include "ui/base/l10n/l10n_util.h" |
199 #include "ui/base/l10n/l10n_util_mac.h" | 199 #include "ui/base/l10n/l10n_util_mac.h" |
200 #include "ui/base/page_transition_types.h" | 200 #include "ui/base/page_transition_types.h" |
201 #include "url/gurl.h" | 201 #include "url/gurl.h" |
202 | 202 |
| 203 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 204 #error "This file requires ARC support." |
| 205 #endif |
| 206 |
203 using base::UserMetricsAction; | 207 using base::UserMetricsAction; |
204 using bookmarks::BookmarkNode; | 208 using bookmarks::BookmarkNode; |
205 | 209 |
206 class BrowserBookmarkModelBridge; | 210 class BrowserBookmarkModelBridge; |
207 class InfoBarContainerDelegateIOS; | 211 class InfoBarContainerDelegateIOS; |
208 | 212 |
209 namespace ios_internal { | 213 namespace ios_internal { |
210 NSString* const kPageInfoWillShowNotification = | 214 NSString* const kPageInfoWillShowNotification = |
211 @"kPageInfoWillShowNotification"; | 215 @"kPageInfoWillShowNotification"; |
212 NSString* const kPageInfoWillHideNotification = | 216 NSString* const kPageInfoWillHideNotification = |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 // Notifies the toolbar menu of reading list changes. | 487 // Notifies the toolbar menu of reading list changes. |
484 base::scoped_nsobject<ReadingListMenuNotifier> _readingListMenuNotifier; | 488 base::scoped_nsobject<ReadingListMenuNotifier> _readingListMenuNotifier; |
485 | 489 |
486 // The sender for the last received IDC_VOICE_SEARCH command. | 490 // The sender for the last received IDC_VOICE_SEARCH command. |
487 base::WeakNSObject<UIView> _voiceSearchButton; | 491 base::WeakNSObject<UIView> _voiceSearchButton; |
488 | 492 |
489 // Coordinator for displaying alerts. | 493 // Coordinator for displaying alerts. |
490 base::scoped_nsobject<AlertCoordinator> _alertCoordinator; | 494 base::scoped_nsobject<AlertCoordinator> _alertCoordinator; |
491 | 495 |
492 // Releaser for properties that aren't backed by scoped_nsobjects. | 496 // Releaser for properties that aren't backed by scoped_nsobjects. |
493 base::mac::ObjCPropertyReleaser _propertyReleaser_BrowserViewController; | |
494 } | 497 } |
495 | 498 |
496 // The browser's side swipe controller. Lazily instantiated on the first call. | 499 // The browser's side swipe controller. Lazily instantiated on the first call. |
497 @property(nonatomic, retain, readonly) SideSwipeController* sideSwipeController; | 500 @property(nonatomic, strong, readonly) SideSwipeController* sideSwipeController; |
498 // The browser's preload controller. | 501 // The browser's preload controller. |
499 @property(nonatomic, retain, readonly) PreloadController* preloadController; | 502 @property(nonatomic, strong, readonly) PreloadController* preloadController; |
500 // The dialog presenter for this BVC's tab model. | 503 // The dialog presenter for this BVC's tab model. |
501 @property(nonatomic, retain, readonly) DialogPresenter* dialogPresenter; | 504 @property(nonatomic, strong, readonly) DialogPresenter* dialogPresenter; |
502 // The object that manages keyboard commands on behalf of the BVC. | 505 // The object that manages keyboard commands on behalf of the BVC. |
503 @property(nonatomic, retain, readonly) KeyCommandsProvider* keyCommandsProvider; | 506 @property(nonatomic, strong, readonly) KeyCommandsProvider* keyCommandsProvider; |
504 // Whether the current tab can enable the reader mode menu item. | 507 // Whether the current tab can enable the reader mode menu item. |
505 @property(nonatomic, assign, readonly) BOOL canUseReaderMode; | 508 @property(nonatomic, assign, readonly) BOOL canUseReaderMode; |
506 // Whether the current tab can enable the request desktop menu item. | 509 // Whether the current tab can enable the request desktop menu item. |
507 @property(nonatomic, assign, readonly) BOOL canUseDesktopUserAgent; | 510 @property(nonatomic, assign, readonly) BOOL canUseDesktopUserAgent; |
508 // Whether the sharing menu should be enabled. | 511 // Whether the sharing menu should be enabled. |
509 @property(nonatomic, assign, readonly) BOOL canShowShareMenu; | 512 @property(nonatomic, assign, readonly) BOOL canShowShareMenu; |
510 // Helper method to check web controller canShowFindBar method. | 513 // Helper method to check web controller canShowFindBar method. |
511 @property(nonatomic, assign, readonly) BOOL canShowFindBar; | 514 @property(nonatomic, assign, readonly) BOOL canShowFindBar; |
512 // Whether the controller's view is currently available. | 515 // Whether the controller's view is currently available. |
513 // YES from viewWillAppear to viewWillDisappear. | 516 // YES from viewWillAppear to viewWillDisappear. |
514 @property(nonatomic, assign, getter=isVisible) BOOL visible; | 517 @property(nonatomic, assign, getter=isVisible) BOOL visible; |
515 // Whether the controller's view is currently visible. | 518 // Whether the controller's view is currently visible. |
516 // YES from viewDidAppear to viewWillDisappear. | 519 // YES from viewDidAppear to viewWillDisappear. |
517 @property(nonatomic, assign) BOOL viewVisible; | 520 @property(nonatomic, assign) BOOL viewVisible; |
518 // Whether the controller is currently dismissing a presented view controller. | 521 // Whether the controller is currently dismissing a presented view controller. |
519 @property(nonatomic, assign, getter=isDismissingModal) BOOL dismissingModal; | 522 @property(nonatomic, assign, getter=isDismissingModal) BOOL dismissingModal; |
520 // Returns YES if the toolbar has not been scrolled out by fullscreen. | 523 // Returns YES if the toolbar has not been scrolled out by fullscreen. |
521 @property(nonatomic, assign, readonly, getter=isToolbarOnScreen) | 524 @property(nonatomic, assign, readonly, getter=isToolbarOnScreen) |
522 BOOL toolbarOnScreen; | 525 BOOL toolbarOnScreen; |
523 // Whether a new tab animation is occurring. | 526 // Whether a new tab animation is occurring. |
524 @property(nonatomic, assign, readonly, getter=isInNewTabAnimation) | 527 @property(nonatomic, assign, readonly, getter=isInNewTabAnimation) |
525 BOOL inNewTabAnimation; | 528 BOOL inNewTabAnimation; |
526 // Whether BVC prefers to hide the status bar. This value is used to determine | 529 // Whether BVC prefers to hide the status bar. This value is used to determine |
527 // the response from the |prefersStatusBarHidden| method. | 530 // the response from the |prefersStatusBarHidden| method. |
528 @property(nonatomic, assign) BOOL hideStatusBar; | 531 @property(nonatomic, assign) BOOL hideStatusBar; |
529 // Whether the VoiceSearchBar should be displayed. | 532 // Whether the VoiceSearchBar should be displayed. |
530 @property(nonatomic, readonly) BOOL shouldShowVoiceSearchBar; | 533 @property(nonatomic, readonly) BOOL shouldShowVoiceSearchBar; |
531 // Coordinator for displaying a modal overlay with activity indicator to prevent | 534 // Coordinator for displaying a modal overlay with activity indicator to prevent |
532 // the user from interacting with the browser view. | 535 // the user from interacting with the browser view. |
533 @property(nonatomic, retain) | 536 @property(nonatomic, strong) |
534 ActivityOverlayCoordinator* activityOverlayCoordinator; | 537 ActivityOverlayCoordinator* activityOverlayCoordinator; |
535 | 538 |
536 // The user agent type used to load the currently visible page. User agent type | 539 // The user agent type used to load the currently visible page. User agent type |
537 // is NONE if there is no visible page or visible page is a native page. | 540 // is NONE if there is no visible page or visible page is a native page. |
538 @property(nonatomic, assign, readonly) web::UserAgentType userAgentType; | 541 @property(nonatomic, assign, readonly) web::UserAgentType userAgentType; |
539 | 542 |
540 // BVC initialization: | 543 // BVC initialization: |
541 // If the BVC is initialized with a valid browser state & tab model immediately, | 544 // If the BVC is initialized with a valid browser state & tab model immediately, |
542 // the path is straightforward: functionality is enabled, and the UI is built | 545 // the path is straightforward: functionality is enabled, and the UI is built |
543 // when -viewDidLoad is called. | 546 // when -viewDidLoad is called. |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
818 *arrow_half_width = 0; | 821 *arrow_half_width = 0; |
819 *bar_height = animation.CurrentValueBetween(0, bar_target_height); | 822 *bar_height = animation.CurrentValueBetween(0, bar_target_height); |
820 } | 823 } |
821 | 824 |
822 void InfoBarContainerStateChanged(bool is_animating) override { | 825 void InfoBarContainerStateChanged(bool is_animating) override { |
823 [controller_ infoBarContainerStateChanged:is_animating]; | 826 [controller_ infoBarContainerStateChanged:is_animating]; |
824 } | 827 } |
825 | 828 |
826 bool DrawInfoBarArrows(int* x) const override { return false; } | 829 bool DrawInfoBarArrows(int* x) const override { return false; } |
827 | 830 |
828 BrowserViewController* controller_; // weak | 831 __weak BrowserViewController* controller_; |
829 }; | 832 }; |
830 | 833 |
831 // Called from the BrowserBookmarkModelBridge from C++ -> ObjC. | 834 // Called from the BrowserBookmarkModelBridge from C++ -> ObjC. |
832 @interface BrowserViewController (BookmarkBridgeMethods) | 835 @interface BrowserViewController (BookmarkBridgeMethods) |
833 // If a bookmark matching the currentTab url is added or moved, update the | 836 // If a bookmark matching the currentTab url is added or moved, update the |
834 // toolbar state so the star highlight is in sync. | 837 // toolbar state so the star highlight is in sync. |
835 - (void)bookmarkNodeModified:(const BookmarkNode*)node; | 838 - (void)bookmarkNodeModified:(const BookmarkNode*)node; |
836 - (void)allBookmarksRemoved; | 839 - (void)allBookmarksRemoved; |
837 @end | 840 @end |
838 | 841 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 void BookmarkNodeChildrenReordered(bookmarks::BookmarkModel* model, | 880 void BookmarkNodeChildrenReordered(bookmarks::BookmarkModel* model, |
878 const BookmarkNode* node) override {} | 881 const BookmarkNode* node) override {} |
879 | 882 |
880 void BookmarkAllUserNodesRemoved( | 883 void BookmarkAllUserNodesRemoved( |
881 bookmarks::BookmarkModel* model, | 884 bookmarks::BookmarkModel* model, |
882 const std::set<GURL>& removed_urls) override { | 885 const std::set<GURL>& removed_urls) override { |
883 [owner_ allBookmarksRemoved]; | 886 [owner_ allBookmarksRemoved]; |
884 } | 887 } |
885 | 888 |
886 private: | 889 private: |
887 BrowserViewController* owner_; // Weak. | 890 __weak BrowserViewController* owner_; |
888 }; | 891 }; |
889 | 892 |
890 @implementation BrowserViewController | 893 @implementation BrowserViewController |
891 | 894 |
892 @synthesize contentArea = _contentArea; | 895 @synthesize contentArea = _contentArea; |
893 @synthesize typingShield = _typingShield; | 896 @synthesize typingShield = _typingShield; |
894 @synthesize active = _active; | 897 @synthesize active = _active; |
895 @synthesize visible = _visible; | 898 @synthesize visible = _visible; |
896 @synthesize viewVisible = _viewVisible; | 899 @synthesize viewVisible = _viewVisible; |
897 @synthesize dismissingModal = _dismissingModal; | 900 @synthesize dismissingModal = _dismissingModal; |
898 @synthesize hideStatusBar = _hideStatusBar; | 901 @synthesize hideStatusBar = _hideStatusBar; |
899 @synthesize activityOverlayCoordinator = _activityOverlayCoordinator; | 902 @synthesize activityOverlayCoordinator = _activityOverlayCoordinator; |
900 @synthesize presenting = _presenting; | 903 @synthesize presenting = _presenting; |
901 | 904 |
902 #pragma mark - Object lifecycle | 905 #pragma mark - Object lifecycle |
903 | 906 |
904 - (instancetype)initWithTabModel:(TabModel*)model | 907 - (instancetype)initWithTabModel:(TabModel*)model |
905 browserState:(ios::ChromeBrowserState*)browserState | 908 browserState:(ios::ChromeBrowserState*)browserState |
906 dependencyFactory: | 909 dependencyFactory: |
907 (BrowserViewControllerDependencyFactory*)factory { | 910 (BrowserViewControllerDependencyFactory*)factory { |
908 self = [super initWithNibName:nil bundle:base::mac::FrameworkBundle()]; | 911 self = [super initWithNibName:nil bundle:base::mac::FrameworkBundle()]; |
909 if (self) { | 912 if (self) { |
910 DCHECK(factory); | 913 DCHECK(factory); |
911 _propertyReleaser_BrowserViewController.Init(self, | 914 |
912 [BrowserViewController class]); | 915 _dependencyFactory.reset(factory); |
913 _dependencyFactory.reset([factory retain]); | 916 _nativeControllersForTabIDs.reset([NSMapTable strongToWeakObjectsMapTable]); |
914 _nativeControllersForTabIDs.reset( | |
915 [[NSMapTable strongToWeakObjectsMapTable] retain]); | |
916 _dialogPresenter.reset([[DialogPresenter alloc] initWithDelegate:self | 917 _dialogPresenter.reset([[DialogPresenter alloc] initWithDelegate:self |
917 presentingViewController:self]); | 918 presentingViewController:self]); |
918 _javaScriptDialogPresenter.reset( | 919 _javaScriptDialogPresenter.reset( |
919 new JavaScriptDialogPresenterImpl(_dialogPresenter)); | 920 new JavaScriptDialogPresenterImpl(_dialogPresenter)); |
920 _webStateDelegate.reset(new web::WebStateDelegateBridge(self)); | 921 _webStateDelegate.reset(new web::WebStateDelegateBridge(self)); |
921 // TODO(leng): Delay this. | 922 // TODO(leng): Delay this. |
922 [[UpgradeCenter sharedInstance] registerClient:self]; | 923 [[UpgradeCenter sharedInstance] registerClient:self]; |
923 _inNewTabAnimation = NO; | 924 _inNewTabAnimation = NO; |
924 if (model && browserState) | 925 if (model && browserState) |
925 [self updateWithTabModel:model browserState:browserState]; | 926 [self updateWithTabModel:model browserState:browserState]; |
(...skipping 23 matching lines...) Expand all Loading... |
949 if (_bookmarkModel) | 950 if (_bookmarkModel) |
950 _bookmarkModel->RemoveObserver(_bookmarkModelBridge.get()); | 951 _bookmarkModel->RemoveObserver(_bookmarkModelBridge.get()); |
951 [_model removeObserver:self]; | 952 [_model removeObserver:self]; |
952 [[UpgradeCenter sharedInstance] unregisterClient:self]; | 953 [[UpgradeCenter sharedInstance] unregisterClient:self]; |
953 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 954 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
954 [_toolbarController setDelegate:nil]; | 955 [_toolbarController setDelegate:nil]; |
955 if (_voiceSearchController.get()) | 956 if (_voiceSearchController.get()) |
956 _voiceSearchController->SetDelegate(nil); | 957 _voiceSearchController->SetDelegate(nil); |
957 [_rateThisAppDialog setDelegate:nil]; | 958 [_rateThisAppDialog setDelegate:nil]; |
958 [_model closeAllTabs]; | 959 [_model closeAllTabs]; |
959 [super dealloc]; | |
960 } | 960 } |
961 | 961 |
962 #pragma mark - Accessibility | 962 #pragma mark - Accessibility |
963 | 963 |
964 - (BOOL)accessibilityPerformEscape { | 964 - (BOOL)accessibilityPerformEscape { |
965 [self dismissPopups]; | 965 [self dismissPopups]; |
966 return YES; | 966 return YES; |
967 } | 967 } |
968 | 968 |
969 #pragma mark - Properties | 969 #pragma mark - Properties |
970 | 970 |
971 - (void)setActive:(BOOL)active { | 971 - (void)setActive:(BOOL)active { |
972 if (_active == active) { | 972 if (_active == active) { |
973 return; | 973 return; |
974 } | 974 } |
975 _active = active; | 975 _active = active; |
976 | 976 |
977 // If not active, display an activity indicator overlay over the view to | 977 // If not active, display an activity indicator overlay over the view to |
978 // prevent interaction with the web page. | 978 // prevent interaction with the web page. |
979 // TODO(crbug.com/637093): This coordinator should be managed by the | 979 // TODO(crbug.com/637093): This coordinator should be managed by the |
980 // coordinator used to present BrowserViewController, when implemented. | 980 // coordinator used to present BrowserViewController, when implemented. |
981 if (active) { | 981 if (active) { |
982 [self.activityOverlayCoordinator stop]; | 982 [self.activityOverlayCoordinator stop]; |
983 self.activityOverlayCoordinator = nil; | 983 self.activityOverlayCoordinator = nil; |
984 } else if (!self.activityOverlayCoordinator) { | 984 } else if (!self.activityOverlayCoordinator) { |
985 self.activityOverlayCoordinator = [[[ActivityOverlayCoordinator alloc] | 985 self.activityOverlayCoordinator = |
986 initWithBaseViewController:self] autorelease]; | 986 [[ActivityOverlayCoordinator alloc] initWithBaseViewController:self]; |
987 [self.activityOverlayCoordinator start]; | 987 [self.activityOverlayCoordinator start]; |
988 } | 988 } |
989 | 989 |
990 if (_browserState) { | 990 if (_browserState) { |
991 web::ActiveStateManager* active_state_manager = | 991 web::ActiveStateManager* active_state_manager = |
992 web::BrowserState::GetActiveStateManager(_browserState); | 992 web::BrowserState::GetActiveStateManager(_browserState); |
993 active_state_manager->SetActive(active); | 993 active_state_manager->SetActive(active); |
994 } | 994 } |
995 | 995 |
996 [_model setWebUsageEnabled:active]; | 996 [_model setWebUsageEnabled:active]; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 #pragma mark - UIViewController methods | 1165 #pragma mark - UIViewController methods |
1166 | 1166 |
1167 // Perform additional set up after loading the view, typically from a nib. | 1167 // Perform additional set up after loading the view, typically from a nib. |
1168 - (void)viewDidLoad { | 1168 - (void)viewDidLoad { |
1169 CGRect initialViewsRect = self.view.frame; | 1169 CGRect initialViewsRect = self.view.frame; |
1170 initialViewsRect.origin.y += StatusBarHeight(); | 1170 initialViewsRect.origin.y += StatusBarHeight(); |
1171 initialViewsRect.size.height -= StatusBarHeight(); | 1171 initialViewsRect.size.height -= StatusBarHeight(); |
1172 UIViewAutoresizing initialViewAutoresizing = | 1172 UIViewAutoresizing initialViewAutoresizing = |
1173 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; | 1173 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; |
1174 | 1174 |
1175 self.contentArea = [[[BrowserContainerView alloc] | 1175 self.contentArea = |
1176 initWithFrame:initialViewsRect] autorelease]; | 1176 [[BrowserContainerView alloc] initWithFrame:initialViewsRect]; |
1177 self.contentArea.autoresizingMask = initialViewAutoresizing; | 1177 self.contentArea.autoresizingMask = initialViewAutoresizing; |
1178 self.typingShield = | 1178 self.typingShield = [[UIButton alloc] initWithFrame:initialViewsRect]; |
1179 [[[UIButton alloc] initWithFrame:initialViewsRect] autorelease]; | |
1180 self.typingShield.autoresizingMask = initialViewAutoresizing; | 1179 self.typingShield.autoresizingMask = initialViewAutoresizing; |
1181 [self.typingShield addTarget:self | 1180 [self.typingShield addTarget:self |
1182 action:@selector(shieldWasTapped:) | 1181 action:@selector(shieldWasTapped:) |
1183 forControlEvents:UIControlEventTouchUpInside]; | 1182 forControlEvents:UIControlEventTouchUpInside]; |
1184 self.view.autoresizingMask = initialViewAutoresizing; | 1183 self.view.autoresizingMask = initialViewAutoresizing; |
1185 self.view.backgroundColor = [UIColor colorWithWhite:0.75 alpha:1.0]; | 1184 self.view.backgroundColor = [UIColor colorWithWhite:0.75 alpha:1.0]; |
1186 [self.view addSubview:self.contentArea]; | 1185 [self.view addSubview:self.contentArea]; |
1187 [self.view addSubview:self.typingShield]; | 1186 [self.view addSubview:self.typingShield]; |
1188 [super viewDidLoad]; | 1187 [super viewDidLoad]; |
1189 | 1188 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 return; | 1330 return; |
1332 | 1331 |
1333 // Record focused state. | 1332 // Record focused state. |
1334 BOOL isFocusedBeforeReshow = [_findBarController isFocused]; | 1333 BOOL isFocusedBeforeReshow = [_findBarController isFocused]; |
1335 | 1334 |
1336 [self hideFindBarWithAnimation:NO]; | 1335 [self hideFindBarWithAnimation:NO]; |
1337 | 1336 |
1338 base::WeakNSObject<BrowserViewController> weakSelf(self); | 1337 base::WeakNSObject<BrowserViewController> weakSelf(self); |
1339 void (^completion)(id<UIViewControllerTransitionCoordinatorContext>) = ^( | 1338 void (^completion)(id<UIViewControllerTransitionCoordinatorContext>) = ^( |
1340 id<UIViewControllerTransitionCoordinatorContext> context) { | 1339 id<UIViewControllerTransitionCoordinatorContext> context) { |
1341 base::scoped_nsobject<BrowserViewController> strongSelf([weakSelf retain]); | 1340 base::scoped_nsobject<BrowserViewController> strongSelf(weakSelf); |
1342 if (strongSelf) | 1341 if (strongSelf) |
1343 [strongSelf showFindBarWithAnimation:NO | 1342 [strongSelf showFindBarWithAnimation:NO |
1344 selectText:NO | 1343 selectText:NO |
1345 shouldFocus:isFocusedBeforeReshow]; | 1344 shouldFocus:isFocusedBeforeReshow]; |
1346 }; | 1345 }; |
1347 | 1346 |
1348 BOOL enqueued = | 1347 BOOL enqueued = |
1349 [coordinator animateAlongsideTransition:nil completion:completion]; | 1348 [coordinator animateAlongsideTransition:nil completion:completion]; |
1350 if (!enqueued) { | 1349 if (!enqueued) { |
1351 completion(nil); | 1350 completion(nil); |
1352 } | 1351 } |
1353 } | 1352 } |
1354 | 1353 |
1355 - (void)dismissViewControllerAnimated:(BOOL)flag | 1354 - (void)dismissViewControllerAnimated:(BOOL)flag |
1356 completion:(void (^)())completion { | 1355 completion:(void (^)())completion { |
1357 self.dismissingModal = YES; | 1356 self.dismissingModal = YES; |
1358 base::WeakNSObject<BrowserViewController> weakSelf(self); | 1357 base::WeakNSObject<BrowserViewController> weakSelf(self); |
1359 [super dismissViewControllerAnimated:flag | 1358 [super dismissViewControllerAnimated:flag |
1360 completion:^{ | 1359 completion:^{ |
1361 base::scoped_nsobject<BrowserViewController> | 1360 base::scoped_nsobject<BrowserViewController> |
1362 strongSelf([weakSelf retain]); | 1361 strongSelf(weakSelf); |
1363 [strongSelf setDismissingModal:NO]; | 1362 [strongSelf setDismissingModal:NO]; |
1364 [strongSelf setPresenting:NO]; | 1363 [strongSelf setPresenting:NO]; |
1365 if (completion) | 1364 if (completion) |
1366 completion(); | 1365 completion(); |
1367 [[strongSelf dialogPresenter] tryToPresent]; | 1366 [[strongSelf dialogPresenter] tryToPresent]; |
1368 }]; | 1367 }]; |
1369 } | 1368 } |
1370 | 1369 |
1371 - (void)presentViewController:(UIViewController*)viewControllerToPresent | 1370 - (void)presentViewController:(UIViewController*)viewControllerToPresent |
1372 animated:(BOOL)flag | 1371 animated:(BOOL)flag |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1625 #pragma mark - UI Configuration and Layout | 1624 #pragma mark - UI Configuration and Layout |
1626 | 1625 |
1627 - (void)updateWithTabModel:(TabModel*)model | 1626 - (void)updateWithTabModel:(TabModel*)model |
1628 browserState:(ios::ChromeBrowserState*)browserState { | 1627 browserState:(ios::ChromeBrowserState*)browserState { |
1629 DCHECK(model); | 1628 DCHECK(model); |
1630 DCHECK(browserState); | 1629 DCHECK(browserState); |
1631 DCHECK(!_model); | 1630 DCHECK(!_model); |
1632 DCHECK(!_browserState); | 1631 DCHECK(!_browserState); |
1633 _browserState = browserState; | 1632 _browserState = browserState; |
1634 _isOffTheRecord = browserState->IsOffTheRecord() ? YES : NO; | 1633 _isOffTheRecord = browserState->IsOffTheRecord() ? YES : NO; |
1635 _model.reset([model retain]); | 1634 _model.reset(model); |
1636 [_model addObserver:self]; | 1635 [_model addObserver:self]; |
1637 | 1636 |
1638 if (!_isOffTheRecord) { | 1637 if (!_isOffTheRecord) { |
1639 [DefaultIOSWebViewFactory | 1638 [DefaultIOSWebViewFactory |
1640 registerWebViewFactory:[ChromeWebViewFactory class]]; | 1639 registerWebViewFactory:[ChromeWebViewFactory class]]; |
1641 } | 1640 } |
1642 NSUInteger count = [_model count]; | 1641 NSUInteger count = [_model count]; |
1643 for (NSUInteger index = 0; index < count; ++index) | 1642 for (NSUInteger index = 0; index < count; ++index) |
1644 [self installDelegatesForTab:[_model tabAtIndex:index]]; | 1643 [self installDelegatesForTab:[_model tabAtIndex:index]]; |
1645 | 1644 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1756 | 1755 |
1757 [self.sideSwipeController addHorizontalGesturesToView:self.view]; | 1756 [self.sideSwipeController addHorizontalGesturesToView:self.view]; |
1758 | 1757 |
1759 infobars::InfoBarManager* infoBarManager = | 1758 infobars::InfoBarManager* infoBarManager = |
1760 [[_model currentTab] infoBarManager]; | 1759 [[_model currentTab] infoBarManager]; |
1761 _infoBarContainer->ChangeInfoBarManager(infoBarManager); | 1760 _infoBarContainer->ChangeInfoBarManager(infoBarManager); |
1762 | 1761 |
1763 // Create contextual search views and controller. | 1762 // Create contextual search views and controller. |
1764 if ([TouchToSearchPermissionsMediator isTouchToSearchAvailableOnDevice] && | 1763 if ([TouchToSearchPermissionsMediator isTouchToSearchAvailableOnDevice] && |
1765 !_browserState->IsOffTheRecord()) { | 1764 !_browserState->IsOffTheRecord()) { |
1766 _contextualSearchMask = | 1765 _contextualSearchMask = [[ContextualSearchMaskView alloc] init]; |
1767 [[[ContextualSearchMaskView alloc] init] autorelease]; | |
1768 [self.view insertSubview:_contextualSearchMask | 1766 [self.view insertSubview:_contextualSearchMask |
1769 belowSubview:[_toolbarController view]]; | 1767 belowSubview:[_toolbarController view]]; |
1770 _contextualSearchPanel = [self createPanelView]; | 1768 _contextualSearchPanel = [self createPanelView]; |
1771 [self.view insertSubview:_contextualSearchPanel | 1769 [self.view insertSubview:_contextualSearchPanel |
1772 aboveSubview:[_toolbarController view]]; | 1770 aboveSubview:[_toolbarController view]]; |
1773 _contextualSearchController.reset([[ContextualSearchController alloc] | 1771 _contextualSearchController.reset([[ContextualSearchController alloc] |
1774 initWithBrowserState:_browserState | 1772 initWithBrowserState:_browserState |
1775 delegate:self]); | 1773 delegate:self]); |
1776 [_contextualSearchController setPanel:_contextualSearchPanel]; | 1774 [_contextualSearchController setPanel:_contextualSearchPanel]; |
1777 [_contextualSearchController setTab:[_model currentTab]]; | 1775 [_contextualSearchController setTab:[_model currentTab]]; |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2038 DCHECK(position <= [_model count]); | 2036 DCHECK(position <= [_model count]); |
2039 | 2037 |
2040 web::NavigationManager::WebLoadParams params(URL); | 2038 web::NavigationManager::WebLoadParams params(URL); |
2041 params.transition_type = transition; | 2039 params.transition_type = transition; |
2042 if (postData) { | 2040 if (postData) { |
2043 // Extract the content type and post params from |postData| and add them | 2041 // Extract the content type and post params from |postData| and add them |
2044 // to the load params. | 2042 // to the load params. |
2045 NSString* contentType = base::SysUTF8ToNSString(postData->first); | 2043 NSString* contentType = base::SysUTF8ToNSString(postData->first); |
2046 NSData* data = [NSData dataWithBytes:(void*)postData->second.data() | 2044 NSData* data = [NSData dataWithBytes:(void*)postData->second.data() |
2047 length:postData->second.length()]; | 2045 length:postData->second.length()]; |
2048 params.post_data.reset([data retain]); | 2046 params.post_data.reset(data); |
2049 params.extra_headers.reset([@{ @"Content-Type" : contentType } retain]); | 2047 params.extra_headers.reset(@{ @"Content-Type" : contentType }); |
2050 } | 2048 } |
2051 Tab* tab = [_model insertTabWithLoadParams:params | 2049 Tab* tab = [_model insertTabWithLoadParams:params |
2052 opener:nil | 2050 opener:nil |
2053 openedByDOM:NO | 2051 openedByDOM:NO |
2054 atIndex:position | 2052 atIndex:position |
2055 inBackground:NO]; | 2053 inBackground:NO]; |
2056 return tab; | 2054 return tab; |
2057 } | 2055 } |
2058 | 2056 |
2059 // Whether the given tab's URL is an application specific URL. | 2057 // Whether the given tab's URL is an application specific URL. |
2060 - (BOOL)isTabNativePage:(Tab*)tab { | 2058 - (BOOL)isTabNativePage:(Tab*)tab { |
2061 web::WebState* webState = tab.webState; | 2059 web::WebState* webState = tab.webState; |
2062 if (!webState) | 2060 if (!webState) |
2063 return NO; | 2061 return NO; |
2064 web::NavigationItem* visibleItem = | 2062 web::NavigationItem* visibleItem = |
2065 webState->GetNavigationManager()->GetVisibleItem(); | 2063 webState->GetNavigationManager()->GetVisibleItem(); |
2066 if (!visibleItem) | 2064 if (!visibleItem) |
2067 return NO; | 2065 return NO; |
2068 return web::GetWebClient()->IsAppSpecificURL(visibleItem->GetURL()); | 2066 return web::GetWebClient()->IsAppSpecificURL(visibleItem->GetURL()); |
2069 } | 2067 } |
2070 | 2068 |
2071 - (void)expectNewForegroundTab { | 2069 - (void)expectNewForegroundTab { |
2072 _expectingForegroundTab = YES; | 2070 _expectingForegroundTab = YES; |
2073 } | 2071 } |
2074 | 2072 |
2075 - (UIImageView*)pageFullScreenOpenCloseAnimationView { | 2073 - (UIImageView*)pageFullScreenOpenCloseAnimationView { |
2076 CGRect viewBounds, remainder; | 2074 CGRect viewBounds, remainder; |
2077 CGRectDivide(self.view.bounds, &remainder, &viewBounds, StatusBarHeight(), | 2075 CGRectDivide(self.view.bounds, &remainder, &viewBounds, StatusBarHeight(), |
2078 CGRectMinYEdge); | 2076 CGRectMinYEdge); |
2079 return [[[UIImageView alloc] initWithFrame:viewBounds] autorelease]; | 2077 return [[UIImageView alloc] initWithFrame:viewBounds]; |
2080 } | 2078 } |
2081 | 2079 |
2082 - (UIImageView*)pageOpenCloseAnimationView { | 2080 - (UIImageView*)pageOpenCloseAnimationView { |
2083 CGRect frame = [_contentArea bounds]; | 2081 CGRect frame = [_contentArea bounds]; |
2084 | 2082 |
2085 frame.size.height = frame.size.height - [self headerHeight]; | 2083 frame.size.height = frame.size.height - [self headerHeight]; |
2086 frame.origin.y = [self headerHeight]; | 2084 frame.origin.y = [self headerHeight]; |
2087 | 2085 |
2088 UIImageView* pageView = | 2086 UIImageView* pageView = [[UIImageView alloc] initWithFrame:frame]; |
2089 [[[UIImageView alloc] initWithFrame:frame] autorelease]; | |
2090 CGPoint center = CGPointMake(CGRectGetMidX(frame), CGRectGetMidY(frame)); | 2087 CGPoint center = CGPointMake(CGRectGetMidX(frame), CGRectGetMidY(frame)); |
2091 pageView.center = center; | 2088 pageView.center = center; |
2092 | 2089 |
2093 pageView.backgroundColor = [UIColor whiteColor]; | 2090 pageView.backgroundColor = [UIColor whiteColor]; |
2094 return pageView; | 2091 return pageView; |
2095 } | 2092 } |
2096 | 2093 |
2097 - (void)installDelegatesForTab:(Tab*)tab { | 2094 - (void)installDelegatesForTab:(Tab*)tab { |
2098 // Unregistration happens when the Tab is removed from the TabModel. | 2095 // Unregistration happens when the Tab is removed from the TabModel. |
2099 tab.dialogDelegate = self; | 2096 tab.dialogDelegate = self; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2183 - (void)removeExternalFilesImmediately:(BOOL)immediately | 2180 - (void)removeExternalFilesImmediately:(BOOL)immediately |
2184 completionHandler:(ProceduralBlock)completionHandler { | 2181 completionHandler:(ProceduralBlock)completionHandler { |
2185 DCHECK_CURRENTLY_ON(web::WebThread::UI); | 2182 DCHECK_CURRENTLY_ON(web::WebThread::UI); |
2186 DCHECK(!_isOffTheRecord); | 2183 DCHECK(!_isOffTheRecord); |
2187 _externalFileRemover.reset(new ExternalFileRemover(self)); | 2184 _externalFileRemover.reset(new ExternalFileRemover(self)); |
2188 // Delay the cleanup of the unreferenced files received from other apps | 2185 // Delay the cleanup of the unreferenced files received from other apps |
2189 // to not impact startup performance. | 2186 // to not impact startup performance. |
2190 int delay = immediately ? 0 : kExternalFilesCleanupDelaySeconds; | 2187 int delay = immediately ? 0 : kExternalFilesCleanupDelaySeconds; |
2191 _externalFileRemover->RemoveAfterDelay( | 2188 _externalFileRemover->RemoveAfterDelay( |
2192 base::TimeDelta::FromSeconds(delay), | 2189 base::TimeDelta::FromSeconds(delay), |
2193 base::BindBlock(completionHandler ? completionHandler | 2190 base::BindBlockArc(completionHandler ? completionHandler |
2194 : ^{ | 2191 : ^{ |
2195 })); | 2192 })); |
2196 } | 2193 } |
2197 | 2194 |
2198 #pragma mark - SnapshotOverlayProvider methods | 2195 #pragma mark - SnapshotOverlayProvider methods |
2199 | 2196 |
2200 - (NSArray*)snapshotOverlaysForTab:(Tab*)tab { | 2197 - (NSArray*)snapshotOverlaysForTab:(Tab*)tab { |
2201 NSMutableArray* overlays = [NSMutableArray array]; | 2198 NSMutableArray* overlays = [NSMutableArray array]; |
2202 if (![_model webUsageEnabled]) { | 2199 if (![_model webUsageEnabled]) { |
2203 return overlays; | 2200 return overlays; |
2204 } | 2201 } |
2205 UIView* voiceSearchView = [self voiceSearchOverlayViewForTab:tab]; | 2202 UIView* voiceSearchView = [self voiceSearchOverlayViewForTab:tab]; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2291 } | 2288 } |
2292 } | 2289 } |
2293 | 2290 |
2294 - (void)ensureVoiceSearchBarCreated { | 2291 - (void)ensureVoiceSearchBarCreated { |
2295 if (_voiceSearchBar) | 2292 if (_voiceSearchBar) |
2296 return; | 2293 return; |
2297 | 2294 |
2298 CGFloat width = CGRectGetWidth([[self view] bounds]); | 2295 CGFloat width = CGRectGetWidth([[self view] bounds]); |
2299 CGFloat y = CGRectGetHeight([[self view] bounds]) - kVoiceSearchBarHeight; | 2296 CGFloat y = CGRectGetHeight([[self view] bounds]) - kVoiceSearchBarHeight; |
2300 CGRect frame = CGRectMake(0.0, y, width, kVoiceSearchBarHeight); | 2297 CGRect frame = CGRectMake(0.0, y, width, kVoiceSearchBarHeight); |
2301 _voiceSearchBar.reset([ios::GetChromeBrowserProvider() | 2298 _voiceSearchBar.reset(ios::GetChromeBrowserProvider() |
2302 ->GetVoiceSearchProvider() | 2299 ->GetVoiceSearchProvider() |
2303 ->BuildVoiceSearchBar(frame) retain]); | 2300 ->BuildVoiceSearchBar(frame)); |
2304 [_voiceSearchBar setVoiceSearchBarDelegate:self]; | 2301 [_voiceSearchBar setVoiceSearchBarDelegate:self]; |
2305 [_voiceSearchBar setHidden:YES]; | 2302 [_voiceSearchBar setHidden:YES]; |
2306 [_voiceSearchBar setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | | 2303 [_voiceSearchBar setAutoresizingMask:UIViewAutoresizingFlexibleTopMargin | |
2307 UIViewAutoresizingFlexibleWidth]; | 2304 UIViewAutoresizingFlexibleWidth]; |
2308 [self.view insertSubview:_voiceSearchBar | 2305 [self.view insertSubview:_voiceSearchBar |
2309 belowSubview:_infoBarContainer->view()]; | 2306 belowSubview:_infoBarContainer->view()]; |
2310 } | 2307 } |
2311 | 2308 |
2312 - (void)updateVoiceSearchBarVisibilityAnimated:(BOOL)animated { | 2309 - (void)updateVoiceSearchBarVisibilityAnimated:(BOOL)animated { |
2313 // Voice search bar exists and is shown/hidden. | 2310 // Voice search bar exists and is shown/hidden. |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2618 - (void)webState:(web::WebState*)webState | 2615 - (void)webState:(web::WebState*)webState |
2619 runRepostFormDialogWithCompletionHandler:(void (^)(BOOL))handler { | 2616 runRepostFormDialogWithCompletionHandler:(void (^)(BOOL))handler { |
2620 // Display the action sheet with the arrow pointing at the top center of the | 2617 // Display the action sheet with the arrow pointing at the top center of the |
2621 // web contents. | 2618 // web contents. |
2622 Tab* tab = LegacyTabHelper::GetTabForWebState(webState); | 2619 Tab* tab = LegacyTabHelper::GetTabForWebState(webState); |
2623 UIView* view = webState->GetView(); | 2620 UIView* view = webState->GetView(); |
2624 CGPoint dialogLocation = | 2621 CGPoint dialogLocation = |
2625 CGPointMake(CGRectGetMidX(view.frame), | 2622 CGPointMake(CGRectGetMidX(view.frame), |
2626 CGRectGetMinY(view.frame) + [self headerHeightForTab:tab]); | 2623 CGRectGetMinY(view.frame) + [self headerHeightForTab:tab]); |
2627 auto* helper = RepostFormTabHelper::FromWebState(webState); | 2624 auto* helper = RepostFormTabHelper::FromWebState(webState); |
2628 helper->PresentDialog(dialogLocation, base::BindBlock(^(bool shouldContinue) { | 2625 helper->PresentDialog(dialogLocation, |
| 2626 base::BindBlockArc(^(bool shouldContinue) { |
2629 handler(shouldContinue); | 2627 handler(shouldContinue); |
2630 })); | 2628 })); |
2631 } | 2629 } |
2632 | 2630 |
2633 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState: | 2631 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState: |
2634 (web::WebState*)webState { | 2632 (web::WebState*)webState { |
2635 return _javaScriptDialogPresenter.get(); | 2633 return _javaScriptDialogPresenter.get(); |
2636 } | 2634 } |
2637 | 2635 |
2638 - (void)webState:(web::WebState*)webState | 2636 - (void)webState:(web::WebState*)webState |
(...skipping 25 matching lines...) Expand all Loading... |
2664 } | 2662 } |
2665 | 2663 |
2666 - (const std::vector<HeaderDefinition>)headerViews { | 2664 - (const std::vector<HeaderDefinition>)headerViews { |
2667 std::vector<HeaderDefinition> results; | 2665 std::vector<HeaderDefinition> results; |
2668 if (![self isViewLoaded]) | 2666 if (![self isViewLoaded]) |
2669 return results; | 2667 return results; |
2670 | 2668 |
2671 if (!IsIPadIdiom()) { | 2669 if (!IsIPadIdiom()) { |
2672 if ([_toolbarController view]) { | 2670 if ([_toolbarController view]) { |
2673 HeaderDefinition header = { | 2671 HeaderDefinition header = { |
2674 base::scoped_nsobject<UIView>([[_toolbarController view] retain]), | 2672 base::scoped_nsobject<UIView>([_toolbarController view]), Hideable, |
2675 Hideable, [ToolbarController toolbarDropShadowHeight], 0.0, | 2673 [ToolbarController toolbarDropShadowHeight], 0.0, |
2676 }; | 2674 }; |
2677 results.push_back(header); | 2675 results.push_back(header); |
2678 } | 2676 } |
2679 } else { | 2677 } else { |
2680 if ([_tabStripController view]) { | 2678 if ([_tabStripController view]) { |
2681 HeaderDefinition header = { | 2679 HeaderDefinition header = { |
2682 base::scoped_nsobject<UIView>([[_tabStripController view] retain]), | 2680 base::scoped_nsobject<UIView>([_tabStripController view]), Hideable, |
2683 Hideable, 0.0, 0.0, | 2681 0.0, 0.0, |
2684 }; | 2682 }; |
2685 results.push_back(header); | 2683 results.push_back(header); |
2686 } | 2684 } |
2687 if ([_toolbarController view]) { | 2685 if ([_toolbarController view]) { |
2688 HeaderDefinition header = { | 2686 HeaderDefinition header = { |
2689 base::scoped_nsobject<UIView>([[_toolbarController view] retain]), | 2687 base::scoped_nsobject<UIView>([_toolbarController view]), Hideable, |
2690 Hideable, [ToolbarController toolbarDropShadowHeight], 0.0, | 2688 [ToolbarController toolbarDropShadowHeight], 0.0, |
2691 }; | 2689 }; |
2692 results.push_back(header); | 2690 results.push_back(header); |
2693 } | 2691 } |
2694 if ([_findBarController view]) { | 2692 if ([_findBarController view]) { |
2695 HeaderDefinition header = { | 2693 HeaderDefinition header = { |
2696 base::scoped_nsobject<UIView>([[_findBarController view] retain]), | 2694 base::scoped_nsobject<UIView>([_findBarController view]), Overlap, |
2697 Overlap, 0.0, kIPadFindBarOverlap, | 2695 0.0, kIPadFindBarOverlap, |
2698 }; | 2696 }; |
2699 results.push_back(header); | 2697 results.push_back(header); |
2700 } | 2698 } |
2701 } | 2699 } |
2702 return results; | 2700 return results; |
2703 } | 2701 } |
2704 | 2702 |
2705 - (UIView*)footerView { | 2703 - (UIView*)footerView { |
2706 return _voiceSearchBar; | 2704 return _voiceSearchBar; |
2707 } | 2705 } |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2862 | 2860 |
2863 - (id<VoiceSearchBar>)voiceSearchBar { | 2861 - (id<VoiceSearchBar>)voiceSearchBar { |
2864 return _voiceSearchBar; | 2862 return _voiceSearchBar; |
2865 } | 2863 } |
2866 | 2864 |
2867 #pragma mark - Install OverScrollActionController method. | 2865 #pragma mark - Install OverScrollActionController method. |
2868 - (void)setOverScrollActionControllerToStaticNativeContent: | 2866 - (void)setOverScrollActionControllerToStaticNativeContent: |
2869 (StaticHtmlNativeContent*)nativeContent { | 2867 (StaticHtmlNativeContent*)nativeContent { |
2870 if (!IsIPadIdiom() && !FirstRun::IsChromeFirstRun()) { | 2868 if (!IsIPadIdiom() && !FirstRun::IsChromeFirstRun()) { |
2871 OverscrollActionsController* controller = | 2869 OverscrollActionsController* controller = |
2872 [[[OverscrollActionsController alloc] | 2870 [[OverscrollActionsController alloc] |
2873 initWithScrollView:[nativeContent scrollView]] autorelease]; | 2871 initWithScrollView:[nativeContent scrollView]]; |
2874 [controller setDelegate:self]; | 2872 [controller setDelegate:self]; |
2875 OverscrollStyle style = _isOffTheRecord | 2873 OverscrollStyle style = _isOffTheRecord |
2876 ? OverscrollStyle::REGULAR_PAGE_INCOGNITO | 2874 ? OverscrollStyle::REGULAR_PAGE_INCOGNITO |
2877 : OverscrollStyle::REGULAR_PAGE_NON_INCOGNITO; | 2875 : OverscrollStyle::REGULAR_PAGE_NON_INCOGNITO; |
2878 controller.style = style; | 2876 controller.style = style; |
2879 nativeContent.overscrollActionsController = controller; | 2877 nativeContent.overscrollActionsController = controller; |
2880 } | 2878 } |
2881 } | 2879 } |
2882 | 2880 |
2883 #pragma mark - OverscrollActionsControllerDelegate methods. | 2881 #pragma mark - OverscrollActionsControllerDelegate methods. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2954 - (void)selectedPanelDidChange { | 2952 - (void)selectedPanelDidChange { |
2955 [self updateToolbar]; | 2953 [self updateToolbar]; |
2956 } | 2954 } |
2957 | 2955 |
2958 #pragma mark - CRWNativeContentProvider methods | 2956 #pragma mark - CRWNativeContentProvider methods |
2959 | 2957 |
2960 - (id<CRWNativeContent>)controllerForURL:(const GURL&)url | 2958 - (id<CRWNativeContent>)controllerForURL:(const GURL&)url |
2961 withError:(NSError*)error | 2959 withError:(NSError*)error |
2962 isPost:(BOOL)isPost { | 2960 isPost:(BOOL)isPost { |
2963 ErrorPageContent* errorPageContent = | 2961 ErrorPageContent* errorPageContent = |
2964 [[[ErrorPageContent alloc] initWithLoader:self | 2962 [[ErrorPageContent alloc] initWithLoader:self |
2965 browserState:self.browserState | 2963 browserState:self.browserState |
2966 url:url | 2964 url:url |
2967 error:error | 2965 error:error |
2968 isPost:isPost | 2966 isPost:isPost |
2969 isIncognito:_isOffTheRecord] autorelease]; | 2967 isIncognito:_isOffTheRecord]; |
2970 [self setOverScrollActionControllerToStaticNativeContent:errorPageContent]; | 2968 [self setOverScrollActionControllerToStaticNativeContent:errorPageContent]; |
2971 return errorPageContent; | 2969 return errorPageContent; |
2972 } | 2970 } |
2973 | 2971 |
2974 - (BOOL)hasControllerForURL:(const GURL&)url { | 2972 - (BOOL)hasControllerForURL:(const GURL&)url { |
2975 std::string host(url.host()); | 2973 std::string host(url.host()); |
2976 | 2974 |
2977 return host == kChromeUINewTabHost || host == kChromeUIBookmarksHost || | 2975 return host == kChromeUINewTabHost || host == kChromeUIBookmarksHost || |
2978 host == kChromeUITermsHost || host == kChromeUIOfflineHost; | 2976 host == kChromeUITermsHost || host == kChromeUIOfflineHost; |
2979 } | 2977 } |
2980 | 2978 |
2981 - (id<CRWNativeContent>)controllerForURL:(const GURL&)url | 2979 - (id<CRWNativeContent>)controllerForURL:(const GURL&)url |
2982 webState:(web::WebState*)webState { | 2980 webState:(web::WebState*)webState { |
2983 DCHECK(url.SchemeIs(kChromeUIScheme)); | 2981 DCHECK(url.SchemeIs(kChromeUIScheme)); |
2984 | 2982 |
2985 id<CRWNativeContent> nativeController = nil; | 2983 id<CRWNativeContent> nativeController = nil; |
2986 std::string url_host = url.host(); | 2984 std::string url_host = url.host(); |
2987 if (url_host == kChromeUINewTabHost || url_host == kChromeUIBookmarksHost) { | 2985 if (url_host == kChromeUINewTabHost || url_host == kChromeUIBookmarksHost) { |
2988 NewTabPageController* pageController = | 2986 NewTabPageController* pageController = |
2989 [[[NewTabPageController alloc] initWithUrl:url | 2987 [[NewTabPageController alloc] initWithUrl:url |
2990 loader:self | 2988 loader:self |
2991 focuser:_toolbarController | 2989 focuser:_toolbarController |
2992 ntpObserver:self | 2990 ntpObserver:self |
2993 browserState:_browserState | 2991 browserState:_browserState |
2994 colorCache:_dominantColorCache | 2992 colorCache:_dominantColorCache |
2995 webToolbarDelegate:self | 2993 webToolbarDelegate:self |
2996 tabModel:_model] autorelease]; | 2994 tabModel:_model]; |
2997 pageController.swipeRecognizerProvider = self.sideSwipeController; | 2995 pageController.swipeRecognizerProvider = self.sideSwipeController; |
2998 | 2996 |
2999 // Panel is always NTP for iPhone. | 2997 // Panel is always NTP for iPhone. |
3000 NewTabPage::PanelIdentifier panelType = NewTabPage::kMostVisitedPanel; | 2998 NewTabPage::PanelIdentifier panelType = NewTabPage::kMostVisitedPanel; |
3001 | 2999 |
3002 if (IsIPadIdiom()) { | 3000 if (IsIPadIdiom()) { |
3003 // New Tab Page can have multiple panels. Each panel is addressable | 3001 // New Tab Page can have multiple panels. Each panel is addressable |
3004 // by a #fragment, e.g. chrome://newtab/#most_visited takes user to | 3002 // by a #fragment, e.g. chrome://newtab/#most_visited takes user to |
3005 // the Most Visited page, chrome://newtab/#bookmarks takes user to | 3003 // the Most Visited page, chrome://newtab/#bookmarks takes user to |
3006 // the Bookmark Manager, etc. | 3004 // the Bookmark Manager, etc. |
3007 // The utility functions NewTabPage::IdentifierFromFragment() and | 3005 // The utility functions NewTabPage::IdentifierFromFragment() and |
3008 // FragmentFromIdentifier() map an identifier to/from a #fragment. | 3006 // FragmentFromIdentifier() map an identifier to/from a #fragment. |
3009 // If the URL is chrome://bookmarks, pre-select the #bookmarks panel | 3007 // If the URL is chrome://bookmarks, pre-select the #bookmarks panel |
3010 // without changing the URL since the URL may be chrome://bookmarks/#123. | 3008 // without changing the URL since the URL may be chrome://bookmarks/#123. |
3011 // If the URL is chrome://newtab/, pre-select the panel based on the | 3009 // If the URL is chrome://newtab/, pre-select the panel based on the |
3012 // #fragment. | 3010 // #fragment. |
3013 panelType = url_host == kChromeUIBookmarksHost | 3011 panelType = url_host == kChromeUIBookmarksHost |
3014 ? NewTabPage::kBookmarksPanel | 3012 ? NewTabPage::kBookmarksPanel |
3015 : NewTabPage::IdentifierFromFragment(url.ref()); | 3013 : NewTabPage::IdentifierFromFragment(url.ref()); |
3016 } | 3014 } |
3017 [pageController selectPanel:panelType]; | 3015 [pageController selectPanel:panelType]; |
3018 nativeController = pageController; | 3016 nativeController = pageController; |
3019 } else if (url_host == kChromeUITermsHost) { | 3017 } else if (url_host == kChromeUITermsHost) { |
3020 const std::string& filename = GetTermsOfServicePath(); | 3018 const std::string& filename = GetTermsOfServicePath(); |
3021 | 3019 |
3022 StaticHtmlNativeContent* staticNativeController = | 3020 StaticHtmlNativeContent* staticNativeController = |
3023 [[[StaticHtmlNativeContent alloc] | 3021 [[StaticHtmlNativeContent alloc] |
3024 initWithResourcePathResource:base::SysUTF8ToNSString(filename) | 3022 initWithResourcePathResource:base::SysUTF8ToNSString(filename) |
3025 loader:self | 3023 loader:self |
3026 browserState:_browserState | 3024 browserState:_browserState |
3027 url:GURL(kChromeUITermsURL)] autorelease]; | 3025 url:GURL(kChromeUITermsURL)]; |
3028 [self setOverScrollActionControllerToStaticNativeContent: | 3026 [self setOverScrollActionControllerToStaticNativeContent: |
3029 staticNativeController]; | 3027 staticNativeController]; |
3030 nativeController = staticNativeController; | 3028 nativeController = staticNativeController; |
3031 } else if (url_host == kChromeUIOfflineHost) { | 3029 } else if (url_host == kChromeUIOfflineHost) { |
3032 StaticHtmlNativeContent* staticNativeController = | 3030 StaticHtmlNativeContent* staticNativeController = |
3033 [[[OfflinePageNativeContent alloc] initWithLoader:self | 3031 [[OfflinePageNativeContent alloc] initWithLoader:self |
3034 browserState:_browserState | 3032 browserState:_browserState |
3035 webState:webState | 3033 webState:webState |
3036 URL:url] autorelease]; | 3034 URL:url]; |
3037 [self setOverScrollActionControllerToStaticNativeContent: | 3035 [self setOverScrollActionControllerToStaticNativeContent: |
3038 staticNativeController]; | 3036 staticNativeController]; |
3039 nativeController = staticNativeController; | 3037 nativeController = staticNativeController; |
3040 } else if (url_host == kChromeUIExternalFileHost) { | 3038 } else if (url_host == kChromeUIExternalFileHost) { |
3041 // Return an instance of the |ExternalFileController| only if the file is | 3039 // Return an instance of the |ExternalFileController| only if the file is |
3042 // still in the sandbox. | 3040 // still in the sandbox. |
3043 NSString* filePath = [ExternalFileController pathForExternalFileURL:url]; | 3041 NSString* filePath = [ExternalFileController pathForExternalFileURL:url]; |
3044 if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { | 3042 if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { |
3045 nativeController = [[[ExternalFileController alloc] | 3043 nativeController = |
3046 initWithURL:url | 3044 [[ExternalFileController alloc] initWithURL:url |
3047 browserState:_browserState] autorelease]; | 3045 browserState:_browserState]; |
3048 } | 3046 } |
3049 } else { | 3047 } else { |
3050 DCHECK(![self hasControllerForURL:url]); | 3048 DCHECK(![self hasControllerForURL:url]); |
3051 // In any other case the PageNotAvailableController is returned. | 3049 // In any other case the PageNotAvailableController is returned. |
3052 nativeController = | 3050 nativeController = [[PageNotAvailableController alloc] initWithUrl:url]; |
3053 [[[PageNotAvailableController alloc] initWithUrl:url] autorelease]; | |
3054 if (url_host == kChromeUIHistoryFrameHost) { | 3051 if (url_host == kChromeUIHistoryFrameHost) { |
3055 base::mac::ObjCCastStrict<PageNotAvailableController>(nativeController) | 3052 base::mac::ObjCCastStrict<PageNotAvailableController>(nativeController) |
3056 .descriptionText = l10n_util::GetNSStringFWithFixup( | 3053 .descriptionText = l10n_util::GetNSStringFWithFixup( |
3057 IDS_IOS_HISTORY_URL_NOT_AVAILABLE, | 3054 IDS_IOS_HISTORY_URL_NOT_AVAILABLE, |
3058 base::UTF8ToUTF16(kChromeUIHistoryURL), | 3055 base::UTF8ToUTF16(kChromeUIHistoryURL), |
3059 l10n_util::GetStringUTF16(IDS_HISTORY_SHOW_HISTORY)); | 3056 l10n_util::GetStringUTF16(IDS_HISTORY_SHOW_HISTORY)); |
3060 } | 3057 } |
3061 } | 3058 } |
3062 // If a native controller is vended before its tab is added to the tab model, | 3059 // If a native controller is vended before its tab is added to the tab model, |
3063 // use the temporary key and add it under the new tab's tabId in the | 3060 // use the temporary key and add it under the new tab's tabId in the |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3194 }; | 3191 }; |
3195 _imageFetcher->FetchImageDataWebpDecoded( | 3192 _imageFetcher->FetchImageDataWebpDecoded( |
3196 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer), | 3193 url, callback, web::ReferrerHeaderValueForNavigation(url, referrer), |
3197 web::PolicyForNavigation(url, referrer)); | 3194 web::PolicyForNavigation(url, referrer)); |
3198 } | 3195 } |
3199 | 3196 |
3200 - (void)managePermissionAndSaveImage:(NSData*)data | 3197 - (void)managePermissionAndSaveImage:(NSData*)data |
3201 withFileExtension:(NSString*)fileExtension { | 3198 withFileExtension:(NSString*)fileExtension { |
3202 switch ([PHPhotoLibrary authorizationStatus]) { | 3199 switch ([PHPhotoLibrary authorizationStatus]) { |
3203 // User was never asked for permission to access photos. | 3200 // User was never asked for permission to access photos. |
3204 case PHAuthorizationStatusNotDetermined: | 3201 case PHAuthorizationStatusNotDetermined: { |
3205 [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { | 3202 [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) { |
3206 // Call -saveImage again to check if chrome needs to display an error or | 3203 // Call -saveImage again to check if chrome needs to display an error or |
3207 // saves the image. | 3204 // saves the image. |
3208 if (status != PHAuthorizationStatusNotDetermined) | 3205 if (status != PHAuthorizationStatusNotDetermined) |
3209 [self managePermissionAndSaveImage:data | 3206 [self managePermissionAndSaveImage:data |
3210 withFileExtension:fileExtension]; | 3207 withFileExtension:fileExtension]; |
3211 }]; | 3208 }]; |
3212 break; | 3209 break; |
| 3210 } |
3213 | 3211 |
3214 // The application doesn't have permission to access photo and the user | 3212 // The application doesn't have permission to access photo and the user |
3215 // cannot grant it. | 3213 // cannot grant it. |
3216 case PHAuthorizationStatusRestricted: | 3214 case PHAuthorizationStatusRestricted: |
3217 [self displayPrivacyErrorAlertOnMainQueue: | 3215 [self displayPrivacyErrorAlertOnMainQueue: |
3218 l10n_util::GetNSString( | 3216 l10n_util::GetNSString( |
3219 IDS_IOS_SAVE_IMAGE_RESTRICTED_PRIVACY_ALERT_MESSAGE)]; | 3217 IDS_IOS_SAVE_IMAGE_RESTRICTED_PRIVACY_ALERT_MESSAGE)]; |
3220 break; | 3218 break; |
3221 | 3219 |
3222 // The application doesn't have permission to access photo and the user | 3220 // The application doesn't have permission to access photo and the user |
3223 // can grant it. | 3221 // can grant it. |
3224 case PHAuthorizationStatusDenied: | 3222 case PHAuthorizationStatusDenied: |
3225 [self displayImageErrorAlertWithSettingsOnMainQueue]; | 3223 [self displayImageErrorAlertWithSettingsOnMainQueue]; |
3226 break; | 3224 break; |
3227 | 3225 |
3228 // The application has permission to access the photos. | 3226 // The application has permission to access the photos. |
3229 default: { | 3227 default: { |
3230 web::WebThread::PostTask( | 3228 web::WebThread::PostTask( |
3231 web::WebThread::FILE, FROM_HERE, base::BindBlock(^{ | 3229 web::WebThread::FILE, FROM_HERE, base::BindBlockArc(^{ |
3232 [self saveImage:data withFileExtension:fileExtension]; | 3230 [self saveImage:data withFileExtension:fileExtension]; |
3233 })); | 3231 })); |
3234 break; | 3232 break; |
3235 } | 3233 } |
3236 } | 3234 } |
3237 } | 3235 } |
3238 | 3236 |
3239 - (void)saveImage:(NSData*)data withFileExtension:(NSString*)fileExtension { | 3237 - (void)saveImage:(NSData*)data withFileExtension:(NSString*)fileExtension { |
3240 NSString* fileName = [[[NSProcessInfo processInfo] globallyUniqueString] | 3238 NSString* fileName = [[[NSProcessInfo processInfo] globallyUniqueString] |
3241 stringByAppendingString:fileExtension]; | 3239 stringByAppendingString:fileExtension]; |
(...skipping 15 matching lines...) Expand all Loading... |
3257 // Save the image to photos. | 3255 // Save the image to photos. |
3258 [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ | 3256 [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ |
3259 [PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL:fileURL]; | 3257 [PHAssetChangeRequest creationRequestForAssetFromImageAtFileURL:fileURL]; |
3260 } | 3258 } |
3261 completionHandler:^(BOOL success, NSError* error) { | 3259 completionHandler:^(BOOL success, NSError* error) { |
3262 // Callback for the image saving. | 3260 // Callback for the image saving. |
3263 [self finishSavingImageWithError:error]; | 3261 [self finishSavingImageWithError:error]; |
3264 | 3262 |
3265 // Cleanup the temporary file. | 3263 // Cleanup the temporary file. |
3266 web::WebThread::PostTask( | 3264 web::WebThread::PostTask( |
3267 web::WebThread::FILE, FROM_HERE, base::BindBlock(^{ | 3265 web::WebThread::FILE, FROM_HERE, base::BindBlockArc(^{ |
3268 NSError* error = nil; | 3266 NSError* error = nil; |
3269 [[NSFileManager defaultManager] removeItemAtURL:fileURL | 3267 [[NSFileManager defaultManager] removeItemAtURL:fileURL |
3270 error:&error]; | 3268 error:&error]; |
3271 })); | 3269 })); |
3272 }]; | 3270 }]; |
3273 } | 3271 } |
3274 | 3272 |
3275 - (void)displayImageErrorAlertWithSettingsOnMainQueue { | 3273 - (void)displayImageErrorAlertWithSettingsOnMainQueue { |
3276 NSURL* settingURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; | 3274 NSURL* settingURL = [NSURL URLWithString:UIApplicationOpenSettingsURLString]; |
3277 BOOL canGoToSetting = | 3275 BOOL canGoToSetting = |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3902 CGFloat shortAxis = frame.size.width; | 3900 CGFloat shortAxis = frame.size.width; |
3903 CGFloat shortInset = kCardImageInsets.left + kCardImageInsets.right; | 3901 CGFloat shortInset = kCardImageInsets.left + kCardImageInsets.right; |
3904 shortAxis -= shortInset + 2 * ios_internal::page_animation_util::kCardMargin; | 3902 shortAxis -= shortInset + 2 * ios_internal::page_animation_util::kCardMargin; |
3905 CGFloat aspectRatio = frame.size.height / frame.size.width; | 3903 CGFloat aspectRatio = frame.size.height / frame.size.width; |
3906 CGFloat longAxis = std::floor(aspectRatio * shortAxis); | 3904 CGFloat longAxis = std::floor(aspectRatio * shortAxis); |
3907 CGFloat longInset = kCardImageInsets.top + kCardImageInsets.bottom; | 3905 CGFloat longInset = kCardImageInsets.top + kCardImageInsets.bottom; |
3908 CGSize cardSize = CGSizeMake(shortAxis + shortInset, longAxis + longInset); | 3906 CGSize cardSize = CGSizeMake(shortAxis + shortInset, longAxis + longInset); |
3909 CGRect cardFrame = {frame.origin, cardSize}; | 3907 CGRect cardFrame = {frame.origin, cardSize}; |
3910 | 3908 |
3911 CardView* card = | 3909 CardView* card = |
3912 [[[CardView alloc] initWithFrame:cardFrame isIncognito:_isOffTheRecord] | 3910 [[CardView alloc] initWithFrame:cardFrame isIncognito:_isOffTheRecord]; |
3913 autorelease]; | |
3914 card.closeButtonSide = IsPortrait() ? CardCloseButtonSide::TRAILING | 3911 card.closeButtonSide = IsPortrait() ? CardCloseButtonSide::TRAILING |
3915 : CardCloseButtonSide::LEADING; | 3912 : CardCloseButtonSide::LEADING; |
3916 [_contentArea addSubview:card]; | 3913 [_contentArea addSubview:card]; |
3917 return card; | 3914 return card; |
3918 } | 3915 } |
3919 | 3916 |
3920 #pragma mark - Command Handling | 3917 #pragma mark - Command Handling |
3921 | 3918 |
3922 - (IBAction)chromeExecuteCommand:(id)sender { | 3919 - (IBAction)chromeExecuteCommand:(id)sender { |
3923 NSInteger command = [sender tag]; | 3920 NSInteger command = [sender tag]; |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4423 | 4420 |
4424 #if !defined(NDEBUG) | 4421 #if !defined(NDEBUG) |
4425 - (void)viewSource { | 4422 - (void)viewSource { |
4426 Tab* tab = [_model currentTab]; | 4423 Tab* tab = [_model currentTab]; |
4427 DCHECK(tab); | 4424 DCHECK(tab); |
4428 CRWWebController* webController = tab.webController; | 4425 CRWWebController* webController = tab.webController; |
4429 NSString* script = @"document.documentElement.outerHTML;"; | 4426 NSString* script = @"document.documentElement.outerHTML;"; |
4430 base::WeakNSObject<Tab> weakTab(tab); | 4427 base::WeakNSObject<Tab> weakTab(tab); |
4431 base::WeakNSObject<BrowserViewController> weakSelf(self); | 4428 base::WeakNSObject<BrowserViewController> weakSelf(self); |
4432 web::JavaScriptResultBlock completionHandlerBlock = ^(id result, NSError*) { | 4429 web::JavaScriptResultBlock completionHandlerBlock = ^(id result, NSError*) { |
4433 base::scoped_nsobject<Tab> strongTab([weakTab retain]); | 4430 base::scoped_nsobject<Tab> strongTab(weakTab); |
4434 if (!strongTab) | 4431 if (!strongTab) |
4435 return; | 4432 return; |
4436 if (![result isKindOfClass:[NSString class]]) | 4433 if (![result isKindOfClass:[NSString class]]) |
4437 result = @"Not an HTML page"; | 4434 result = @"Not an HTML page"; |
4438 std::string base64HTML; | 4435 std::string base64HTML; |
4439 base::Base64Encode(base::SysNSStringToUTF8(result), &base64HTML); | 4436 base::Base64Encode(base::SysNSStringToUTF8(result), &base64HTML); |
4440 GURL URL(std::string("data:text/plain;charset=utf-8;base64,") + base64HTML); | 4437 GURL URL(std::string("data:text/plain;charset=utf-8;base64,") + base64HTML); |
4441 web::Referrer referrer([strongTab url], web::ReferrerPolicyDefault); | 4438 web::Referrer referrer([strongTab url], web::ReferrerPolicyDefault); |
4442 | 4439 |
4443 [[weakSelf tabModel] | 4440 [[weakSelf tabModel] |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4727 CGSize panelContainerSize = self.view.bounds.size; | 4724 CGSize panelContainerSize = self.view.bounds.size; |
4728 if (IsIPadIdiom()) { | 4725 if (IsIPadIdiom()) { |
4729 config = [PadPanelConfiguration | 4726 config = [PadPanelConfiguration |
4730 configurationForContainerSize:panelContainerSize | 4727 configurationForContainerSize:panelContainerSize |
4731 horizontalSizeClass:self.traitCollection.horizontalSizeClass]; | 4728 horizontalSizeClass:self.traitCollection.horizontalSizeClass]; |
4732 } else { | 4729 } else { |
4733 config = [PhonePanelConfiguration | 4730 config = [PhonePanelConfiguration |
4734 configurationForContainerSize:panelContainerSize | 4731 configurationForContainerSize:panelContainerSize |
4735 horizontalSizeClass:self.traitCollection.horizontalSizeClass]; | 4732 horizontalSizeClass:self.traitCollection.horizontalSizeClass]; |
4736 } | 4733 } |
4737 ContextualSearchPanelView* newPanel = [[[ContextualSearchPanelView alloc] | 4734 ContextualSearchPanelView* newPanel = |
4738 initWithConfiguration:config] autorelease]; | 4735 [[ContextualSearchPanelView alloc] initWithConfiguration:config]; |
4739 [newPanel addMotionObserver:self]; | 4736 [newPanel addMotionObserver:self]; |
4740 [newPanel addMotionObserver:_contextualSearchMask]; | 4737 [newPanel addMotionObserver:_contextualSearchMask]; |
4741 return newPanel; | 4738 return newPanel; |
4742 } | 4739 } |
4743 | 4740 |
4744 #pragma mark - ContextualSearchPanelMotionObserver | 4741 #pragma mark - ContextualSearchPanelMotionObserver |
4745 | 4742 |
4746 - (void)panel:(ContextualSearchPanelView*)panel | 4743 - (void)panel:(ContextualSearchPanelView*)panel |
4747 didMoveWithMotion:(ContextualSearch::PanelMotion)motion { | 4744 didMoveWithMotion:(ContextualSearch::PanelMotion)motion { |
4748 // If the header is offset, it's offscreen (or moving offscreen) and the | 4745 // If the header is offset, it's offscreen (or moving offscreen) and the |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5015 NSString* title = l10n_util::GetNSString(titleMessageId); | 5012 NSString* title = l10n_util::GetNSString(titleMessageId); |
5016 NSString* message = l10n_util::GetNSString(messageId); | 5013 NSString* message = l10n_util::GetNSString(messageId); |
5017 [self showErrorAlertWithStringTitle:title message:message]; | 5014 [self showErrorAlertWithStringTitle:title message:message]; |
5018 } | 5015 } |
5019 | 5016 |
5020 - (void)showErrorAlertWithStringTitle:(NSString*)title | 5017 - (void)showErrorAlertWithStringTitle:(NSString*)title |
5021 message:(NSString*)message { | 5018 message:(NSString*)message { |
5022 // Dismiss current alert. | 5019 // Dismiss current alert. |
5023 [_alertCoordinator stop]; | 5020 [_alertCoordinator stop]; |
5024 | 5021 |
5025 _alertCoordinator.reset( | 5022 _alertCoordinator.reset([_dependencyFactory alertCoordinatorWithTitle:title |
5026 [[_dependencyFactory alertCoordinatorWithTitle:title | 5023 message:message |
5027 message:message | 5024 viewController:self]); |
5028 viewController:self] retain]); | |
5029 [_alertCoordinator start]; | 5025 [_alertCoordinator start]; |
5030 } | 5026 } |
5031 | 5027 |
5032 - (void)showSnackbar:(NSString*)message { | 5028 - (void)showSnackbar:(NSString*)message { |
5033 [_dependencyFactory showSnackbarWithMessage:message]; | 5029 [_dependencyFactory showSnackbarWithMessage:message]; |
5034 } | 5030 } |
5035 | 5031 |
5036 #pragma mark - Show Mail Composer methods | 5032 #pragma mark - Show Mail Composer methods |
5037 | 5033 |
5038 - (void)showMailComposer:(id)sender { | 5034 - (void)showMailComposer:(id)sender { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5140 | 5136 |
5141 - (UIView*)voiceSearchButton { | 5137 - (UIView*)voiceSearchButton { |
5142 return _voiceSearchButton; | 5138 return _voiceSearchButton; |
5143 } | 5139 } |
5144 | 5140 |
5145 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5141 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
5146 return [self currentLogoAnimationControllerOwner]; | 5142 return [self currentLogoAnimationControllerOwner]; |
5147 } | 5143 } |
5148 | 5144 |
5149 @end | 5145 @end |
OLD | NEW |