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

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

Issue 2682043002: Expose thumbnails of pages to iOS share extensions. (Closed)
Patch Set: Created 3 years, 10 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 #import "ios/chrome/browser/snapshots/snapshot_cache.h" 74 #import "ios/chrome/browser/snapshots/snapshot_cache.h"
75 #import "ios/chrome/browser/snapshots/snapshot_overlay.h" 75 #import "ios/chrome/browser/snapshots/snapshot_overlay.h"
76 #import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h" 76 #import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h"
77 #import "ios/chrome/browser/storekit_launcher.h" 77 #import "ios/chrome/browser/storekit_launcher.h"
78 #import "ios/chrome/browser/tabs/tab.h" 78 #import "ios/chrome/browser/tabs/tab.h"
79 #import "ios/chrome/browser/tabs/tab_dialog_delegate.h" 79 #import "ios/chrome/browser/tabs/tab_dialog_delegate.h"
80 #import "ios/chrome/browser/tabs/tab_headers_delegate.h" 80 #import "ios/chrome/browser/tabs/tab_headers_delegate.h"
81 #import "ios/chrome/browser/tabs/tab_model.h" 81 #import "ios/chrome/browser/tabs/tab_model.h"
82 #import "ios/chrome/browser/tabs/tab_model_observer.h" 82 #import "ios/chrome/browser/tabs/tab_model_observer.h"
83 #import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h" 83 #import "ios/chrome/browser/tabs/tab_snapshotting_delegate.h"
84 #import "ios/chrome/browser/ui/activity_services/chrome_activity_item_thumbnail_ generator.h"
84 #import "ios/chrome/browser/ui/activity_services/share_protocol.h" 85 #import "ios/chrome/browser/ui/activity_services/share_protocol.h"
85 #import "ios/chrome/browser/ui/activity_services/share_to_data.h" 86 #import "ios/chrome/browser/ui/activity_services/share_to_data.h"
87 #import "ios/chrome/browser/ui/activity_services/share_to_data_builder.h"
86 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h" 88 #import "ios/chrome/browser/ui/alert_coordinator/alert_coordinator.h"
87 #import "ios/chrome/browser/ui/authentication/re_signin_infobar_delegate.h" 89 #import "ios/chrome/browser/ui/authentication/re_signin_infobar_delegate.h"
88 #import "ios/chrome/browser/ui/background_generator.h" 90 #import "ios/chrome/browser/ui/background_generator.h"
89 #import "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h" 91 #import "ios/chrome/browser/ui/bookmarks/bookmark_interaction_controller.h"
90 #import "ios/chrome/browser/ui/browser_container_view.h" 92 #import "ios/chrome/browser/ui/browser_container_view.h"
91 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h" 93 #import "ios/chrome/browser/ui/browser_view_controller_dependency_factory.h"
92 #import "ios/chrome/browser/ui/chrome_web_view_factory.h" 94 #import "ios/chrome/browser/ui/chrome_web_view_factory.h"
93 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h" 95 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
94 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" 96 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
95 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" 97 #include "ios/chrome/browser/ui/commands/ios_command_ids.h"
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 - (void)showNoTabsUI; 587 - (void)showNoTabsUI;
586 // Dismisses the No-Tabs UI with animation. 588 // Dismisses the No-Tabs UI with animation.
587 - (void)dismissNoTabsUI; 589 - (void)dismissNoTabsUI;
588 590
589 // Shows the tools menu popup. 591 // Shows the tools menu popup.
590 - (void)showToolsMenuPopup; 592 - (void)showToolsMenuPopup;
591 // Add all delegates to the provided |tab|. 593 // Add all delegates to the provided |tab|.
592 - (void)installDelegatesForTab:(Tab*)tab; 594 - (void)installDelegatesForTab:(Tab*)tab;
593 // Closes the current tab, with animation if applicable. 595 // Closes the current tab, with animation if applicable.
594 - (void)closeCurrentTab; 596 - (void)closeCurrentTab;
595 // Returns an autoreleased share to data for |tab|.
596 - (ShareToData*)shareToDataForTab:(Tab*)tab;
597 // Shows the menu to initiate sharing |data|. 597 // Shows the menu to initiate sharing |data|.
598 - (void)sharePageWithData:(ShareToData*)data; 598 - (void)sharePageWithData:(ShareToData*)data;
599 // Convenience method to share the current page. 599 // Convenience method to share the current page.
600 - (void)sharePage; 600 - (void)sharePage;
601 // Prints the web page in the current tab. 601 // Prints the web page in the current tab.
602 - (void)print; 602 - (void)print;
603 // Shows the Online Help Page in a tab. 603 // Shows the Online Help Page in a tab.
604 - (void)showHelpPage; 604 - (void)showHelpPage;
605 // Show the bookmarks page. 605 // Show the bookmarks page.
606 - (void)showAllBookmarks; 606 - (void)showAllBookmarks;
(...skipping 3528 matching lines...) Expand 10 before | Expand all | Expand 10 after
4135 // Do not animate close in iPad. 4135 // Do not animate close in iPad.
4136 if (!IsIPadIdiom()) { 4136 if (!IsIPadIdiom()) {
4137 [_contentArea addSubview:exitingPage]; 4137 [_contentArea addSubview:exitingPage];
4138 ios_internal::page_animation_util::AnimateOutWithCompletion( 4138 ios_internal::page_animation_util::AnimateOutWithCompletion(
4139 exitingPage, 0, YES, IsPortrait(), ^{ 4139 exitingPage, 0, YES, IsPortrait(), ^{
4140 [exitingPage removeFromSuperview]; 4140 [exitingPage removeFromSuperview];
4141 }); 4141 });
4142 } 4142 }
4143 } 4143 }
4144 4144
4145 - (ShareToData*)shareToDataForTab:(Tab*)tab {
4146 // For crash documented in crbug.com/503955, tab.url which is being passed
4147 // as a reference parameter caused a crash due to invalid address which
4148 // which suggests that |tab| may be deallocated along the way. Check that
4149 // tab is still valid by checking webState which would be deallocated if
4150 // tab is being closed.
4151 if (!tab.webState)
4152 return nil;
4153 DCHECK(tab);
4154 // If the original page title exists, it is expected to match the tab title.
4155 // If this ever changes, then a decision has to be made on which one should
4156 // be used for sharing.
4157 DCHECK(!tab.originalTitle || [tab.originalTitle isEqualToString:tab.title]);
4158 BOOL isPagePrintable = [tab viewForPrinting] != nil;
4159 return [[[ShareToData alloc] initWithURL:tab.url
4160 title:tab.title
4161 isOriginalTitle:(tab.originalTitle != nil)
4162 isPagePrintable:isPagePrintable] autorelease];
4163 }
4164
4165 - (void)sharePage { 4145 - (void)sharePage {
4166 ShareToData* data = [self shareToDataForTab:[_model currentTab]]; 4146 ShareToData* data = activity_services::ShareToDataForTab([_model currentTab]);
4167 if (data) 4147 if (data)
4168 [self sharePageWithData:data]; 4148 [self sharePageWithData:data];
4169 } 4149 }
4170 4150
4171 - (void)sharePageWithData:(ShareToData*)data { 4151 - (void)sharePageWithData:(ShareToData*)data {
4172 id<ShareProtocol> controller = [_dependencyFactory shareControllerInstance]; 4152 id<ShareProtocol> controller = [_dependencyFactory shareControllerInstance];
4173 if ([controller isActive]) 4153 if ([controller isActive])
4174 return; 4154 return;
4175 CGRect fromRect = [_toolbarController shareButtonAnchorRect]; 4155 CGRect fromRect = [_toolbarController shareButtonAnchorRect];
4176 UIView* inView = [_toolbarController shareButtonView]; 4156 UIView* inView = [_toolbarController shareButtonView];
(...skipping 956 matching lines...) Expand 10 before | Expand all | Expand 10 after
5133 5113
5134 - (UIView*)voiceSearchButton { 5114 - (UIView*)voiceSearchButton {
5135 return _voiceSearchButton; 5115 return _voiceSearchButton;
5136 } 5116 }
5137 5117
5138 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { 5118 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
5139 return [self currentLogoAnimationControllerOwner]; 5119 return [self currentLogoAnimationControllerOwner];
5140 } 5120 }
5141 5121
5142 @end 5122 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698