Commit f2247baa authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] New PageInfo design setup

This CL sets up the new design of the security page info, creating the
flag and the files needed.

- The existing PageInfoVC is renamed LegacyPageInfoViewController
- A new PageInfoViewController is created
- A new PageInfoCoordinator is created
- A features file is created (with the feature inside)
- BrowserCoordinator is instantiating the old/new coordinator based
  on the feature
- The call to display PageInfo depends on the feature state

Bug: 1038919
Change-Id: Ia42620e99c0343a7ee8bdc5838145aa9c5ed4f9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1986825
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarMark Cogan <marq@chromium.org>
Auto-Submit: Gauthier Ambard <gambard@chromium.org>
Cr-Commit-Position: refs/heads/master@{#728592}
parent 8c8f244b
......@@ -49,6 +49,7 @@ source_set("flags") {
"//ios/chrome/browser/ui/dialogs:feature_flags",
"//ios/chrome/browser/ui/fullscreen:feature_flags",
"//ios/chrome/browser/ui/infobars:feature_flags",
"//ios/chrome/browser/ui/page_info:features",
"//ios/chrome/browser/ui/settings/autofill:feature_flags",
"//ios/chrome/browser/ui/table_view:feature_flags",
"//ios/chrome/browser/ui/toolbar/public:feature_flags",
......
......@@ -60,6 +60,7 @@
#import "ios/chrome/browser/ui/dialogs/dialog_features.h"
#import "ios/chrome/browser/ui/fullscreen/fullscreen_features.h"
#import "ios/chrome/browser/ui/infobars/infobar_feature.h"
#import "ios/chrome/browser/ui/page_info/features.h"
#include "ios/chrome/browser/ui/settings/autofill/features.h"
#import "ios/chrome/browser/ui/table_view/feature_flags.h"
#import "ios/chrome/browser/ui/toolbar/public/features.h"
......@@ -606,7 +607,9 @@ const flags_ui::FeatureEntry kFeatureEntries[] = {
{"reload-sad-tab", flag_descriptions::kReloadSadTabName,
flag_descriptions::kReloadSadTabDescription, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(web::kReloadSadTab)},
};
{"page-info-refactoring", flag_descriptions::kPageInfoRefactoringName,
flag_descriptions::kPageInfoRefactoringDescription, flags_ui::kOsIos,
FEATURE_VALUE_TYPE(kPageInfoRefactoring)}};
// Add all switches from experimental flags to |command_line|.
void AppendSwitchesFromExperimentalSettings(base::CommandLine* command_line) {
......
......@@ -307,6 +307,10 @@ const char kOmniboxOnDeviceHeadSuggestionsDescription[] =
"Shows Google head non personalized search suggestions provided by a "
"compact on device model";
const char kPageInfoRefactoringName[] = "New design of the page info";
const char kPageInfoRefactoringDescription[] =
"Uses the new design for the page security info.";
const char kPasswordLeakDetectionName[] = "Password Leak Detection";
const char kPasswordLeakDetectionDescription[] =
"Enables the detection of leaked passwords.";
......
......@@ -264,6 +264,10 @@ extern const char kOmniboxUseDefaultSearchEngineFaviconDescription[];
extern const char kOmniboxOnDeviceHeadSuggestionsName[];
extern const char kOmniboxOnDeviceHeadSuggestionsDescription[];
// Title and description for the flag to enable the new design of the page info.
extern const char kPageInfoRefactoringName[];
extern const char kPageInfoRefactoringDescription[];
// Title and description for the flag to enable leak detection for entered
// credentials.
extern const char kPasswordLeakDetectionName[];
......
......@@ -118,6 +118,7 @@ source_set("browser_view") {
"//ios/chrome/browser/ui/open_in",
"//ios/chrome/browser/ui/overscroll_actions",
"//ios/chrome/browser/ui/page_info:coordinator",
"//ios/chrome/browser/ui/page_info:features",
"//ios/chrome/browser/ui/page_info/requirements",
"//ios/chrome/browser/ui/passwords",
"//ios/chrome/browser/ui/payments",
......
......@@ -35,6 +35,8 @@
#import "ios/chrome/browser/ui/download/ar_quick_look_coordinator.h"
#import "ios/chrome/browser/ui/download/pass_kit_coordinator.h"
#import "ios/chrome/browser/ui/open_in/open_in_mediator.h"
#import "ios/chrome/browser/ui/page_info/features.h"
#import "ios/chrome/browser/ui/page_info/page_info_coordinator.h"
#import "ios/chrome/browser/ui/page_info/page_info_legacy_coordinator.h"
#import "ios/chrome/browser/ui/passwords/password_breach_coordinator.h"
#import "ios/chrome/browser/ui/print/print_controller.h"
......@@ -111,7 +113,7 @@
ManualFillAllPasswordCoordinator* allPasswordCoordinator;
// Coordinator for Page Info UI.
@property(nonatomic, strong) PageInfoLegacyCoordinator* pageInfoCoordinator;
@property(nonatomic, strong) ChromeCoordinator* pageInfoCoordinator;
// Coordinator for the PassKit UI presentation.
@property(nonatomic, strong) PassKitCoordinator* passKitCoordinator;
......@@ -311,10 +313,21 @@
browser:self.browser];
[self.translateInfobarCoordinator start];
self.pageInfoCoordinator = [[PageInfoLegacyCoordinator alloc]
initWithBaseViewController:self.viewController
browser:self.browser];
self.pageInfoCoordinator.presentationProvider = self.viewController;
if (base::FeatureList::IsEnabled(kPageInfoRefactoring)) {
PageInfoCoordinator* pageInfoCoordinator = [[PageInfoCoordinator alloc]
initWithBaseViewController:self.viewController
browser:self.browser];
pageInfoCoordinator.presentationProvider = self.viewController;
self.pageInfoCoordinator = pageInfoCoordinator;
} else {
PageInfoLegacyCoordinator* pageInfoCoordinator =
[[PageInfoLegacyCoordinator alloc]
initWithBaseViewController:self.viewController
browser:self.browser];
pageInfoCoordinator.presentationProvider = self.viewController;
self.pageInfoCoordinator = pageInfoCoordinator;
}
[self.pageInfoCoordinator start];
self.passKitCoordinator = [[PassKitCoordinator alloc]
......
......@@ -11,14 +11,18 @@
// Commands related to the Page Info UI.
@protocol PageInfoCommands
// Show the page security info. |originPoint| is the midpoint of the UI element
// TODO(crbug.com/1038923): Remove this command.
// Shows the page security info. |originPoint| is the midpoint of the UI element
// which triggered this command and should be in window coordinates.
- (void)showPageInfoForOriginPoint:(CGPoint)originPoint;
- (void)legacyShowPageInfoForOriginPoint:(CGPoint)originPoint;
// Hide the page security info.
// Shows the page security info.
- (void)showPageInfo;
// Hides the page security info.
- (void)hidePageInfo;
// Show the security help page.
// Shows the security help page.
- (void)showSecurityHelpPage;
@end
......
......@@ -5,6 +5,8 @@
source_set("page_info") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"legacy_page_info_view_controller.h",
"legacy_page_info_view_controller.mm",
"page_info_model.cc",
"page_info_model.h",
"page_info_view_controller.h",
......@@ -48,9 +50,22 @@ source_set("constants") {
]
}
source_set("features") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"features.h",
"features.mm",
]
deps = [
"//base",
]
}
source_set("coordinator") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"page_info_coordinator.h",
"page_info_coordinator.mm",
"page_info_legacy_coordinator.h",
"page_info_legacy_coordinator.mm",
]
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_PAGE_INFO_FEATURES_H_
#define IOS_CHROME_BROWSER_UI_PAGE_INFO_FEATURES_H_
#include "base/feature_list.h"
// Feature to enable the new design of the page info.
extern const base::Feature kPageInfoRefactoring;
#endif // IOS_CHROME_BROWSER_UI_PAGE_INFO_FEATURES_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/page_info/features.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
const base::Feature kPageInfoRefactoring{"PageInfoRefactoring",
base::FEATURE_DISABLED_BY_DEFAULT};
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_PAGE_INFO_LEGACY_PAGE_INFO_VIEW_CONTROLLER_H_
#define IOS_CHROME_BROWSER_UI_PAGE_INFO_LEGACY_PAGE_INFO_VIEW_CONTROLLER_H_
#import <UIKit/UIKit.h>
#include <memory>
#include "base/memory/weak_ptr.h"
@protocol PageInfoCommands;
@protocol PageInfoPresentation;
@protocol PageInfoReloading;
class PageInfoModel;
// TODO(crbug.com/227827) Merge 178763: PageInfoModel has been removed in
// upstream; check if we should use PageInfoModel.
// The view controller for the page info view.
@interface LegacyPageInfoViewController : NSObject
// Designated initializer.
// The |sourcePoint| parameter should be in the coordinate system of
// |provider|'s view. Typically, |sourcePoint| would be the midpoint of a button
// that resulted in this popup being displayed.
- (id)initWithModel:(PageInfoModel*)model
sourcePoint:(CGPoint)sourcePoint
presentationProvider:(id<PageInfoPresentation>)provider
dispatcher:(id<PageInfoCommands, PageInfoReloading>)dispatcher;
// Dispatcher for this view controller.
@property(nonatomic, weak) id<PageInfoCommands, PageInfoReloading> dispatcher;
// Dismisses the view.
- (void)dismiss;
// Layout the page info view.
- (void)performLayout;
@end
#endif // IOS_CHROME_BROWSER_UI_PAGE_INFO_LEGACY_PAGE_INFO_VIEW_CONTROLLER_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_PAGE_INFO_PAGE_INFO_COORDINATOR_H_
#define IOS_CHROME_BROWSER_UI_PAGE_INFO_PAGE_INFO_COORDINATOR_H_
#import <Foundation/Foundation.h>
#import "ios/chrome/browser/ui/coordinators/chrome_coordinator.h"
@protocol PageInfoPresentation;
// The coordinator for the page info.
@interface PageInfoCoordinator : ChromeCoordinator
// |presentationProvider| provides information and runs tasks necessary to
// present Page Info.
@property(nonatomic, weak) id<PageInfoPresentation> presentationProvider;
@end
#endif // IOS_CHROME_BROWSER_UI_PAGE_INFO_PAGE_INFO_COORDINATOR_H_
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/chrome/browser/ui/page_info/page_info_coordinator.h"
#include "base/logging.h"
#include "ios/chrome/browser/main/browser.h"
#import "ios/chrome/browser/ui/commands/command_dispatcher.h"
#import "ios/chrome/browser/ui/commands/page_info_commands.h"
#import "ios/chrome/browser/ui/page_info/page_info_view_controller.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@interface PageInfoCoordinator () <PageInfoCommands>
@end
@implementation PageInfoCoordinator
@synthesize presentationProvider = _presentationProvider;
#pragma mark - ChromeCoordinator
- (void)start {
[self.browser->GetCommandDispatcher()
startDispatchingToTarget:self
forProtocol:@protocol(PageInfoCommands)];
}
- (void)stop {
[self.browser->GetCommandDispatcher() stopDispatchingToTarget:self];
}
#pragma mark - PageInfoCommands
- (void)legacyShowPageInfoForOriginPoint:(CGPoint)originPoint {
NOTREACHED();
}
- (void)showPageInfo {
// TODO(crbug.com/1038919): Implement this.
}
- (void)hidePageInfo {
// TODO(crbug.com/1038919): Implement this.
}
- (void)showSecurityHelpPage {
// TODO(crbug.com/1038919): Implement this.
}
@end
......@@ -17,9 +17,9 @@
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/commands/page_info_commands.h"
#import "ios/chrome/browser/ui/fullscreen/chrome_coordinator+fullscreen_disabling.h"
#import "ios/chrome/browser/ui/page_info/legacy_page_info_view_controller.h"
#import "ios/chrome/browser/ui/page_info/page_info_constants.h"
#include "ios/chrome/browser/ui/page_info/page_info_model.h"
#import "ios/chrome/browser/ui/page_info/page_info_view_controller.h"
#import "ios/chrome/browser/ui/page_info/requirements/page_info_presentation.h"
#import "ios/chrome/browser/ui/page_info/requirements/page_info_reloading.h"
#import "ios/chrome/browser/url_loading/url_loading_params.h"
......@@ -39,12 +39,15 @@
@interface PageInfoLegacyCoordinator ()<PageInfoCommands, PageInfoReloading>
// The view controller for the Page Info UI. Nil if not visible.
@property(nonatomic, strong) PageInfoViewController* pageInfoViewController;
@property(nonatomic, strong)
LegacyPageInfoViewController* pageInfoViewController;
@end
@implementation PageInfoLegacyCoordinator
@synthesize presentationProvider = _presentationProvider;
#pragma mark - ChromeCoordinator
- (void)start {
......@@ -63,7 +66,7 @@
#pragma mark - PageInfoCommands
- (void)showPageInfoForOriginPoint:(CGPoint)originPoint {
- (void)legacyShowPageInfoForOriginPoint:(CGPoint)originPoint {
web::WebState* webState =
self.browser->GetWebStateList()->GetActiveWebState();
web::NavigationItem* navItem =
......@@ -103,13 +106,17 @@
CGPoint originPresentationCoordinates = [self.presentationProvider
convertToPresentationCoordinatesForOrigin:originPoint];
self.pageInfoViewController = [[PageInfoViewController alloc]
self.pageInfoViewController = [[LegacyPageInfoViewController alloc]
initWithModel:pageInfoModel
sourcePoint:originPresentationCoordinates
presentationProvider:self.presentationProvider
dispatcher:self];
}
- (void)showPageInfo {
NOTREACHED();
}
- (void)hidePageInfo {
// Early return if the PageInfoPopup is not presented.
if (!self.pageInfoViewController)
......
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -7,36 +7,8 @@
#import <UIKit/UIKit.h>
#include <memory>
#include "base/memory/weak_ptr.h"
@protocol PageInfoCommands;
@protocol PageInfoPresentation;
@protocol PageInfoReloading;
class PageInfoModel;
// TODO(crbug.com/227827) Merge 178763: PageInfoModel has been removed in
// upstream; check if we should use PageInfoModel.
// The view controller for the page info view.
@interface PageInfoViewController : NSObject
// Designated initializer.
// The |sourcePoint| parameter should be in the coordinate system of
// |provider|'s view. Typically, |sourcePoint| would be the midpoint of a button
// that resulted in this popup being displayed.
- (id)initWithModel:(PageInfoModel*)model
sourcePoint:(CGPoint)sourcePoint
presentationProvider:(id<PageInfoPresentation>)provider
dispatcher:(id<PageInfoCommands, PageInfoReloading>)dispatcher;
// Dispatcher for this view controller.
@property(nonatomic, weak) id<PageInfoCommands, PageInfoReloading> dispatcher;
// Dismisses the view.
- (void)dismiss;
// Layout the page info view.
- (void)performLayout;
// View Controller for displaying the page info.
@interface PageInfoViewController : UIViewController
@end
......
......@@ -65,6 +65,7 @@ source_set("popup_menu") {
"//ios/chrome/browser/ui/coordinators:chrome_coordinators",
"//ios/chrome/browser/ui/list_model",
"//ios/chrome/browser/ui/ntp_tile_views:constants",
"//ios/chrome/browser/ui/page_info:features",
"//ios/chrome/browser/ui/popup_menu/cells",
"//ios/chrome/browser/ui/popup_menu/public",
"//ios/chrome/browser/ui/popup_menu/public:popup_menu_ui",
......
......@@ -14,6 +14,7 @@
#import "ios/chrome/browser/ui/commands/browser_commands.h"
#import "ios/chrome/browser/ui/commands/load_query_commands.h"
#import "ios/chrome/browser/ui/commands/open_new_tab_command.h"
#import "ios/chrome/browser/ui/page_info/features.h"
#import "ios/chrome/browser/ui/popup_menu/popup_menu_action_handler_commands.h"
#import "ios/chrome/browser/ui/popup_menu/public/cells/popup_menu_item.h"
#import "ios/chrome/browser/ui/popup_menu/public/popup_menu_table_view_controller.h"
......@@ -84,8 +85,13 @@ using base::UserMetricsAction;
break;
case PopupMenuActionSiteInformation:
RecordAction(UserMetricsAction("MobileMenuSiteInformation"));
[self.dispatcher
showPageInfoForOriginPoint:self.baseViewController.view.center];
if (base::FeatureList::IsEnabled(kPageInfoRefactoring)) {
[self.dispatcher showPageInfo];
} else {
[self.dispatcher
legacyShowPageInfoForOriginPoint:self.baseViewController.view
.center];
}
break;
case PopupMenuActionReportIssue:
RecordAction(UserMetricsAction("MobileMenuReportAnIssue"));
......
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