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

Unified Diff: ios/chrome/browser/itunes_links/itunes_links_observer.mm

Issue 2731553005: Introduced StoreKitTabHelper class (Closed)
Patch Set: rebase Created 3 years, 9 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
Index: ios/chrome/browser/itunes_links/itunes_links_observer.mm
diff --git a/ios/chrome/browser/itunes_links/itunes_links_observer.mm b/ios/chrome/browser/itunes_links/itunes_links_observer.mm
index fc39792bbc8280871c587f2f4d7e705fac6326ae..e0533dd6870ba81c86cce383169045576d09b020 100644
--- a/ios/chrome/browser/itunes_links/itunes_links_observer.mm
+++ b/ios/chrome/browser/itunes_links/itunes_links_observer.mm
@@ -8,9 +8,9 @@
#include "base/logging.h"
#include "base/strings/sys_string_conversions.h"
-#import "ios/chrome/browser/storekit_launcher.h"
+#import "ios/chrome/browser/store_kit/store_kit_tab_helper.h"
+#import "ios/web/public/web_state/web_state.h"
#import "ios/web/public/web_state/web_state_observer_bridge.h"
-#include "ios/web/public/web_state/web_state.h"
#include "url/gurl.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
@@ -28,7 +28,7 @@
@end
@implementation ITunesLinksObserver {
- __weak id<StoreKitLauncher> _storeKitLauncher;
+ web::WebState* _webState;
std::unique_ptr<web::WebStateObserverBridge> _webStateObserverBridge;
}
@@ -37,15 +37,11 @@
if (self) {
_webStateObserverBridge.reset(
new web::WebStateObserverBridge(webState, self));
sdefresne 2017/03/08 02:53:14 optional: can you change this to use base::MakeUni
pkl (ping after 24h if needed) 2017/03/08 14:27:41 I'll do a separate CL as this is unrelated to this
+ _webState = webState;
}
return self;
}
-- (instancetype)init {
- NOTREACHED();
- return nil;
-}
-
+ (NSString*)productIDFromURL:(const GURL&)URL {
if (!URL.SchemeIsHTTPOrHTTPS() || !URL.DomainIs("itunes.apple.com"))
return nil;
@@ -57,17 +53,22 @@
return base::SysUTF8ToNSString(productID);
}
-#pragma mark - CRWWebStateObserver
+#pragma mark - WebStateObserverBridge
- (void)webState:(web::WebState*)webState didLoadPageWithSuccess:(BOOL)success {
GURL URL = webState->GetLastCommittedURL();
NSString* productID = [ITunesLinksObserver productIDFromURL:URL];
- if (productID)
- [_storeKitLauncher openAppStore:productID];
+ if (productID) {
+ StoreKitTabHelper* tabHelper = StoreKitTabHelper::FromWebState(_webState);
+ if (tabHelper)
+ tabHelper->OpenAppStore(productID);
+ }
}
- (void)setStoreKitLauncher:(id<StoreKitLauncher>)storeKitLauncher {
- _storeKitLauncher = storeKitLauncher;
+ StoreKitTabHelper* tabHelper = StoreKitTabHelper::FromWebState(_webState);
+ if (tabHelper)
+ tabHelper->SetLauncher(storeKitLauncher);
}
@end
« no previous file with comments | « ios/chrome/browser/itunes_links/BUILD.gn ('k') | ios/chrome/browser/itunes_links/itunes_links_observer_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698