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
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55

content / public / browser / bluetooth_scanning_prompt.h [blame]

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CONTENT_PUBLIC_BROWSER_BLUETOOTH_SCANNING_PROMPT_H_
#define CONTENT_PUBLIC_BROWSER_BLUETOOTH_SCANNING_PROMPT_H_

#include <string>

#include "base/functional/callback_forward.h"
#include "content/common/content_export.h"

namespace content {

// Represents a way to ask the user permission to allow a site to receive
// Bluetooth advertisement packets from Bluetooth devices.
class CONTENT_EXPORT BluetoothScanningPrompt {
 public:
  // A Java counterpart will be generated for this enum.
  // GENERATED_JAVA_ENUM_PACKAGE: (
  //   org.chromium.content_public.browser.bluetooth_scanning)
  enum class Event {
    kAllow,
    kBlock,
    // This can happen when multiple request scanning functions are called,
    // and in this case, the previous prompts will be closed.
    kCanceled,
  };

  // Prompt implementations are constructed with an |EventHandler| and report
  // user interaction with the prompt through it.
  //
  // The EventHandler won't be called after the prompt object is destroyed.
  //
  // After the EventHandler is called, it won't be called again, and
  // users must not call any more BluetoothScanningPrompt methods.
  using EventHandler = base::RepeatingCallback<void(Event)>;

  BluetoothScanningPrompt();
  virtual ~BluetoothScanningPrompt();

  // Adds a new device to the prompt or updates the information of an
  // existing device.
  //
  // Sometimes when a Bluetooth device stops advertising, the |device_name|
  // can be invalid, and in that case |should_update_name| will be set
  // false.
  virtual void AddOrUpdateDevice(const std::string& device_id,
                                 bool should_update_name,
                                 const std::u16string& device_name) {}
};

}  // namespace content

#endif  // CONTENT_PUBLIC_BROWSER_BLUETOOTH_SCANNING_PROMPT_H_