| 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" | |
| 42 #include "wtf/text/WTFString.h" | 41 #include "wtf/text/WTFString.h" |
| 43 #include <memory> | |
| 44 | 42 |
| 45 namespace blink { | 43 namespace blink { |
| 46 | 44 |
| 47 std::unique_ptr<FileSystemClient> LocalFileSystemClient::create() | 45 PassOwnPtr<FileSystemClient> LocalFileSystemClient::create() |
| 48 { | 46 { |
| 49 return wrapUnique(static_cast<FileSystemClient*>(new LocalFileSystemClient()
)); | 47 return adoptPtr(static_cast<FileSystemClient*>(new LocalFileSystemClient()))
; |
| 50 } | 48 } |
| 51 | 49 |
| 52 LocalFileSystemClient::~LocalFileSystemClient() | 50 LocalFileSystemClient::~LocalFileSystemClient() |
| 53 { | 51 { |
| 54 } | 52 } |
| 55 | 53 |
| 56 bool LocalFileSystemClient::requestFileSystemAccessSync(ExecutionContext* contex
t) | 54 bool LocalFileSystemClient::requestFileSystemAccessSync(ExecutionContext* contex
t) |
| 57 { | 55 { |
| 58 DCHECK(context); | 56 DCHECK(context); |
| 59 if (context->isDocument()) { | 57 if (context->isDocument()) { |
| 60 NOTREACHED(); | 58 NOTREACHED(); |
| 61 return false; | 59 return false; |
| 62 } | 60 } |
| 63 | 61 |
| 64 DCHECK(context->isWorkerGlobalScope()); | 62 DCHECK(context->isWorkerGlobalScope()); |
| 65 return WorkerContentSettingsClient::from(*toWorkerGlobalScope(context))->req
uestFileSystemAccessSync(); | 63 return WorkerContentSettingsClient::from(*toWorkerGlobalScope(context))->req
uestFileSystemAccessSync(); |
| 66 } | 64 } |
| 67 | 65 |
| 68 void LocalFileSystemClient::requestFileSystemAccessAsync(ExecutionContext* conte
xt, std::unique_ptr<ContentSettingCallbacks> callbacks) | 66 void LocalFileSystemClient::requestFileSystemAccessAsync(ExecutionContext* conte
xt, PassOwnPtr<ContentSettingCallbacks> callbacks) |
| 69 { | 67 { |
| 70 DCHECK(context); | 68 DCHECK(context); |
| 71 if (!context->isDocument()) { | 69 if (!context->isDocument()) { |
| 72 NOTREACHED(); | 70 NOTREACHED(); |
| 73 return; | 71 return; |
| 74 } | 72 } |
| 75 | 73 |
| 76 Document* document = toDocument(context); | 74 Document* document = toDocument(context); |
| 77 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame()
); | 75 WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(document->frame()
); |
| 78 if (!webFrame->contentSettingsClient()) { | 76 if (!webFrame->contentSettingsClient()) { |
| 79 callbacks->onAllowed(); | 77 callbacks->onAllowed(); |
| 80 return; | 78 return; |
| 81 } | 79 } |
| 82 webFrame->contentSettingsClient()->requestFileSystemAccessAsync(std::move(ca
llbacks)); | 80 webFrame->contentSettingsClient()->requestFileSystemAccessAsync(std::move(ca
llbacks)); |
| 83 } | 81 } |
| 84 | 82 |
| 85 LocalFileSystemClient::LocalFileSystemClient() | 83 LocalFileSystemClient::LocalFileSystemClient() |
| 86 { | 84 { |
| 87 } | 85 } |
| 88 | 86 |
| 89 } // namespace blink | 87 } // namespace blink |
| OLD | NEW |