Commit 0b8f4b54 authored by stkhapugin@chromium.org's avatar stkhapugin@chromium.org Committed by Commit Bot

Popup view controller

Cq-Include-Trybots: luci.chromium.try:ios-simulator-cronet;luci.chromium.try:ios-simulator-full-configs
Change-Id: I674ed55abf3313a7e93b5d7404aebcf9609ca621
Reviewed-on: https://chromium-review.googlesource.com/1235933
Commit-Queue: Stepan Khapugin <stkhapugin@chromium.org>
Reviewed-by: default avatarGauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#595845}
parent e25dccb8
......@@ -143,6 +143,7 @@ const int kLocationAuthorizationStatusCount = 4;
self.omniboxPopupCoordinator =
[self.omniboxCoordinator createPopupCoordinator:self.popupPositioner];
self.omniboxPopupCoordinator.dispatcher = self.dispatcher;
self.omniboxPopupCoordinator.webStateList = self.webStateList;
[self.omniboxPopupCoordinator start];
self.mediator =
......@@ -265,11 +266,13 @@ const int kLocationAuthorizationStatusCount = 4;
[self.viewController.dispatcher focusFakebox];
} else {
[self.omniboxCoordinator focusOmnibox];
[self.omniboxPopupCoordinator openPopup];
}
}
- (void)cancelOmniboxEdit {
[self.omniboxCoordinator endEditing];
[self.omniboxPopupCoordinator closePopup];
}
#pragma mark - LocationBarDelegate
......
......@@ -32,12 +32,14 @@ source_set("popup") {
"//ios/chrome/browser/ui:ui",
"//ios/chrome/browser/ui:ui_util",
"//ios/chrome/browser/ui/commands",
"//ios/chrome/browser/ui/ntp:util",
"//ios/chrome/browser/ui/omnibox:omnibox_popup_shared",
"//ios/chrome/browser/ui/omnibox:omnibox_util",
"//ios/chrome/browser/ui/toolbar/buttons",
"//ios/chrome/browser/ui/toolbar/public:feature_flags",
"//ios/chrome/browser/ui/toolbar/public:public",
"//ios/chrome/browser/ui/util:util",
"//ios/chrome/browser/web_state_list:web_state_list",
"//ios/web/public:public",
"//net",
]
......
......@@ -16,6 +16,7 @@ class OmniboxPopupViewIOS;
namespace ios {
class ChromeBrowserState;
}
class WebStateList;
// Coordinator for the Omnibox Popup.
@interface OmniboxPopupCoordinator : NSObject
......@@ -34,9 +35,18 @@ class ChromeBrowserState;
@property(nonatomic, assign, readonly) BOOL isOpen;
// The dispatcher for this view controller.
@property(nonatomic, readwrite, weak) CommandDispatcher* dispatcher;
// The web state list this coordinator is handling.
@property(nonatomic, assign) WebStateList* webStateList;
- (void)start;
- (void)stop;
// Opens the popup immediately. It's auto-sized to fit the suggestions.
- (void)openPopup;
// Closes the popup immediately.
- (void)closePopup;
@end
#endif // IOS_CHROME_BROWSER_UI_OMNIBOX_POPUP_OMNIBOX_POPUP_COORDINATOR_H_
......@@ -4,16 +4,20 @@
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_coordinator.h"
#include "base/feature_list.h"
#import "components/image_fetcher/ios/ios_image_data_fetcher_wrapper.h"
#include "components/omnibox/browser/autocomplete_result.h"
#include "components/omnibox/browser/omnibox_field_trial.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/chrome/browser/ui/ntp/ntp_util.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_legacy_presenter.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_mediator.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_presenter.h"
#import "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_controller.h"
#include "ios/chrome/browser/ui/omnibox/popup/omnibox_popup_view_ios.h"
#include "ios/chrome/browser/ui/ui_util.h"
#import "ios/chrome/browser/web_state_list/web_state_list.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
......@@ -91,6 +95,25 @@
return self.mediator.isOpen;
}
- (void)openPopup {
// Show shortcuts when the feature is enabled. Don't show them on NTP as they
// are already part of the NTP.
if (!IsVisibleUrlNewTabPage(self.webStateList->GetActiveWebState()) &&
base::FeatureList::IsEnabled(
omnibox::kOmniboxPopupShortcutIconsInZeroState)) {
self.popupViewController.shortcutsEnabled = YES;
}
[self.mediator.presenter updateHeightAndAnimateAppearanceIfNecessary];
self.mediator.open = YES;
}
- (void)closePopup {
self.mediator.open = NO;
self.popupViewController.shortcutsEnabled = NO;
[self.mediator.presenter animateCollapse];
}
#pragma mark - Property accessor
- (BOOL)hasResults {
......
......@@ -87,8 +87,6 @@
if (self.open) {
[self.presenter updateHeightAndAnimateAppearanceIfNecessary];
} else {
[self.presenter animateCollapse];
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment