1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_
6 #define CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_
8 #include "base/callback.h"
9 #include "base/files/file_path.h"
10 #include "components/infobars/core/confirm_infobar_delegate.h"
13 class HostContentSettingsMap
;
15 class TabSpecificContentSettings
;
21 // Shows an infobar that asks the user whether a Pepper plugin is allowed
22 // to connect to its (privileged) broker. The user decision is made "sticky"
23 // by storing a content setting for the site.
24 class PepperBrokerInfoBarDelegate
: public ConfirmInfoBarDelegate
{
26 // Determines whether the broker setting is allow, deny, or ask. In the first
27 // two cases, runs the callback directly. In the third, creates a pepper
28 // broker infobar and delegate and adds the infobar to the InfoBarService
29 // associated with |web_contents|.
30 static void Create(content::WebContents
* web_contents
,
32 const base::FilePath
& plugin_path
,
33 const base::Callback
<void(bool)>& callback
);
36 PepperBrokerInfoBarDelegate(const GURL
& url
,
37 const base::FilePath
& plugin_path
,
38 const std::string
& languages
,
39 HostContentSettingsMap
* content_settings
,
40 TabSpecificContentSettings
* tab_content_settings
,
41 const base::Callback
<void(bool)>& callback
);
42 ~PepperBrokerInfoBarDelegate() override
;
44 // ConfirmInfoBarDelegate:
45 int GetIconId() const override
;
46 base::string16
GetMessageText() const override
;
47 base::string16
GetButtonLabel(InfoBarButton button
) const override
;
48 bool Accept() override
;
49 bool Cancel() override
;
50 base::string16
GetLinkText() const override
;
51 bool LinkClicked(WindowOpenDisposition disposition
) override
;
53 void DispatchCallback(bool result
);
56 const base::FilePath plugin_path_
;
57 const std::string languages_
;
58 HostContentSettingsMap
* content_settings_
;
59 TabSpecificContentSettings
* tab_content_settings_
;
60 base::Callback
<void(bool)> callback_
;
62 DISALLOW_COPY_AND_ASSIGN(PepperBrokerInfoBarDelegate
);
65 #endif // CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_