Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "modules/credentialmanager/CredentialManagerClient.h" | 6 #include "modules/credentialmanager/CredentialManagerClient.h" |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptState.h" | |
| 9 #include "core/dom/Document.h" | |
| 10 #include "core/dom/ExecutionContext.h" | |
| 8 #include "core/page/Page.h" | 11 #include "core/page/Page.h" |
| 9 | 12 |
| 10 namespace blink { | 13 namespace blink { |
| 11 | 14 |
| 12 CredentialManagerClient::CredentialManagerClient(WebCredentialManagerClient* cli ent) | 15 CredentialManagerClient::CredentialManagerClient(WebCredentialManagerClient* cli ent) |
| 13 : m_client(client) | 16 : m_client(client) |
| 14 { | 17 { |
| 15 } | 18 } |
| 16 | 19 |
| 17 CredentialManagerClient::~CredentialManagerClient() | 20 CredentialManagerClient::~CredentialManagerClient() |
| 18 { | 21 { |
| 19 } | 22 } |
| 20 | 23 |
| 21 // static | 24 // static |
| 22 const char* CredentialManagerClient::supplementName() | 25 const char* CredentialManagerClient::supplementName() |
| 23 { | 26 { |
| 24 return "CredentialManagerClient"; | 27 return "CredentialManagerClient"; |
| 25 } | 28 } |
| 26 | 29 |
| 27 // static | 30 // static |
| 31 CredentialManagerClient* CredentialManagerClient::from(ScriptState* scriptState) | |
| 32 { | |
| 33 if (!scriptState->executionContext()->isDocument()) | |
| 34 return 0; | |
| 35 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.
| |
| 36 } | |
| 37 | |
| 38 // static | |
| 28 CredentialManagerClient* CredentialManagerClient::from(Page* page) | 39 CredentialManagerClient* CredentialManagerClient::from(Page* page) |
| 29 { | 40 { |
| 30 return static_cast<CredentialManagerClient*>(WillBeHeapSupplement<Page>::fro m(page, supplementName())); | 41 return static_cast<CredentialManagerClient*>(WillBeHeapSupplement<Page>::fro m(page, supplementName())); |
| 31 } | 42 } |
| 32 | 43 |
| 33 void provideCredentialManagerClientTo(Page& page, CredentialManagerClient* clien t) | 44 void provideCredentialManagerClientTo(Page& page, CredentialManagerClient* clien t) |
| 34 { | 45 { |
| 35 CredentialManagerClient::provideTo(page, CredentialManagerClient::supplement Name(), adoptPtrWillBeNoop(client)); | 46 CredentialManagerClient::provideTo(page, CredentialManagerClient::supplement Name(), adoptPtrWillBeNoop(client)); |
| 36 } | 47 } |
| 37 | 48 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 57 } | 68 } |
| 58 | 69 |
| 59 void CredentialManagerClient::dispatchRequest(bool zeroClickOnly, const WebVecto r<WebURL>& federations, WebCredentialManagerClient::RequestCallbacks* callbacks) | 70 void CredentialManagerClient::dispatchRequest(bool zeroClickOnly, const WebVecto r<WebURL>& federations, WebCredentialManagerClient::RequestCallbacks* callbacks) |
| 60 { | 71 { |
| 61 if (!m_client) | 72 if (!m_client) |
| 62 return; | 73 return; |
| 63 m_client->dispatchRequest(zeroClickOnly, federations, callbacks); | 74 m_client->dispatchRequest(zeroClickOnly, federations, callbacks); |
| 64 } | 75 } |
| 65 | 76 |
| 66 } // namespace blink | 77 } // namespace blink |
| OLD | NEW |