| Index: third_party/WebKit/Source/core/page/Page.cpp | 
| diff --git a/third_party/WebKit/Source/core/page/Page.cpp b/third_party/WebKit/Source/core/page/Page.cpp | 
| index dac637d20e4d5dcfc021aebc504f1456fbc2820e..c1721a1720ea6a73c689b75fd90c010667a6254f 100644 | 
| --- a/third_party/WebKit/Source/core/page/Page.cpp | 
| +++ b/third_party/WebKit/Source/core/page/Page.cpp | 
| @@ -40,6 +40,7 @@ | 
| #include "core/inspector/InspectorInstrumentation.h" | 
| #include "core/layout/LayoutView.h" | 
| #include "core/layout/TextAutosizer.h" | 
| +#include "core/layout/svg/SVGResourcesCache.h" | 
| #include "core/page/AutoscrollController.h" | 
| #include "core/page/ChromeClient.h" | 
| #include "core/page/ContextMenuController.h" | 
| @@ -49,7 +50,9 @@ | 
| #include "core/page/ValidationMessageClient.h" | 
| #include "core/page/scrolling/ScrollingCoordinator.h" | 
| #include "core/paint/PaintLayer.h" | 
| +#include "platform/graphics/ColorSpaceProfile.h" | 
| #include "platform/graphics/GraphicsLayer.h" | 
| +#include "platform/graphics/GraphicsScreen.h" | 
| #include "platform/plugins/PluginData.h" | 
| #include "public/platform/Platform.h" | 
|  | 
| @@ -328,11 +331,46 @@ void Page::setDeviceScaleFactor(float scaleFactor) | 
|  | 
| void Page::setDeviceColorProfile(const Vector<char>& profile) | 
| { | 
| -    // FIXME: implement. | 
| +    if (!RuntimeEnabledFeatures::imageColorProfilesEnabled()) | 
| +        return; | 
| + | 
| +    fprintf(stderr, "\nWebCore::Page %p setDeviceColorProfile begins\n", this); | 
| +    fflush(stderr); | 
| + | 
| +    setScreenColorProfile(reinterpret_cast<int64_t>(this), profile.data(), profile.size()); | 
| + | 
| +    setCurrentScreenId(reinterpret_cast<int64_t>(this)); | 
| + | 
| +    for (Frame* frame = mainFrame(); frame; frame = frame->tree().traverseNext()) { | 
| +        if (!frame->isLocalFrame()) | 
| +            continue; | 
| + | 
| +        if (LayoutView* layoutView = toLocalFrame(frame)->document()->layoutView()) | 
| +            layoutView->invalidatePaintForViewAndCompositedLayers(true); | 
| + | 
| +        // Clear the SVG pattern cache: see crbug.com/531258 | 
| +        SVGResourcesCache::invalidateAllResources(*toLocalFrame(frame)->document()); | 
| + | 
| +        RELEASE_ASSERT(currentScreenId() == reinterpret_cast<int64_t>(this)); | 
| +    } | 
| + | 
| +    animator().scheduleVisualUpdate(); | 
| + | 
| +    fprintf(stderr, "WebCore::Page %p setDeviceColorProfile ends\n\n", this); | 
| +    fflush(stderr); | 
| + | 
| +    setCurrentScreenId(0); | 
| } | 
|  | 
| void Page::resetDeviceColorProfileForTesting() | 
| { | 
| +    if (RuntimeEnabledFeatures::imageColorProfilesEnabled()) { | 
| +        fprintf(stderr, "\nWebCore::Page %ld resetDeviceColorProfileForTesting\n", (long int)this); | 
| +        fflush(stderr); | 
| +    } | 
| + | 
| +    removeScreenColorProfile(reinterpret_cast<int64_t>(this)); | 
| + | 
| RuntimeEnabledFeatures::setImageColorProfilesEnabled(false); | 
| } | 
|  | 
| @@ -599,6 +637,8 @@ void Page::willBeDestroyed() | 
| chromeClient().chromeDestroyed(); | 
| if (m_validationMessageClient) | 
| m_validationMessageClient->willBeDestroyed(); | 
| + | 
| +    removeScreenColorProfile(reinterpret_cast<int64_t>(this)); | 
| m_mainFrame = nullptr; | 
|  | 
| Page::notifyContextDestroyed(); | 
|  |