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

Unified Diff: ios/chrome/browser/tabs/tab.mm

Issue 2854883003: Revert of Removes Native App Launcher functionality. (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/tabs/tab_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/tabs/tab.mm
diff --git a/ios/chrome/browser/tabs/tab.mm b/ios/chrome/browser/tabs/tab.mm
index fe6b85467c6750529995709bcb6de808aa801ee6..6bb0c4ab49b34abb3b75b8b970a06213c483dd4f 100644
--- a/ios/chrome/browser/tabs/tab.mm
+++ b/ios/chrome/browser/tabs/tab.mm
@@ -62,6 +62,7 @@
#include "ios/chrome/browser/history/top_sites_factory.h"
#include "ios/chrome/browser/infobars/infobar_manager_impl.h"
#import "ios/chrome/browser/metrics/tab_usage_recorder.h"
+#import "ios/chrome/browser/native_app_launcher/native_app_navigation_controller.h"
#import "ios/chrome/browser/passwords/password_controller.h"
#import "ios/chrome/browser/passwords/passwords_ui_delegate_impl.h"
#include "ios/chrome/browser/pref_names.h"
@@ -70,6 +71,8 @@
#include "ios/chrome/browser/sessions/ios_chrome_session_tab_helper.h"
#include "ios/chrome/browser/signin/account_consistency_service_factory.h"
#include "ios/chrome/browser/signin/account_reconcilor_factory.h"
+#include "ios/chrome/browser/signin/authentication_service.h"
+#include "ios/chrome/browser/signin/authentication_service_factory.h"
#include "ios/chrome/browser/signin/signin_capability.h"
#import "ios/chrome/browser/snapshots/snapshot_manager.h"
#import "ios/chrome/browser/snapshots/snapshot_overlay_provider.h"
@@ -104,6 +107,9 @@
#include "ios/chrome/browser/web/print_observer.h"
#import "ios/chrome/browser/xcallback_parameters.h"
#include "ios/chrome/grit/ios_strings.h"
+#include "ios/public/provider/chrome/browser/chrome_browser_provider.h"
+#import "ios/public/provider/chrome/browser/native_app_launcher/native_app_metadata.h"
+#import "ios/public/provider/chrome/browser/native_app_launcher/native_app_whitelist_manager.h"
#import "ios/web/navigation/crw_session_controller.h"
#import "ios/web/navigation/navigation_item_impl.h"
#import "ios/web/navigation/navigation_manager_impl.h"
@@ -277,6 +283,10 @@
// Handles autofill.
base::scoped_nsobject<AutofillController> autofillController_;
+ // Handles GAL infobar on web pages.
+ base::scoped_nsobject<NativeAppNavigationController>
+ nativeAppNavigationController_;
+
// Handles caching and retrieving of snapshots.
base::scoped_nsobject<SnapshotManager> snapshotManager_;
@@ -340,6 +350,9 @@
// Returns the OpenInController for this tab.
- (OpenInController*)openInController;
+
+// Initialize the Native App Launcher controller.
+- (void)initNativeAppNavigationController;
// Handles exportable files if possible.
- (void)handleExportableFile:(net::HttpResponseHeaders*)headers;
@@ -492,6 +505,8 @@
webControllerSnapshotHelper_.reset([[WebControllerSnapshotHelper alloc]
initWithSnapshotManager:snapshotManager_
tab:self]);
+
+ [self initNativeAppNavigationController];
[[NSNotificationCenter defaultCenter]
addObserver:self
@@ -1611,8 +1626,29 @@
- (BOOL)urlTriggersNativeAppLaunch:(const GURL&)url
sourceURL:(const GURL&)sourceURL
linkClicked:(BOOL)linkClicked {
- // TODO(crbug/711511): Returning NO bypasses all Link Navigation logic
- // for Native App Launcher. This call should eventually be eliminated.
+ // Don't open any native app directly when prerendering or from Incognito.
+ if (isPrerenderTab_ || self.browserState->IsOffTheRecord())
+ return NO;
+
+ base::scoped_nsprotocol<id<NativeAppMetadata>> metadata(
+ [[ios::GetChromeBrowserProvider()->GetNativeAppWhitelistManager()
+ nativeAppForURL:url] retain]);
+ if (![metadata shouldAutoOpenLinks])
+ return NO;
+
+ AuthenticationService* authenticationService =
+ AuthenticationServiceFactory::GetForBrowserState(self.browserState);
+ ChromeIdentity* identity = authenticationService->GetAuthenticatedIdentity();
+
+ // Attempts to open external app without x-callback.
+ if ([self openExternalURL:[metadata launchURLWithURL:url identity:identity]
+ sourceURL:sourceURL
+ linkClicked:linkClicked]) {
+ return YES;
+ }
+
+ // Auto-open didn't work. Reset the auto-open flag.
+ [metadata unsetShouldAutoOpenLinks];
return NO;
}
@@ -1878,8 +1914,16 @@
}
- (NativeAppNavigationController*)nativeAppNavigationController {
- // TODO(crbug.com/711511): This call should eventually be eliminated.
- return nil;
+ return nativeAppNavigationController_;
+}
+
+- (void)initNativeAppNavigationController {
+ if (browserState_->IsOffTheRecord())
+ return;
+ DCHECK(!nativeAppNavigationController_);
+ nativeAppNavigationController_.reset(
+ [[NativeAppNavigationController alloc] initWithWebState:self.webState]);
+ DCHECK(nativeAppNavigationController_);
}
- (id<PassKitDialogProvider>)passKitDialogProvider {
« no previous file with comments | « no previous file | ios/chrome/browser/tabs/tab_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698