Home | History | Annotate | Download | only in Shared
      1 /*
      2  * Copyright (C)  2010 Apple Inc. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions
      6  * are met:
      7  * 1. Redistributions of source code must retain the above copyright
      8  *    notice, this list of conditions and the following disclaimer.
      9  * 2. Redistributions in binary form must reproduce the above copyright
     10  *    notice, this list of conditions and the following disclaimer in the
     11  *    documentation and/or other materials provided with the distribution.
     12  *
     13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
     14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
     17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     23  * THE POSSIBILITY OF SUCH DAMAGE.
     24  */
     25 
     26 #include "config.h"
     27 #include "WebPageCreationParameters.h"
     28 
     29 #include "WebCoreArgumentCoders.h"
     30 
     31 namespace WebKit {
     32 
     33 void WebPageCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) const
     34 {
     35     encoder->encode(viewSize);
     36     encoder->encode(isActive);
     37     encoder->encode(isFocused);
     38     encoder->encode(isVisible);
     39     encoder->encode(isInWindow);
     40 
     41     encoder->encode(store);
     42     encoder->encodeEnum(drawingAreaType);
     43     encoder->encode(pageGroupData);
     44     encoder->encode(drawsBackground);
     45     encoder->encode(drawsTransparentBackground);
     46     encoder->encode(areMemoryCacheClientCallsEnabled);
     47     encoder->encode(useFixedLayout);
     48     encoder->encode(fixedLayoutSize);
     49     encoder->encode(userAgent);
     50     encoder->encode(sessionState);
     51     encoder->encode(highestUsedBackForwardItemID);
     52     encoder->encode(canRunBeforeUnloadConfirmPanel);
     53     encoder->encode(canRunModal);
     54     encoder->encode(userSpaceScaleFactor);
     55 
     56 #if PLATFORM(MAC)
     57     encoder->encode(isSmartInsertDeleteEnabled);
     58 #endif
     59 
     60 #if PLATFORM(WIN)
     61     encoder->encode(reinterpret_cast<uint64_t>(nativeWindow));
     62 #endif
     63 }
     64 
     65 bool WebPageCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, WebPageCreationParameters& parameters)
     66 {
     67     if (!decoder->decode(parameters.viewSize))
     68         return false;
     69     if (!decoder->decode(parameters.isActive))
     70         return false;
     71     if (!decoder->decode(parameters.isFocused))
     72         return false;
     73     if (!decoder->decode(parameters.isVisible))
     74         return false;
     75     if (!decoder->decode(parameters.isInWindow))
     76         return false;
     77     if (!decoder->decode(parameters.store))
     78         return false;
     79     if (!decoder->decodeEnum(parameters.drawingAreaType))
     80         return false;
     81     if (!decoder->decode(parameters.pageGroupData))
     82         return false;
     83     if (!decoder->decode(parameters.drawsBackground))
     84         return false;
     85     if (!decoder->decode(parameters.drawsTransparentBackground))
     86         return false;
     87     if (!decoder->decode(parameters.areMemoryCacheClientCallsEnabled))
     88         return false;
     89     if (!decoder->decode(parameters.useFixedLayout))
     90         return false;
     91     if (!decoder->decode(parameters.fixedLayoutSize))
     92         return false;
     93     if (!decoder->decode(parameters.userAgent))
     94         return false;
     95     if (!decoder->decode(parameters.sessionState))
     96         return false;
     97     if (!decoder->decode(parameters.highestUsedBackForwardItemID))
     98         return false;
     99     if (!decoder->decode(parameters.canRunBeforeUnloadConfirmPanel))
    100         return false;
    101     if (!decoder->decode(parameters.canRunModal))
    102         return false;
    103     if (!decoder->decode(parameters.userSpaceScaleFactor))
    104         return false;
    105 
    106 #if PLATFORM(MAC)
    107     if (!decoder->decode(parameters.isSmartInsertDeleteEnabled))
    108         return false;
    109 #endif
    110 
    111 #if PLATFORM(WIN)
    112     uint64_t nativeWindow;
    113     if (!decoder->decode(nativeWindow))
    114         return false;
    115     parameters.nativeWindow = reinterpret_cast<HWND>(nativeWindow);
    116 #endif
    117 
    118     return true;
    119 }
    120 
    121 } // namespace WebKit
    122