Changeset 202345 in webkit
- Timestamp:
- Jun 22, 2016 1:00:03 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r202337 r202345 6 6 "${WEBCORE_DIR}" 7 7 "${WEBCORE_DIR}/Modules/airplay" 8 "${WEBCORE_DIR}/Modules/applepay" 8 9 "${WEBCORE_DIR}/Modules/battery" 9 10 "${WEBCORE_DIR}/Modules/encryptedmedia" -
trunk/Source/WebCore/ChangeLog
r202342 r202345 1 2016-06-22 Anders Carlsson <andersca@apple.com> 2 3 Inline the last of the Apple Pay WebCore code 4 https://bugs.webkit.org/show_bug.cgi?id=159032 5 6 Reviewed by Tim Horton. 7 8 * loader/EmptyClients.cpp: 9 (WebCore::fillWithEmptyClients): 10 * page/MainFrame.cpp: 11 (WebCore::MainFrame::MainFrame): 12 * page/MainFrame.h: 13 * page/PageConfiguration.h: 14 * platform/cocoa/ThemeCocoa.mm: 15 (WebCore::passKitBundle): 16 (WebCore::loadPassKitPDFPage): 17 (WebCore::applePayButtonLogoBlack): 18 (WebCore::applePayButtonLogoWhite): 19 (WebCore::drawApplePayButton): 20 (WebCore::ThemeCocoa::drawNamedImage): 21 1 22 2016-06-22 Anders Carlsson <andersca@apple.com> 2 23 -
trunk/Source/WebCore/loader/EmptyClients.cpp
r202005 r202345 42 42 #include "Page.h" 43 43 #include "PageConfiguration.h" 44 #include "PaymentCoordinatorClient.h" 44 45 #include "StorageArea.h" 45 46 #include "StorageNamespace.h" … … 48 49 #include <wtf/NeverDestroyed.h> 49 50 50 #if USE(APPLE_INTERNAL_SDK)51 #include <WebKitAdditions/EmptyClientsIncludes.h>52 #endif53 54 51 namespace WebCore { 52 53 #if ENABLE(APPLE_PAY) 54 class EmptyPaymentCoordinatorClient final : public PaymentCoordinatorClient { 55 bool supportsVersion(unsigned) override { return false; } 56 bool canMakePayments() override { return false; } 57 void canMakePaymentsWithActiveCard(const String&, const String&, std::function<void (bool)> completionHandler) override { callOnMainThread([completionHandler] { completionHandler(false); }); } 58 void showPaymentUI(const URL&, const Vector<URL>&, const PaymentRequest&) override { } 59 void completeMerchantValidation(const PaymentMerchantSession&) override { } 60 61 void completeShippingMethodSelection(PaymentAuthorizationStatus, Optional<PaymentRequest::TotalAndLineItems>) override { } 62 void completeShippingContactSelection(PaymentAuthorizationStatus, const Vector<PaymentRequest::ShippingMethod>&, Optional<PaymentRequest::TotalAndLineItems>) override { } 63 void completePaymentMethodSelection(Optional<WebCore::PaymentRequest::TotalAndLineItems>) override { } 64 void completePaymentSession(PaymentAuthorizationStatus) override { } 65 void abortPaymentSession() override { } 66 void mainFrameDestroyed() override { } 67 }; 68 #endif 55 69 56 70 class EmptyDatabaseProvider final : public DatabaseProvider { … … 121 135 pageConfiguration.chromeClient = &dummyChromeClient.get(); 122 136 137 #if ENABLE(APPLE_PAY) 138 static NeverDestroyed<EmptyPaymentCoordinatorClient> dummyPaymentCoordinatorClient; 139 pageConfiguration.paymentCoordinatorClient = &dummyPaymentCoordinatorClient.get(); 140 #endif 141 123 142 #if ENABLE(CONTEXT_MENUS) 124 143 static NeverDestroyed<EmptyContextMenuClient> dummyContextMenuClient; … … 147 166 pageConfiguration.userContentProvider = adoptRef(new EmptyUserContentProvider); 148 167 pageConfiguration.visitedLinkStore = adoptRef(new EmptyVisitedLinkStore); 149 150 #if USE(APPLE_INTERNAL_SDK)151 #include <WebKitAdditions/EmptyClientsFill.cpp>152 #endif153 168 } 154 169 -
trunk/Source/WebCore/page/MainFrame.cpp
r199955 r202345 31 31 #include "PageConfiguration.h" 32 32 #include "PageOverlayController.h" 33 #include "PaymentCoordinator.h" 33 34 #include "ScrollLatchingState.h" 34 35 #include "Settings.h" … … 38 39 #if PLATFORM(MAC) 39 40 #include "ServicesOverlayController.h" 40 #endif /* PLATFORM(MAC) */41 42 #if USE(APPLE_INTERNAL_SDK)43 #include <WebKitAdditions/MainFrameIncludes.h>44 41 #endif 45 42 … … 49 46 : Frame(page, nullptr, *configuration.loaderClientForMainFrame) 50 47 , m_selfOnlyRefCount(0) 51 #if PLATFORM(MAC) 52 #if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION) 48 #if PLATFORM(MAC) && (ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION)) 53 49 , m_servicesOverlayController(std::make_unique<ServicesOverlayController>(*this)) 54 #endif55 50 #endif 56 51 , m_recentWheelEventDeltaFilter(WheelEventDeltaFilter::create()) 57 52 , m_pageOverlayController(std::make_unique<PageOverlayController>(*this)) 53 #if ENABLE(APPLE_PAY) 54 , m_paymentCoordinator(std::make_unique<PaymentCoordinator>(*configuration.paymentCoordinatorClient)) 55 #endif 58 56 { 59 #if USE(APPLE_INTERNAL_SDK)60 #include <WebKitAdditions/MainFrameInitialization.cpp>61 #endif62 57 } 63 58 -
trunk/Source/WebCore/page/MainFrame.h
r202298 r202345 64 64 #endif // PLATFORM(MAC) 65 65 66 #if USE(APPLE_INTERNAL_SDK)67 #include <WebKitAdditions/MainFrameMembers.h> 66 #if ENABLE(APPLE_PAY) 67 PaymentCoordinator& paymentCoordinator() const { return *m_paymentCoordinator; } 68 68 #endif 69 69 … … 84 84 std::unique_ptr<WheelEventDeltaFilter> m_recentWheelEventDeltaFilter; 85 85 std::unique_ptr<PageOverlayController> m_pageOverlayController; 86 87 #if ENABLE(APPLE_PAY) 88 std::unique_ptr<PaymentCoordinator> m_paymentCoordinator; 89 #endif 86 90 }; 87 91 -
trunk/Source/WebCore/page/PageConfiguration.h
r202005 r202345 30 30 #include <wtf/UniqueRef.h> 31 31 32 #if USE(APPLE_INTERNAL_SDK)33 #include <WebKitAdditions/PageConfigurationIncludes.h>34 #endif35 36 32 namespace WebCore { 37 33 … … 46 42 class FrameLoaderClient; 47 43 class InspectorClient; 44 class PaymentCoordinatorClient; 48 45 class PlugInClient; 49 46 class ProgressTrackerClient; … … 73 70 DragClient* dragClient { nullptr }; 74 71 InspectorClient* inspectorClient { nullptr }; 72 #if ENABLE(APPLE_PAY) 73 PaymentCoordinatorClient* paymentCoordinatorClient { nullptr }; 74 #endif 75 75 76 PlugInClient* plugInClient { nullptr }; 76 77 ProgressTrackerClient* progressTrackerClient { nullptr }; … … 79 80 FrameLoaderClient* loaderClientForMainFrame { nullptr }; 80 81 std::unique_ptr<DiagnosticLoggingClient> diagnosticLoggingClient { nullptr }; 81 82 #if USE(APPLE_INTERNAL_SDK)83 #include <WebKitAdditions/PageConfigurationMembers.h>84 #endif85 82 86 83 RefPtr<ApplicationCacheStorage> applicationCacheStorage; -
trunk/Source/WebCore/platform/cocoa/ThemeCocoa.mm
r201241 r202345 54 54 } 55 55 56 #if ENABLE(APPLE_PAY) 57 static NSBundle *passKitBundle() 58 { 59 static NSBundle *passKitBundle; 60 static dispatch_once_t onceToken; 61 dispatch_once(&onceToken, ^{ 62 #if PLATFORM(MAC) 63 passKitBundle = [NSBundle bundleWithURL:[NSURL fileURLWithPath:@"/System/Library/PrivateFrameworks/PassKit.framework"]]; 64 #else 65 dlopen("/System/Library/Frameworks/PassKit.framework/PassKit", RTLD_NOW); 66 passKitBundle = [NSBundle bundleForClass:NSClassFromString(@"PKPaymentAuthorizationViewController")]; 67 #endif 68 }); 69 70 return passKitBundle; 71 } 72 73 static RetainPtr<CGPDFPageRef> loadPassKitPDFPage(NSString *imageName) 74 { 75 NSURL *url = [passKitBundle() URLForResource:imageName withExtension:@"pdf"]; 76 if (!url) 77 return nullptr; 78 79 auto document = adoptCF(CGPDFDocumentCreateWithURL((CFURLRef)url)); 80 if (!document) 81 return nullptr; 82 83 if (!CGPDFDocumentGetNumberOfPages(document.get())) 84 return nullptr; 85 86 return CGPDFDocumentGetPage(document.get(), 1); 87 }; 88 89 static CGPDFPageRef applePayButtonLogoBlack() 90 { 91 static CGPDFPageRef logoPage; 92 static dispatch_once_t onceToken; 93 dispatch_once(&onceToken, ^{ 94 logoPage = loadPassKitPDFPage(@"PayButtonLogoBlack").leakRef(); 95 }); 96 97 return logoPage; 98 }; 99 100 static CGPDFPageRef applePayButtonLogoWhite() 101 { 102 static CGPDFPageRef logoPage; 103 static dispatch_once_t onceToken; 104 dispatch_once(&onceToken, ^{ 105 logoPage = loadPassKitPDFPage(@"PayButtonLogoWhite").leakRef(); 106 }); 107 108 return logoPage; 109 }; 110 111 static void drawApplePayButton(GraphicsContext& context, CGPDFPageRef page, const FloatRect& rect) 112 { 113 CGSize pdfSize = CGPDFPageGetBoxRect(page, kCGPDFMediaBox).size; 114 GraphicsContextStateSaver stateSaver(context); 115 fitContextToBox(context, FloatSize(pdfSize), rect.size()); 116 117 CGContextTranslateCTM(context.platformContext(), 0, pdfSize.height); 118 CGContextScaleCTM(context.platformContext(), 1, -1); 119 120 CGContextDrawPDFPage(context.platformContext(), page); 121 }; 122 123 #endif 124 56 125 void ThemeCocoa::drawNamedImage(const String& name, GraphicsContext& context, const FloatRect& rect) const 57 126 { 58 // We only handle one icon at the moment.59 127 if (name == "wireless-playback") { 60 128 GraphicsContextStateSaver stateSaver(context); … … 89 157 } 90 158 91 #if USE(APPLE_INTERNAL_SDK) 92 #include <WebKitAdditions/ThemeCocoaDrawNamedImage.mm> 159 #if ENABLE(APPLE_PAY) 160 if (name == "apple-pay-logo-black") { 161 if (auto logo = applePayButtonLogoBlack()) { 162 drawApplePayButton(context, logo, rect); 163 return; 164 } 165 } 166 167 if (name == "apple-pay-logo-white") { 168 if (auto logo = applePayButtonLogoWhite()) { 169 drawApplePayButton(context, logo, rect); 170 return; 171 } 172 } 93 173 #endif 94 174
Note: See TracChangeset
for help on using the changeset viewer.