| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "components/search_engines/search_engines_pref_names.h" | 43 #include "components/search_engines/search_engines_pref_names.h" |
| 44 #include "components/search_engines/template_url_service.h" | 44 #include "components/search_engines/template_url_service.h" |
| 45 #include "components/sessions/core/tab_restore_service_helper.h" | 45 #include "components/sessions/core/tab_restore_service_helper.h" |
| 46 #include "components/strings/grit/components_strings.h" | 46 #include "components/strings/grit/components_strings.h" |
| 47 #include "components/toolbar/toolbar_model_impl.h" | 47 #include "components/toolbar/toolbar_model_impl.h" |
| 48 #include "ios/chrome/app/tests_hook.h" | 48 #include "ios/chrome/app/tests_hook.h" |
| 49 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" | 49 #include "ios/chrome/browser/bookmarks/bookmark_model_factory.h" |
| 50 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" | 50 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 51 #include "ios/chrome/browser/chrome_url_constants.h" | 51 #include "ios/chrome/browser/chrome_url_constants.h" |
| 52 #include "ios/chrome/browser/chrome_url_util.h" | 52 #include "ios/chrome/browser/chrome_url_util.h" |
| 53 #import "ios/chrome/browser/content_suggestions/content_suggestions_coordinator.
h" |
| 53 #include "ios/chrome/browser/experimental_flags.h" | 54 #include "ios/chrome/browser/experimental_flags.h" |
| 54 #import "ios/chrome/browser/favicon/favicon_loader.h" | 55 #import "ios/chrome/browser/favicon/favicon_loader.h" |
| 55 #include "ios/chrome/browser/favicon/ios_chrome_favicon_loader_factory.h" | 56 #include "ios/chrome/browser/favicon/ios_chrome_favicon_loader_factory.h" |
| 56 #import "ios/chrome/browser/find_in_page/find_in_page_controller.h" | 57 #import "ios/chrome/browser/find_in_page/find_in_page_controller.h" |
| 57 #import "ios/chrome/browser/find_in_page/find_in_page_model.h" | 58 #import "ios/chrome/browser/find_in_page/find_in_page_model.h" |
| 58 #include "ios/chrome/browser/first_run/first_run.h" | 59 #include "ios/chrome/browser/first_run/first_run.h" |
| 59 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h" | 60 #import "ios/chrome/browser/geolocation/omnibox_geolocation_controller.h" |
| 60 #include "ios/chrome/browser/infobars/infobar_container_ios.h" | 61 #include "ios/chrome/browser/infobars/infobar_container_ios.h" |
| 61 #include "ios/chrome/browser/infobars/infobar_container_view.h" | 62 #include "ios/chrome/browser/infobars/infobar_container_view.h" |
| 62 #import "ios/chrome/browser/metrics/new_tab_page_uma.h" | 63 #import "ios/chrome/browser/metrics/new_tab_page_uma.h" |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 378 |
| 378 // Used to display the Page Info UI. Nil if not visible. | 379 // Used to display the Page Info UI. Nil if not visible. |
| 379 base::scoped_nsobject<PageInfoViewController> _pageInfoController; | 380 base::scoped_nsobject<PageInfoViewController> _pageInfoController; |
| 380 | 381 |
| 381 // Used to display the Voice Search UI. Nil if not visible. | 382 // Used to display the Voice Search UI. Nil if not visible. |
| 382 scoped_refptr<VoiceSearchController> _voiceSearchController; | 383 scoped_refptr<VoiceSearchController> _voiceSearchController; |
| 383 | 384 |
| 384 // Used to display the QR Scanner UI. Nil if not visible. | 385 // Used to display the QR Scanner UI. Nil if not visible. |
| 385 base::scoped_nsobject<QRScannerViewController> _qrScannerViewController; | 386 base::scoped_nsobject<QRScannerViewController> _qrScannerViewController; |
| 386 | 387 |
| 388 // Used to display the Suggestions. |
| 389 base::scoped_nsobject<ContentSuggestionsCoordinator> |
| 390 _contentSuggestionsCoordinator; |
| 391 |
| 387 // Used to display the Find In Page UI. Nil if not visible. | 392 // Used to display the Find In Page UI. Nil if not visible. |
| 388 base::scoped_nsobject<FindBarControllerIOS> _findBarController; | 393 base::scoped_nsobject<FindBarControllerIOS> _findBarController; |
| 389 | 394 |
| 390 // Used to display the No-Tabs UI for iPads. Nil if not visible. | 395 // Used to display the No-Tabs UI for iPads. Nil if not visible. |
| 391 base::scoped_nsobject<NoTabsController> _noTabsController; | 396 base::scoped_nsobject<NoTabsController> _noTabsController; |
| 392 | 397 |
| 393 // Used to display the Print UI. Nil if not visible. | 398 // Used to display the Print UI. Nil if not visible. |
| 394 base::scoped_nsobject<PrintController> _printController; | 399 base::scoped_nsobject<PrintController> _printController; |
| 395 | 400 |
| 396 // Records the set of domains for which full screen alert has already been | 401 // Records the set of domains for which full screen alert has already been |
| (...skipping 3701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4098 // before sending the command up the responder chain. | 4103 // before sending the command up the responder chain. |
| 4099 if ([sender isKindOfClass:[UIView class]]) | 4104 if ([sender isKindOfClass:[UIView class]]) |
| 4100 _voiceSearchButton.reset(sender); | 4105 _voiceSearchButton.reset(sender); |
| 4101 [super chromeExecuteCommand:sender]; | 4106 [super chromeExecuteCommand:sender]; |
| 4102 break; | 4107 break; |
| 4103 case IDC_SHOW_QR_SCANNER: | 4108 case IDC_SHOW_QR_SCANNER: |
| 4104 if (experimental_flags::IsQRCodeReaderEnabled()) { | 4109 if (experimental_flags::IsQRCodeReaderEnabled()) { |
| 4105 [self showQRScanner]; | 4110 [self showQRScanner]; |
| 4106 } | 4111 } |
| 4107 break; | 4112 break; |
| 4113 case IDC_SHOW_SUGGESTIONS: |
| 4114 if (experimental_flags::IsSuggestionsUIEnabled()) { |
| 4115 [self showSuggestionsUI]; |
| 4116 } |
| 4117 break; |
| 4108 default: | 4118 default: |
| 4109 // Unknown commands get sent up the responder chain. | 4119 // Unknown commands get sent up the responder chain. |
| 4110 [super chromeExecuteCommand:sender]; | 4120 [super chromeExecuteCommand:sender]; |
| 4111 break; | 4121 break; |
| 4112 } | 4122 } |
| 4113 } | 4123 } |
| 4114 | 4124 |
| 4115 - (void)closeCurrentTab { | 4125 - (void)closeCurrentTab { |
| 4116 Tab* currentTab = [_model currentTab]; | 4126 Tab* currentTab = [_model currentTab]; |
| 4117 NSUInteger tabIndex = [_model indexOfTab:currentTab]; | 4127 NSUInteger tabIndex = [_model indexOfTab:currentTab]; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4203 | 4213 |
| 4204 [_printController dismissAnimated:YES]; | 4214 [_printController dismissAnimated:YES]; |
| 4205 _printController.reset(); | 4215 _printController.reset(); |
| 4206 if (_noTabsController.get()) | 4216 if (_noTabsController.get()) |
| 4207 [_noTabsController dismissToolsMenuPopup]; | 4217 [_noTabsController dismissToolsMenuPopup]; |
| 4208 else | 4218 else |
| 4209 [_toolbarController dismissToolsMenuPopup]; | 4219 [_toolbarController dismissToolsMenuPopup]; |
| 4210 [_contextMenuCoordinator stop]; | 4220 [_contextMenuCoordinator stop]; |
| 4211 [self dismissRateThisAppDialog]; | 4221 [self dismissRateThisAppDialog]; |
| 4212 | 4222 |
| 4223 [_contentSuggestionsCoordinator stop]; |
| 4224 |
| 4213 if (self.presentedViewController) { | 4225 if (self.presentedViewController) { |
| 4214 // Dismisses any other modal controllers that may be present, e.g. Recent | 4226 // Dismisses any other modal controllers that may be present, e.g. Recent |
| 4215 // Tabs. | 4227 // Tabs. |
| 4216 // Note that currently, some controllers like the bookmark ones were already | 4228 // Note that currently, some controllers like the bookmark ones were already |
| 4217 // dismissed (in this example in -dismissBookmarkModalControllerAnimated:), | 4229 // dismissed (in this example in -dismissBookmarkModalControllerAnimated:), |
| 4218 // but are still reported as the presentedViewController. The result is that | 4230 // but are still reported as the presentedViewController. The result is that |
| 4219 // this will call -dismissViewControllerAnimated:completion: a second time | 4231 // this will call -dismissViewControllerAnimated:completion: a second time |
| 4220 // on it. It is not per se an issue, as it is a no-op. The problem is that | 4232 // on it. It is not per se an issue, as it is a no-op. The problem is that |
| 4221 // in such a case, the completion block is not called. | 4233 // in such a case, the completion block is not called. |
| 4222 // To ensure the completion is called, nil is passed here, and the | 4234 // To ensure the completion is called, nil is passed here, and the |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4362 | 4374 |
| 4363 - (void)showQRScanner { | 4375 - (void)showQRScanner { |
| 4364 _qrScannerViewController.reset( | 4376 _qrScannerViewController.reset( |
| 4365 [[QRScannerViewController alloc] initWithDelegate:_toolbarController]); | 4377 [[QRScannerViewController alloc] initWithDelegate:_toolbarController]); |
| 4366 [self presentViewController:[_qrScannerViewController | 4378 [self presentViewController:[_qrScannerViewController |
| 4367 getViewControllerToPresent] | 4379 getViewControllerToPresent] |
| 4368 animated:YES | 4380 animated:YES |
| 4369 completion:nil]; | 4381 completion:nil]; |
| 4370 } | 4382 } |
| 4371 | 4383 |
| 4384 - (void)showSuggestionsUI { |
| 4385 if (!_contentSuggestionsCoordinator) { |
| 4386 _contentSuggestionsCoordinator.reset([[ContentSuggestionsCoordinator alloc] |
| 4387 initWithBaseViewController:self]); |
| 4388 } |
| 4389 [_contentSuggestionsCoordinator start]; |
| 4390 } |
| 4391 |
| 4372 - (void)showNTPPanel:(NewTabPage::PanelIdentifier)panel { | 4392 - (void)showNTPPanel:(NewTabPage::PanelIdentifier)panel { |
| 4373 DCHECK(self.visible || self.dismissingModal); | 4393 DCHECK(self.visible || self.dismissingModal); |
| 4374 GURL url(kChromeUINewTabURL); | 4394 GURL url(kChromeUINewTabURL); |
| 4375 std::string fragment(NewTabPage::FragmentFromIdentifier(panel)); | 4395 std::string fragment(NewTabPage::FragmentFromIdentifier(panel)); |
| 4376 if (fragment != "") { | 4396 if (fragment != "") { |
| 4377 GURL::Replacements replacement; | 4397 GURL::Replacements replacement; |
| 4378 replacement.SetRefStr(fragment); | 4398 replacement.SetRefStr(fragment); |
| 4379 url = url.ReplaceComponents(replacement); | 4399 url = url.ReplaceComponents(replacement); |
| 4380 } | 4400 } |
| 4381 Tab* tab = [_model currentTab]; | 4401 Tab* tab = [_model currentTab]; |
| (...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5134 | 5154 |
| 5135 - (UIView*)voiceSearchButton { | 5155 - (UIView*)voiceSearchButton { |
| 5136 return _voiceSearchButton; | 5156 return _voiceSearchButton; |
| 5137 } | 5157 } |
| 5138 | 5158 |
| 5139 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { | 5159 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { |
| 5140 return [self currentLogoAnimationControllerOwner]; | 5160 return [self currentLogoAnimationControllerOwner]; |
| 5141 } | 5161 } |
| 5142 | 5162 |
| 5143 @end | 5163 @end |
| OLD | NEW |