Home | History | Annotate | Download | only in testing
      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 "NavigatorContentUtilsClientMock.h"
      7 
      8 #include "modules/navigatorcontentutils/NavigatorContentUtilsClient.h"
      9 #include "platform/weborigin/KURL.h"
     10 #include "wtf/text/StringHash.h"
     11 
     12 namespace blink {
     13 
     14 void NavigatorContentUtilsClientMock::registerProtocolHandler(const String& scheme,
     15     const KURL& url, const String& title)
     16 {
     17     ProtocolInfo info;
     18     info.scheme = scheme;
     19     info.url = url;
     20     info.title = title;
     21 
     22     m_protocolMap.set(scheme, info);
     23 }
     24 
     25 NavigatorContentUtilsClient::CustomHandlersState NavigatorContentUtilsClientMock::isProtocolHandlerRegistered(const String& scheme,
     26     const KURL& url)
     27 {
     28     // "declined" state is checked by NavigatorContentUtils::isProtocolHandlerRegistered() before calling this function.
     29     if (m_protocolMap.contains(scheme))
     30         return NavigatorContentUtilsClient::CustomHandlersRegistered;
     31 
     32     return NavigatorContentUtilsClient::CustomHandlersNew;
     33 }
     34 
     35 void NavigatorContentUtilsClientMock::unregisterProtocolHandler(const String& scheme,
     36     const KURL& url)
     37 {
     38     m_protocolMap.remove(scheme);
     39 }
     40 
     41 } // namespace blink
     42