summaryrefslogtreecommitdiffstats
path: root/chrome/browser/pepper_broker_infobar_delegate.h
blob: cce336411353d8c13fbc2ad93562705480fff107 (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
61
62
63
64
65
66
67
// Copyright (c) 2012 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_PEPPER_BROKER_INFOBAR_DELEGATE_H_
#define CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_

#include "base/callback.h"
#include "base/files/file_path.h"
#include "base/macros.h"
#include "components/infobars/core/confirm_infobar_delegate.h"
#include "url/gurl.h"

class HostContentSettingsMap;
class InfoBarService;
class TabSpecificContentSettings;

namespace content {
class WebContents;
}

// Shows an infobar that asks the user whether a Pepper plugin is allowed
// to connect to its (privileged) broker. The user decision is made "sticky"
// by storing a content setting for the site.
class PepperBrokerInfoBarDelegate : public ConfirmInfoBarDelegate {
 public:
  // Determines whether the broker setting is allow, deny, or ask.  In the first
  // two cases, runs the callback directly.  In the third, creates a pepper
  // broker infobar and delegate and adds the infobar to the InfoBarService
  // associated with |web_contents|.
  static void Create(content::WebContents* web_contents,
                     const GURL& url,
                     const base::FilePath& plugin_path,
                     const base::Callback<void(bool)>& callback);

 private:
  PepperBrokerInfoBarDelegate(const GURL& url,
                              const base::FilePath& plugin_path,
                              const std::string& languages,
                              HostContentSettingsMap* content_settings,
                              TabSpecificContentSettings* tab_content_settings,
                              const base::Callback<void(bool)>& callback);
  ~PepperBrokerInfoBarDelegate() override;

  // ConfirmInfoBarDelegate:
  infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
  int GetIconId() const override;
  base::string16 GetMessageText() const override;
  base::string16 GetButtonLabel(InfoBarButton button) const override;
  bool Accept() override;
  bool Cancel() override;
  base::string16 GetLinkText() const override;
  GURL GetLinkURL() const override;

  void DispatchCallback(bool result);

  const GURL url_;
  const base::FilePath plugin_path_;
  const std::string languages_;
  HostContentSettingsMap* content_settings_;
  TabSpecificContentSettings* tab_content_settings_;
  base::Callback<void(bool)> callback_;

  DISALLOW_COPY_AND_ASSIGN(PepperBrokerInfoBarDelegate);
};

#endif  // CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_