blob: 220297c2f77a7660c1087e731ed91ad6f31fcd1b [file] [log] [blame]
[email protected]8c8fc292012-11-23 18:57:161// 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.
4
5#ifndef CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_
6#define CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_
7
8#include "base/callback.h"
[email protected]57999812013-02-24 05:40:529#include "base/files/file_path.h"
[email protected]4a8adfa02013-03-19 22:37:4610#include "chrome/browser/infobars/confirm_infobar_delegate.h"
[email protected]761fa4702013-07-02 15:25:1511#include "url/gurl.h"
[email protected]8c8fc292012-11-23 18:57:1612
13class HostContentSettingsMap;
[email protected]4f822f022012-12-20 19:11:4214class InfoBarService;
[email protected]404063d2013-02-10 16:23:0115class TabSpecificContentSettings;
[email protected]8c8fc292012-11-23 18:57:1616
17namespace content {
18class WebContents;
19}
20
21// Shows an infobar that asks the user whether a Pepper plug-in is allowed
22// to connect to its (privileged) broker. The user decision is made "sticky"
23// by storing a content setting for the site.
24class PepperBrokerInfoBarDelegate : public ConfirmInfoBarDelegate {
25 public:
[email protected]0be09932013-01-08 02:03:5026 // 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
[email protected]4ee3c912013-07-19 20:20:4228 // broker infobar delegate and adds it to the InfoBarService associated with
[email protected]0be09932013-01-08 02:03:5029 // |web_contents|.
30 static void Create(content::WebContents* web_contents,
31 const GURL& url,
[email protected]650b2d52013-02-10 03:41:4532 const base::FilePath& plugin_path,
[email protected]0be09932013-01-08 02:03:5033 const base::Callback<void(bool)>& callback);
[email protected]8c8fc292012-11-23 18:57:1634
[email protected]8c8fc292012-11-23 18:57:1635 private:
[email protected]01a55272013-07-10 21:25:3736 PepperBrokerInfoBarDelegate(InfoBarService* infobar_service,
37 const GURL& url,
38 const base::FilePath& plugin_path,
39 const std::string& languages,
40 HostContentSettingsMap* content_settings,
41 TabSpecificContentSettings* tab_content_settings,
42 const base::Callback<void(bool)>& callback);
[email protected]0be09932013-01-08 02:03:5043 virtual ~PepperBrokerInfoBarDelegate();
[email protected]8c8fc292012-11-23 18:57:1644
[email protected]da0ade72013-04-30 01:02:5345 // ConfirmInfoBarDelegate:
[email protected]a1c8bae32013-05-16 19:03:5846 virtual int GetIconID() const OVERRIDE;
[email protected]da0ade72013-04-30 01:02:5347 virtual string16 GetMessageText() const OVERRIDE;
[email protected]da0ade72013-04-30 01:02:5348 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE;
49 virtual bool Accept() OVERRIDE;
50 virtual bool Cancel() OVERRIDE;
51 virtual string16 GetLinkText() const OVERRIDE;
52 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE;
53
[email protected]8c8fc292012-11-23 18:57:1654 void DispatchCallback(bool result);
55
56 const GURL url_;
[email protected]650b2d52013-02-10 03:41:4557 const base::FilePath plugin_path_;
[email protected]8c8fc292012-11-23 18:57:1658 const std::string languages_;
59 HostContentSettingsMap* content_settings_;
[email protected]404063d2013-02-10 16:23:0160 TabSpecificContentSettings* tab_content_settings_;
[email protected]8c8fc292012-11-23 18:57:1661 base::Callback<void(bool)> callback_;
62
63 DISALLOW_COPY_AND_ASSIGN(PepperBrokerInfoBarDelegate);
64};
65
66#endif // CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_