summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/web_socket_proxy_controller.h
blob: 4e8ad0d703bf262ad02973705f91847022712d0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_CHROMEOS_WEB_SOCKET_PROXY_CONTROLLER_H_
#define CHROME_BROWSER_CHROMEOS_WEB_SOCKET_PROXY_CONTROLLER_H_
#pragma once

#include <string>
#include <vector>

namespace chromeos {

// Fills vector with extensions IDs which are allowed to use private
// extension API (WebSocketProxyPrivate, InputMethodPrivate, etc.)
void FillWithExtensionsIdsWithPrivateAccess(std::vector<std::string>* ids);

// Controls webproxy to TCP service.
class WebSocketProxyController {
 public:
  enum ConnectionFlags {
    PLAIN_TCP    = 0,
    TLS_OVER_TCP = 1 << 0
  };

  // Can be called on any thread. Subsequent calls are cheap and do nothing.
  static void Initiate();

  // All methods can be called on any thread.
  static void Shutdown();
  static bool IsInitiated();
  static int GetPort();  // Returns port listening websocket connections.

  static bool CheckCredentials(
      const std::string& extension_id,
      const std::string& hostname,
      unsigned short port,
      ConnectionFlags);
};

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_WEB_SOCKET_PROXY_CONTROLLER_H_