Home | History | Annotate | Download | only in credentialmanager
      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
      3 // found in the LICENSE file.
      4 
      5 #include "config.h"
      6 #include "modules/credentialmanager/CredentialManagerClient.h"
      7 
      8 #include "bindings/core/v8/ScriptState.h"
      9 #include "core/dom/Document.h"
     10 #include "core/dom/ExecutionContext.h"
     11 #include "core/page/Page.h"
     12 
     13 namespace blink {
     14 
     15 CredentialManagerClient::CredentialManagerClient(WebCredentialManagerClient* client)
     16     : m_client(client)
     17 {
     18 }
     19 
     20 CredentialManagerClient::~CredentialManagerClient()
     21 {
     22 }
     23 
     24 // static
     25 const char* CredentialManagerClient::supplementName()
     26 {
     27     return "CredentialManagerClient";
     28 }
     29 
     30 // static
     31 CredentialManagerClient* CredentialManagerClient::from(ExecutionContext* executionContext)
     32 {
     33     if (!executionContext->isDocument() || !toDocument(executionContext)->page())
     34         return 0;
     35     return from(toDocument(executionContext)->page());
     36 }
     37 
     38 // static
     39 CredentialManagerClient* CredentialManagerClient::from(Page* page)
     40 {
     41     return static_cast<CredentialManagerClient*>(WillBeHeapSupplement<Page>::from(page, supplementName()));
     42 }
     43 
     44 void provideCredentialManagerClientTo(Page& page, CredentialManagerClient* client)
     45 {
     46     CredentialManagerClient::provideTo(page, CredentialManagerClient::supplementName(), adoptPtrWillBeNoop(client));
     47 }
     48 
     49 void CredentialManagerClient::dispatchFailedSignIn(const WebCredential& credential, WebCredentialManagerClient::NotificationCallbacks* callbacks)
     50 {
     51     if (!m_client)
     52         return;
     53     m_client->dispatchFailedSignIn(credential, callbacks);
     54 }
     55 
     56 void CredentialManagerClient::dispatchSignedIn(const WebCredential& credential, WebCredentialManagerClient::NotificationCallbacks* callbacks)
     57 {
     58     if (!m_client)
     59         return;
     60     m_client->dispatchSignedIn(credential, callbacks);
     61 }
     62 
     63 void CredentialManagerClient::dispatchSignedOut(WebCredentialManagerClient::NotificationCallbacks* callbacks)
     64 {
     65     if (!m_client)
     66         return;
     67     m_client->dispatchSignedOut(callbacks);
     68 }
     69 
     70 void CredentialManagerClient::dispatchRequest(bool zeroClickOnly, const WebVector<WebURL>& federations, WebCredentialManagerClient::RequestCallbacks* callbacks)
     71 {
     72     if (!m_client)
     73         return;
     74     m_client->dispatchRequest(zeroClickOnly, federations, callbacks);
     75 }
     76 
     77 } // namespace blink
     78