summaryrefslogtreecommitdiffstats
path: root/chrome/browser/android/media/media_throttle_infobar_delegate.h
blob: 621f16a4fec844bf2b5dd5e86b7147d0688ad16f (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2015 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_ANDROID_MEDIA_MEDIA_THROTTLE_INFOBAR_DELEGATE_H_
#define CHROME_BROWSER_ANDROID_MEDIA_MEDIA_THROTTLE_INFOBAR_DELEGATE_H_

#include <string>

#include "base/callback.h"
#include "base/macros.h"
#include "components/infobars/core/confirm_infobar_delegate.h"

namespace content {
class WebContents;
}

enum UMAThrottleInfobarResponse {
  UMA_THROTTLE_INFOBAR_NO_RESPONSE,
  UMA_THROTTLE_INFOBAR_TRY_AGAIN,
  UMA_THROTTLE_INFOBAR_WAIT,
  UMA_THROTTLE_INFOBAR_DISMISSED,
  // NOTE: Add responses only immediately above this line. Make sure to
  // update the enum list in tools/metrics/histograms/histograms.xml
  // accordingly.
  UMA_THROTTLE_INFOBAR_RESPONSE_COUNT
};

class MediaThrottleInfoBarDelegate : public ConfirmInfoBarDelegate {
 public:
  typedef base::Callback<void(bool)> DecodeRequestGrantedCallback;
  ~MediaThrottleInfoBarDelegate() override;

  // Static method to create the object
  static void Create(
      content::WebContents* web_contents,
      const DecodeRequestGrantedCallback& callback);

 private:
  explicit MediaThrottleInfoBarDelegate(
      const DecodeRequestGrantedCallback& callback);

  // ConfirmInfoBarDelegate:
  infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
  MediaThrottleInfoBarDelegate* AsMediaThrottleInfoBarDelegate() override;
  base::string16 GetMessageText() const override;
  int GetIconId() const override;
  base::string16 GetButtonLabel(InfoBarButton button) const override;
  bool Accept() override;
  bool Cancel() override;
  void InfoBarDismissed() override;

  UMAThrottleInfobarResponse infobar_response_;

  DecodeRequestGrantedCallback decode_granted_callback_;

  DISALLOW_COPY_AND_ASSIGN(MediaThrottleInfoBarDelegate);
};

#endif  // CHROME_BROWSER_ANDROID_MEDIA_MEDIA_THROTTLE_INFOBAR_DELEGATE_H_