| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "web/LocalFileSystemClient.h" | 31 #include "web/LocalFileSystemClient.h" |
| 32 | 32 |
| 33 #include "core/dom/Document.h" | 33 #include "core/dom/Document.h" |
| 34 #include "core/workers/WorkerGlobalScope.h" | 34 #include "core/workers/WorkerGlobalScope.h" |
| 35 #include "platform/ContentSettingCallbacks.h" | 35 #include "platform/ContentSettingCallbacks.h" |
| 36 #include "platform/weborigin/SecurityOrigin.h" | 36 #include "platform/weborigin/SecurityOrigin.h" |
| 37 #include "public/platform/WebContentSettingCallbacks.h" | 37 #include "public/platform/WebContentSettingCallbacks.h" |
| 38 #include "public/web/WebContentSettingsClient.h" | 38 #include "public/web/WebContentSettingsClient.h" |
| 39 #include "web/WebLocalFrameImpl.h" | 39 #include "web/WebLocalFrameImpl.h" |
| 40 #include "web/WorkerContentSettingsClient.h" | 40 #include "web/WorkerContentSettingsClient.h" |
| 41 #include "wtf/PtrUtil.h" |
| 41 #include "wtf/text/WTFString.h" | 42 #include "wtf/text/WTFString.h" |
| 43 #include <memory> |
| 42 | 44 |
| 43 namespace blink { | 45 namespace blink { |
| 44 | 46 |
| 45 PassOwnPtr<FileSystemClient> LocalFileSystemClient::create() | 47 std::unique_ptr<FileSystemClient> LocalFileSystemClient::create() |
| 46 { | 48 { |
| 47 return adoptPtr(static_cast<FileSystemClient*>(new LocalFileSystemClient()))
; | 49 return wrapUnique(static_cast<FileSystemClient*>(new LocalFileSystemClient()
)); |
| 48 } | 50 } |
| 49 | 51 |
| 50 LocalFileSystemClient::~LocalFileSystemClient() | 52 LocalFileSystemClient::~LocalFileSystemClient() |
| 51 { | 53 { |
| 52 } | 54 } |
| 53 | 55 |
| 54 bool LocalFileSystemClient::requestFileSystemAccessSync(ExecutionContext* contex
t) | 56 bool LocalFileSystemClient::requestFileSystemAccessSync(ExecutionContext* contex
t) |
| 55 { | 57 { |
| 56 DCHECK(context); | 58 DCHECK(context); |
| 57 if (context->isDocument()) { | 59 if (context->isDocument()) { |
| 58 NOTREACHED(); | 60 NOTREACHED(); |
| 59 return false; | 61 return false; |
| 60 } | 62 } |
| 61 | 63 |
| 62 DCHECK(context->isWorkerGlobalScope()); | 64 DCHECK(context->isWorkerGlobalScope()); |
| 63 return WorkerContentSettingsClient::from(*toWorkerGlobalScope(context))->req
uestFileSystemAccessSync(); | 65 return WorkerContentSettingsClient::from(*toWorkerGlobalScope(context))->req
uestFileSystemAccessSync(); |
| 64 } | 66 } |
| 65 | 67 |
| 66 void LocalFileSystemClient::requestFileSystemAccessAsync(ExecutionContext* conte
xt, PassOwnPtr<ContentSettingCallbacks> callbacks) | 68 void LocalFileSystemClient::requestFileSystemAccessAsync(ExecutionContext* conte
xt, std::unique_ptr<ContentSettingCallbacks> callbacks) |
| 67 { | 69 { |
| 68 DCHECK(context); | 70 DCHECK(context); |
| 69 if (!context->isDocument()) { | 71 if (!context->isDocument()) { |
| 70 NOTREACHED(); | 72 NOTREACHED(); |
| 71 return; | 73 return; |
| 72 } | 74 } |
| 73 | 75 |
| 74 Document* document = toDocument(context); | 76 Document* document = toDocument(context); |
| 75 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame()
); | 77 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame()
); |
| 76 if (!webFrame->contentSettingsClient()) { | 78 if (!webFrame->contentSettingsClient()) { |
| 77 callbacks->onAllowed(); | 79 callbacks->onAllowed(); |
| 78 return; | 80 return; |
| 79 } | 81 } |
| 80 webFrame->contentSettingsClient()->requestFileSystemAccessAsync(std::move(ca
llbacks)); | 82 webFrame->contentSettingsClient()->requestFileSystemAccessAsync(std::move(ca
llbacks)); |
| 81 } | 83 } |
| 82 | 84 |
| 83 LocalFileSystemClient::LocalFileSystemClient() | 85 LocalFileSystemClient::LocalFileSystemClient() |
| 84 { | 86 { |
| 85 } | 87 } |
| 86 | 88 |
| 87 } // namespace blink | 89 } // namespace blink |
| OLD | NEW |