Chromium Code Reviews| Index: Source/modules/credentialmanager/CredentialManagerClient.cpp |
| diff --git a/Source/modules/credentialmanager/CredentialManagerClient.cpp b/Source/modules/credentialmanager/CredentialManagerClient.cpp |
| index 76a99b08eb16ebb9ea47b126f88634ba6dae4bab..fbf260c581c667e02833a3cb4027baba403b8879 100644 |
| --- a/Source/modules/credentialmanager/CredentialManagerClient.cpp |
| +++ b/Source/modules/credentialmanager/CredentialManagerClient.cpp |
| @@ -5,6 +5,9 @@ |
| #include "config.h" |
| #include "modules/credentialmanager/CredentialManagerClient.h" |
| +#include "bindings/core/v8/ScriptState.h" |
| +#include "core/dom/Document.h" |
| +#include "core/dom/ExecutionContext.h" |
| #include "core/page/Page.h" |
| namespace blink { |
| @@ -25,6 +28,14 @@ const char* CredentialManagerClient::supplementName() |
| } |
| // static |
| +CredentialManagerClient* CredentialManagerClient::from(ScriptState* scriptState) |
| +{ |
| + if (!scriptState->executionContext()->isDocument()) |
| + return 0; |
| + return from(toDocument(scriptState->executionContext())->page()); |
|
sof
2014/09/15 07:57:17
If the document has become detached, page() will b
Mike West
2014/09/16 07:53:20
That's taken care of in `Supplementable::from()`:
sof
2014/09/16 12:36:11
It does (but a bit tight); I won't insist.
|
| +} |
| + |
| +// static |
| CredentialManagerClient* CredentialManagerClient::from(Page* page) |
| { |
| return static_cast<CredentialManagerClient*>(WillBeHeapSupplement<Page>::from(page, supplementName())); |