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

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

Issue 2719513003: Adding success/failure notification haptics for HUD display. (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
« no previous file with comments | « no previous file | ios/chrome/browser/ui/uikit_ui_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 3388 matching lines...) Expand 10 before | Expand all | Expand 10 after
3399 [[_model currentTab] goToItem:selectedCell.entry.navigationItem]; 3399 [[_model currentTab] goToItem:selectedCell.entry.navigationItem];
3400 [_toolbarController dismissTabHistoryPopup]; 3400 [_toolbarController dismissTabHistoryPopup];
3401 } 3401 }
3402 3402
3403 - (void)print { 3403 - (void)print {
3404 Tab* currentTab = [_model currentTab]; 3404 Tab* currentTab = [_model currentTab];
3405 // The UI should prevent users from printing non-printable pages. However, a 3405 // The UI should prevent users from printing non-printable pages. However, a
3406 // redirection to an un-printable page can happen before it is reflected in 3406 // redirection to an un-printable page can happen before it is reflected in
3407 // the UI. 3407 // the UI.
3408 if (![currentTab viewForPrinting]) { 3408 if (![currentTab viewForPrinting]) {
3409 TriggerHapticFeedbackForNotification(UINotificationFeedbackTypeError);
3409 [self showSnackbar:l10n_util::GetNSString(IDS_IOS_CANNOT_PRINT_PAGE_ERROR)]; 3410 [self showSnackbar:l10n_util::GetNSString(IDS_IOS_CANNOT_PRINT_PAGE_ERROR)];
3410 return; 3411 return;
3411 } 3412 }
3412 DCHECK(_browserState); 3413 DCHECK(_browserState);
3413 if (!_printController.get()) { 3414 if (!_printController.get()) {
3414 _printController.reset([[PrintController alloc] 3415 _printController.reset([[PrintController alloc]
3415 initWithContextGetter:_browserState->GetRequestContext()]); 3416 initWithContextGetter:_browserState->GetRequestContext()]);
3416 } 3417 }
3417 [_printController printView:[currentTab viewForPrinting] 3418 [_printController printView:[currentTab viewForPrinting]
3418 withTitle:[currentTab title] 3419 withTitle:[currentTab title]
3419 viewController:self]; 3420 viewController:self];
3420 } 3421 }
3421 3422
3422 - (void)addToReadingListURL:(const GURL&)URL title:(NSString*)title { 3423 - (void)addToReadingListURL:(const GURL&)URL title:(NSString*)title {
3423 if (!reading_list::switches::IsReadingListEnabled()) { 3424 if (!reading_list::switches::IsReadingListEnabled()) {
3424 return; 3425 return;
3425 } 3426 }
3426 base::RecordAction(UserMetricsAction("MobileReadingListAdd")); 3427 base::RecordAction(UserMetricsAction("MobileReadingListAdd"));
3427 3428
3428 ReadingListModel* readingModel = 3429 ReadingListModel* readingModel =
3429 ReadingListModelFactory::GetForBrowserState(_browserState); 3430 ReadingListModelFactory::GetForBrowserState(_browserState);
3430 readingModel->AddEntry(URL, base::SysNSStringToUTF8(title), 3431 readingModel->AddEntry(URL, base::SysNSStringToUTF8(title),
3431 reading_list::ADDED_VIA_CURRENT_APP); 3432 reading_list::ADDED_VIA_CURRENT_APP);
3432 3433
3434 TriggerHapticFeedbackForNotification(UINotificationFeedbackTypeSuccess);
3433 [self showSnackbar:l10n_util::GetNSString( 3435 [self showSnackbar:l10n_util::GetNSString(
3434 IDS_IOS_READING_LIST_SNACKBAR_MESSAGE)]; 3436 IDS_IOS_READING_LIST_SNACKBAR_MESSAGE)];
3435 } 3437 }
3436 3438
3437 #pragma mark - Keyboard commands management 3439 #pragma mark - Keyboard commands management
3438 3440
3439 - (BOOL)shouldRegisterKeyboardCommands { 3441 - (BOOL)shouldRegisterKeyboardCommands {
3440 if ([self presentedViewController]) 3442 if ([self presentedViewController])
3441 return NO; 3443 return NO;
3442 3444
(...skipping 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
4844 - (void)shareDidComplete:(ShareTo::ShareResult)shareStatus 4846 - (void)shareDidComplete:(ShareTo::ShareResult)shareStatus
4845 successMessage:(NSString*)message { 4847 successMessage:(NSString*)message {
4846 // The shareTo dialog dismisses itself instead of through 4848 // The shareTo dialog dismisses itself instead of through
4847 // |-dismissViewControllerAnimated:completion:| so we must reset the 4849 // |-dismissViewControllerAnimated:completion:| so we must reset the
4848 // presenting state here. 4850 // presenting state here.
4849 self.presenting = NO; 4851 self.presenting = NO;
4850 [self.dialogPresenter tryToPresent]; 4852 [self.dialogPresenter tryToPresent];
4851 4853
4852 switch (shareStatus) { 4854 switch (shareStatus) {
4853 case ShareTo::SHARE_SUCCESS: 4855 case ShareTo::SHARE_SUCCESS:
4854 if ([message length]) 4856 if ([message length]) {
4857 TriggerHapticFeedbackForNotification(UINotificationFeedbackTypeSuccess);
4855 [self showSnackbar:message]; 4858 [self showSnackbar:message];
4859 }
4856 break; 4860 break;
4857 case ShareTo::SHARE_ERROR: 4861 case ShareTo::SHARE_ERROR:
4858 [self showErrorAlert:IDS_IOS_SHARE_TO_ERROR_ALERT_TITLE 4862 [self showErrorAlert:IDS_IOS_SHARE_TO_ERROR_ALERT_TITLE
4859 message:IDS_IOS_SHARE_TO_ERROR_ALERT]; 4863 message:IDS_IOS_SHARE_TO_ERROR_ALERT];
4860 break; 4864 break;
4861 case ShareTo::SHARE_NETWORK_FAILURE: 4865 case ShareTo::SHARE_NETWORK_FAILURE:
4862 [self showErrorAlert:IDS_IOS_SHARE_TO_NETWORK_ERROR_ALERT_TITLE 4866 [self showErrorAlert:IDS_IOS_SHARE_TO_NETWORK_ERROR_ALERT_TITLE
4863 message:IDS_IOS_SHARE_TO_NETWORK_ERROR_ALERT]; 4867 message:IDS_IOS_SHARE_TO_NETWORK_ERROR_ALERT];
4864 break; 4868 break;
4865 case ShareTo::SHARE_SIGN_IN_FAILURE: 4869 case ShareTo::SHARE_SIGN_IN_FAILURE:
(...skipping 13 matching lines...) Expand all
4879 switch (shareStatus) { 4883 switch (shareStatus) {
4880 case ShareTo::SHARE_SUCCESS: { 4884 case ShareTo::SHARE_SUCCESS: {
4881 PasswordController* passwordController = 4885 PasswordController* passwordController =
4882 [[_model currentTab] passwordController]; 4886 [[_model currentTab] passwordController];
4883 __block BOOL shown = NO; 4887 __block BOOL shown = NO;
4884 [passwordController findAndFillPasswordForms:username 4888 [passwordController findAndFillPasswordForms:username
4885 password:password 4889 password:password
4886 completionHandler:^(BOOL completed) { 4890 completionHandler:^(BOOL completed) {
4887 if (shown || !completed || ![message length]) 4891 if (shown || !completed || ![message length])
4888 return; 4892 return;
4893 TriggerHapticFeedbackForNotification(
4894 UINotificationFeedbackTypeSuccess);
4889 [self showSnackbar:message]; 4895 [self showSnackbar:message];
4890 shown = YES; 4896 shown = YES;
4891 }]; 4897 }];
4892 break; 4898 break;
4893 } 4899 }
4894 default: 4900 default:
4895 break; 4901 break;
4896 } 4902 }
4897 } 4903 }
4898 4904
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
5025 5031
5026 - (UIView*)voiceSearchButton { 5032 - (UIView*)voiceSearchButton {
5027 return _voiceSearchButton; 5033 return _voiceSearchButton;
5028 } 5034 }
5029 5035
5030 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { 5036 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
5031 return [self currentLogoAnimationControllerOwner]; 5037 return [self currentLogoAnimationControllerOwner];
5032 } 5038 }
5033 5039
5034 @end 5040 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/ui/uikit_ui_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698