| 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 24 matching lines...) Expand all Loading... |
| 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/threading/sequenced_worker_pool.h" | 38 #include "base/threading/sequenced_worker_pool.h" |
| 39 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 39 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
| 40 #include "components/bookmarks/browser/bookmark_model.h" | 40 #include "components/bookmarks/browser/bookmark_model.h" |
| 41 #include "components/image_fetcher/ios/ios_image_data_fetcher_wrapper.h" | 41 #include "components/image_fetcher/ios/ios_image_data_fetcher_wrapper.h" |
| 42 #include "components/infobars/core/infobar_manager.h" | 42 #include "components/infobars/core/infobar_manager.h" |
| 43 #include "components/prefs/pref_service.h" | 43 #include "components/prefs/pref_service.h" |
| 44 #include "components/reading_list/core/reading_list_model.h" | 44 #include "components/reading_list/core/reading_list_model.h" |
| 45 #include "components/reading_list/core/reading_list_switches.h" | |
| 46 #include "components/search_engines/search_engines_pref_names.h" | 45 #include "components/search_engines/search_engines_pref_names.h" |
| 47 #include "components/search_engines/template_url_service.h" | 46 #include "components/search_engines/template_url_service.h" |
| 48 #include "components/sessions/core/tab_restore_service_helper.h" | 47 #include "components/sessions/core/tab_restore_service_helper.h" |
| 49 #include "components/strings/grit/components_strings.h" | 48 #include "components/strings/grit/components_strings.h" |
| 50 #include "components/toolbar/toolbar_model_impl.h" | 49 #include "components/toolbar/toolbar_model_impl.h" |
| 51 #include "ios/chrome/app/tests_hook.h" | 50 #include "ios/chrome/app/tests_hook.h" |
| 52 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" | 51 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" |
| 53 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 52 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 54 #include "ios/chrome/browser/chrome_url_constants.h" | 53 #include "ios/chrome/browser/chrome_url_constants.h" |
| 55 #include "ios/chrome/browser/chrome_url_util.h" | 54 #include "ios/chrome/browser/chrome_url_util.h" |
| (...skipping 2474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2530 Record(ACTION_OPEN_IN_INCOGNITO_TAB, isImage, isLink); | 2529 Record(ACTION_OPEN_IN_INCOGNITO_TAB, isImage, isLink); |
| 2531 [weakSelf webPageOrderedOpen:link | 2530 [weakSelf webPageOrderedOpen:link |
| 2532 referrer:referrer | 2531 referrer:referrer |
| 2533 inIncognito:YES | 2532 inIncognito:YES |
| 2534 inBackground:NO | 2533 inBackground:NO |
| 2535 appendTo:kCurrentTab]; | 2534 appendTo:kCurrentTab]; |
| 2536 }; | 2535 }; |
| 2537 [_contextMenuCoordinator addItemWithTitle:title action:action]; | 2536 [_contextMenuCoordinator addItemWithTitle:title action:action]; |
| 2538 } | 2537 } |
| 2539 } | 2538 } |
| 2540 if (link.SchemeIsHTTPOrHTTPS() && | 2539 if (link.SchemeIsHTTPOrHTTPS()) { |
| 2541 reading_list::switches::IsReadingListEnabled()) { | |
| 2542 NSString* innerText = params.link_text; | 2540 NSString* innerText = params.link_text; |
| 2543 if ([innerText length] > 0) { | 2541 if ([innerText length] > 0) { |
| 2544 // Add to reading list. | 2542 // Add to reading list. |
| 2545 title = l10n_util::GetNSStringWithFixup( | 2543 title = l10n_util::GetNSStringWithFixup( |
| 2546 IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST); | 2544 IDS_IOS_CONTENT_CONTEXT_ADDTOREADINGLIST); |
| 2547 action = ^{ | 2545 action = ^{ |
| 2548 Record(ACTION_READ_LATER, isImage, isLink); | 2546 Record(ACTION_READ_LATER, isImage, isLink); |
| 2549 [weakSelf addToReadingListURL:link title:innerText]; | 2547 [weakSelf addToReadingListURL:link title:innerText]; |
| 2550 }; | 2548 }; |
| 2551 [_contextMenuCoordinator addItemWithTitle:title action:action]; | 2549 [_contextMenuCoordinator addItemWithTitle:title action:action]; |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3349 [self updateFindBar:NO shouldFocus:NO]; | 3347 [self updateFindBar:NO shouldFocus:NO]; |
| 3350 | 3348 |
| 3351 base::scoped_nsobject<ToolsMenuConfiguration> configuration( | 3349 base::scoped_nsobject<ToolsMenuConfiguration> configuration( |
| 3352 [[ToolsMenuConfiguration alloc] initWithDisplayView:[self view]]); | 3350 [[ToolsMenuConfiguration alloc] initWithDisplayView:[self view]]); |
| 3353 if ([_model count] == 0) | 3351 if ([_model count] == 0) |
| 3354 [configuration setNoOpenedTabs:YES]; | 3352 [configuration setNoOpenedTabs:YES]; |
| 3355 | 3353 |
| 3356 if (_isOffTheRecord) | 3354 if (_isOffTheRecord) |
| 3357 [configuration setInIncognito:YES]; | 3355 [configuration setInIncognito:YES]; |
| 3358 | 3356 |
| 3359 if (reading_list::switches::IsReadingListEnabled()) { | 3357 if (!_readingListMenuNotifier) { |
| 3360 if (!_readingListMenuNotifier) { | 3358 _readingListMenuNotifier.reset([[ReadingListMenuNotifier alloc] |
| 3361 _readingListMenuNotifier.reset([[ReadingListMenuNotifier alloc] | 3359 initWithReadingList:ReadingListModelFactory::GetForBrowserState( |
| 3362 initWithReadingList:ReadingListModelFactory::GetForBrowserState( | 3360 _browserState)]); |
| 3363 _browserState)]); | |
| 3364 } | |
| 3365 [configuration setReadingListMenuNotifier:_readingListMenuNotifier]; | |
| 3366 } | 3361 } |
| 3362 [configuration setReadingListMenuNotifier:_readingListMenuNotifier]; |
| 3367 | 3363 |
| 3368 [configuration setUserAgentType:self.userAgentType]; | 3364 [configuration setUserAgentType:self.userAgentType]; |
| 3369 | 3365 |
| 3370 [_toolbarController showToolsMenuPopupWithConfiguration:configuration]; | 3366 [_toolbarController showToolsMenuPopupWithConfiguration:configuration]; |
| 3371 | 3367 |
| 3372 ToolsPopupController* toolsPopupController = | 3368 ToolsPopupController* toolsPopupController = |
| 3373 [_toolbarController toolsPopupController]; | 3369 [_toolbarController toolsPopupController]; |
| 3374 if ([_model currentTab]) { | 3370 if ([_model currentTab]) { |
| 3375 BOOL isBookmarked = _toolbarModelIOS->IsCurrentTabBookmarked(); | 3371 BOOL isBookmarked = _toolbarModelIOS->IsCurrentTabBookmarked(); |
| 3376 [toolsPopupController setIsCurrentPageBookmarked:isBookmarked]; | 3372 [toolsPopupController setIsCurrentPageBookmarked:isBookmarked]; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3497 if (!_printController.get()) { | 3493 if (!_printController.get()) { |
| 3498 _printController.reset([[PrintController alloc] | 3494 _printController.reset([[PrintController alloc] |
| 3499 initWithContextGetter:_browserState->GetRequestContext()]); | 3495 initWithContextGetter:_browserState->GetRequestContext()]); |
| 3500 } | 3496 } |
| 3501 [_printController printView:[currentTab viewForPrinting] | 3497 [_printController printView:[currentTab viewForPrinting] |
| 3502 withTitle:[currentTab title] | 3498 withTitle:[currentTab title] |
| 3503 viewController:self]; | 3499 viewController:self]; |
| 3504 } | 3500 } |
| 3505 | 3501 |
| 3506 - (void)addToReadingListURL:(const GURL&)URL title:(NSString*)title { | 3502 - (void)addToReadingListURL:(const GURL&)URL title:(NSString*)title { |
| 3507 if (!reading_list::switches::IsReadingListEnabled()) { | |
| 3508 return; | |
| 3509 } | |
| 3510 base::RecordAction(UserMetricsAction("MobileReadingListAdd")); | 3503 base::RecordAction(UserMetricsAction("MobileReadingListAdd")); |
| 3511 | 3504 |
| 3512 ReadingListModel* readingModel = | 3505 ReadingListModel* readingModel = |
| 3513 ReadingListModelFactory::GetForBrowserState(_browserState); | 3506 ReadingListModelFactory::GetForBrowserState(_browserState); |
| 3514 readingModel->AddEntry(URL, base::SysNSStringToUTF8(title), | 3507 readingModel->AddEntry(URL, base::SysNSStringToUTF8(title), |
| 3515 reading_list::ADDED_VIA_CURRENT_APP); | 3508 reading_list::ADDED_VIA_CURRENT_APP); |
| 3516 | 3509 |
| 3517 TriggerHapticFeedbackForNotification(UINotificationFeedbackTypeSuccess); | 3510 TriggerHapticFeedbackForNotification(UINotificationFeedbackTypeSuccess); |
| 3518 [self showSnackbar:l10n_util::GetNSString( | 3511 [self showSnackbar:l10n_util::GetNSString( |
| 3519 IDS_IOS_READING_LIST_SNACKBAR_MESSAGE)]; | 3512 IDS_IOS_READING_LIST_SNACKBAR_MESSAGE)]; |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4066 [self showTabHistoryPopupForForwardHistory]; | 4059 [self showTabHistoryPopupForForwardHistory]; |
| 4067 break; | 4060 break; |
| 4068 case IDC_BACK_FORWARD_IN_TAB_HISTORY: | 4061 case IDC_BACK_FORWARD_IN_TAB_HISTORY: |
| 4069 DCHECK([sender isKindOfClass:[TabHistoryCell class]]); | 4062 DCHECK([sender isKindOfClass:[TabHistoryCell class]]); |
| 4070 [self navigateToSelectedEntry:sender]; | 4063 [self navigateToSelectedEntry:sender]; |
| 4071 break; | 4064 break; |
| 4072 case IDC_PRINT: | 4065 case IDC_PRINT: |
| 4073 [self print]; | 4066 [self print]; |
| 4074 break; | 4067 break; |
| 4075 case IDC_ADD_READING_LIST: { | 4068 case IDC_ADD_READING_LIST: { |
| 4076 DCHECK(reading_list::switches::IsReadingListEnabled()); | |
| 4077 ReadingListAddCommand* command = | 4069 ReadingListAddCommand* command = |
| 4078 base::mac::ObjCCastStrict<ReadingListAddCommand>(sender); | 4070 base::mac::ObjCCastStrict<ReadingListAddCommand>(sender); |
| 4079 [self addToReadingListURL:[command URL] title:[command title]]; | 4071 [self addToReadingListURL:[command URL] title:[command title]]; |
| 4080 break; | 4072 break; |
| 4081 } | 4073 } |
| 4082 case IDC_RATE_THIS_APP: | 4074 case IDC_RATE_THIS_APP: |
| 4083 [self showRateThisAppDialog]; | 4075 [self showRateThisAppDialog]; |
| 4084 break; | 4076 break; |
| 4085 case IDC_SHOW_READING_LIST: | 4077 case IDC_SHOW_READING_LIST: |
| 4086 DCHECK(reading_list::switches::IsReadingListEnabled()); | |
| 4087 [self showReadingList]; | 4078 [self showReadingList]; |
| 4088 break; | 4079 break; |
| 4089 case IDC_VOICE_SEARCH: | 4080 case IDC_VOICE_SEARCH: |
| 4090 // If the voice search command is coming from a UIView sender, store it | 4081 // If the voice search command is coming from a UIView sender, store it |
| 4091 // before sending the command up the responder chain. | 4082 // before sending the command up the responder chain. |
| 4092 if ([sender isKindOfClass:[UIView class]]) | 4083 if ([sender isKindOfClass:[UIView class]]) |
| 4093 _voiceSearchButton.reset(sender); | 4084 _voiceSearchButton.reset(sender); |
| 4094 [super chromeExecuteCommand:sender]; | 4085 [super chromeExecuteCommand:sender]; |
| 4095 break; | 4086 break; |
| 4096 case IDC_SHOW_QR_SCANNER: | 4087 case IDC_SHOW_QR_SCANNER: |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4329 - (void)showAllBookmarks { | 4320 - (void)showAllBookmarks { |
| 4330 DCHECK(self.visible || self.dismissingModal); | 4321 DCHECK(self.visible || self.dismissingModal); |
| 4331 GURL URL(kChromeUIBookmarksURL); | 4322 GURL URL(kChromeUIBookmarksURL); |
| 4332 Tab* tab = [_model currentTab]; | 4323 Tab* tab = [_model currentTab]; |
| 4333 web::NavigationManager::WebLoadParams params(URL); | 4324 web::NavigationManager::WebLoadParams params(URL); |
| 4334 params.transition_type = ui::PAGE_TRANSITION_AUTO_BOOKMARK; | 4325 params.transition_type = ui::PAGE_TRANSITION_AUTO_BOOKMARK; |
| 4335 [[tab webController] loadWithParams:params]; | 4326 [[tab webController] loadWithParams:params]; |
| 4336 } | 4327 } |
| 4337 | 4328 |
| 4338 - (void)showReadingList { | 4329 - (void)showReadingList { |
| 4339 DCHECK(reading_list::switches::IsReadingListEnabled()); | |
| 4340 _readingListCoordinator.reset([[ReadingListCoordinator alloc] | 4330 _readingListCoordinator.reset([[ReadingListCoordinator alloc] |
| 4341 initWithBaseViewController:self | 4331 initWithBaseViewController:self |
| 4342 browserState:self.browserState | 4332 browserState:self.browserState |
| 4343 loader:self]); | 4333 loader:self]); |
| 4344 | 4334 |
| 4345 [_readingListCoordinator start]; | 4335 [_readingListCoordinator start]; |
| 4346 } | 4336 } |
| 4347 | 4337 |
| 4348 - (void)showQRScanner { | 4338 - (void)showQRScanner { |
| 4349 _qrScannerViewController.reset( | 4339 _qrScannerViewController.reset( |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5127 | 5117 |
| 5128 - (UIView*)voiceSearchButton { | 5118 - (UIView*)voiceSearchButton { |
| 5129 return _voiceSearchButton; | 5119 return _voiceSearchButton; |
| 5130 } | 5120 } |
| 5131 | 5121 |
| 5132 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5122 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
| 5133 return [self currentLogoAnimationControllerOwner]; | 5123 return [self currentLogoAnimationControllerOwner]; |
| 5134 } | 5124 } |
| 5135 | 5125 |
| 5136 @end | 5126 @end |
| OLD | NEW |