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

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

Issue 2643753002: Add the suggestions UI in chrome (Closed)
Patch Set: Update comments Created 3 years, 11 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 | « ios/chrome/browser/ui/BUILD.gn ('k') | ios/chrome/browser/ui/commands/ios_command_ids.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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 3705 matching lines...) Expand 10 before | Expand all | Expand 10 after
4102 // before sending the command up the responder chain. 4107 // before sending the command up the responder chain.
4103 if ([sender isKindOfClass:[UIView class]]) 4108 if ([sender isKindOfClass:[UIView class]])
4104 _voiceSearchButton.reset(sender); 4109 _voiceSearchButton.reset(sender);
4105 [super chromeExecuteCommand:sender]; 4110 [super chromeExecuteCommand:sender];
4106 break; 4111 break;
4107 case IDC_SHOW_QR_SCANNER: 4112 case IDC_SHOW_QR_SCANNER:
4108 if (experimental_flags::IsQRCodeReaderEnabled()) { 4113 if (experimental_flags::IsQRCodeReaderEnabled()) {
4109 [self showQRScanner]; 4114 [self showQRScanner];
4110 } 4115 }
4111 break; 4116 break;
4117 case IDC_SHOW_SUGGESTIONS:
4118 if (experimental_flags::IsSuggestionsUIEnabled()) {
4119 [self showSuggestionsUI];
4120 }
4121 break;
4112 default: 4122 default:
4113 // Unknown commands get sent up the responder chain. 4123 // Unknown commands get sent up the responder chain.
4114 [super chromeExecuteCommand:sender]; 4124 [super chromeExecuteCommand:sender];
4115 break; 4125 break;
4116 } 4126 }
4117 } 4127 }
4118 4128
4119 - (void)closeCurrentTab { 4129 - (void)closeCurrentTab {
4120 Tab* currentTab = [_model currentTab]; 4130 Tab* currentTab = [_model currentTab];
4121 NSUInteger tabIndex = [_model indexOfTab:currentTab]; 4131 NSUInteger tabIndex = [_model indexOfTab:currentTab];
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
4207 4217
4208 [_printController dismissAnimated:YES]; 4218 [_printController dismissAnimated:YES];
4209 _printController.reset(); 4219 _printController.reset();
4210 if (_noTabsController.get()) 4220 if (_noTabsController.get())
4211 [_noTabsController dismissToolsMenuPopup]; 4221 [_noTabsController dismissToolsMenuPopup];
4212 else 4222 else
4213 [_toolbarController dismissToolsMenuPopup]; 4223 [_toolbarController dismissToolsMenuPopup];
4214 [_contextMenuCoordinator stop]; 4224 [_contextMenuCoordinator stop];
4215 [self dismissRateThisAppDialog]; 4225 [self dismissRateThisAppDialog];
4216 4226
4227 [_contentSuggestionsCoordinator stop];
4228
4217 if (self.presentedViewController) { 4229 if (self.presentedViewController) {
4218 // Dismisses any other modal controllers that may be present, e.g. Recent 4230 // Dismisses any other modal controllers that may be present, e.g. Recent
4219 // Tabs. 4231 // Tabs.
4220 // Note that currently, some controllers like the bookmark ones were already 4232 // Note that currently, some controllers like the bookmark ones were already
4221 // dismissed (in this example in -dismissBookmarkModalControllerAnimated:), 4233 // dismissed (in this example in -dismissBookmarkModalControllerAnimated:),
4222 // but are still reported as the presentedViewController. The result is that 4234 // but are still reported as the presentedViewController. The result is that
4223 // this will call -dismissViewControllerAnimated:completion: a second time 4235 // this will call -dismissViewControllerAnimated:completion: a second time
4224 // on it. It is not per se an issue, as it is a no-op. The problem is that 4236 // on it. It is not per se an issue, as it is a no-op. The problem is that
4225 // in such a case, the completion block is not called. 4237 // in such a case, the completion block is not called.
4226 // To ensure the completion is called, nil is passed here, and the 4238 // To ensure the completion is called, nil is passed here, and the
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
4366 4378
4367 - (void)showQRScanner { 4379 - (void)showQRScanner {
4368 _qrScannerViewController.reset( 4380 _qrScannerViewController.reset(
4369 [[QRScannerViewController alloc] initWithDelegate:_toolbarController]); 4381 [[QRScannerViewController alloc] initWithDelegate:_toolbarController]);
4370 [self presentViewController:[_qrScannerViewController 4382 [self presentViewController:[_qrScannerViewController
4371 getViewControllerToPresent] 4383 getViewControllerToPresent]
4372 animated:YES 4384 animated:YES
4373 completion:nil]; 4385 completion:nil];
4374 } 4386 }
4375 4387
4388 - (void)showSuggestionsUI {
4389 if (!_contentSuggestionsCoordinator) {
4390 _contentSuggestionsCoordinator.reset([[ContentSuggestionsCoordinator alloc]
4391 initWithBaseViewController:self]);
4392 }
4393 [_contentSuggestionsCoordinator start];
4394 }
4395
4376 - (void)showNTPPanel:(NewTabPage::PanelIdentifier)panel { 4396 - (void)showNTPPanel:(NewTabPage::PanelIdentifier)panel {
4377 DCHECK(self.visible || self.dismissingModal); 4397 DCHECK(self.visible || self.dismissingModal);
4378 GURL url(kChromeUINewTabURL); 4398 GURL url(kChromeUINewTabURL);
4379 std::string fragment(NewTabPage::FragmentFromIdentifier(panel)); 4399 std::string fragment(NewTabPage::FragmentFromIdentifier(panel));
4380 if (fragment != "") { 4400 if (fragment != "") {
4381 GURL::Replacements replacement; 4401 GURL::Replacements replacement;
4382 replacement.SetRefStr(fragment); 4402 replacement.SetRefStr(fragment);
4383 url = url.ReplaceComponents(replacement); 4403 url = url.ReplaceComponents(replacement);
4384 } 4404 }
4385 Tab* tab = [_model currentTab]; 4405 Tab* tab = [_model currentTab];
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
5138 5158
5139 - (UIView*)voiceSearchButton { 5159 - (UIView*)voiceSearchButton {
5140 return _voiceSearchButton; 5160 return _voiceSearchButton;
5141 } 5161 }
5142 5162
5143 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner { 5163 - (id<LogoAnimationControllerOwner>)logoAnimationControllerOwner {
5144 return [self currentLogoAnimationControllerOwner]; 5164 return [self currentLogoAnimationControllerOwner];
5145 } 5165 }
5146 5166
5147 @end 5167 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/ui/BUILD.gn ('k') | ios/chrome/browser/ui/commands/ios_command_ids.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698