[email protected] | 8c8fc29 | 2012-11-23 18:57:16 | [diff] [blame] | 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. |
| 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] | 5799981 | 2013-02-24 05:40:52 | [diff] [blame] | 9 | #include "base/files/file_path.h" |
[email protected] | f9b2160 | 2014-05-22 00:53:12 | [diff] [blame] | 10 | #include "components/infobars/core/confirm_infobar_delegate.h" |
[email protected] | 761fa470 | 2013-07-02 15:25:15 | [diff] [blame] | 11 | #include "url/gurl.h" |
[email protected] | 8c8fc29 | 2012-11-23 18:57:16 | [diff] [blame] | 12 | |
| 13 | class HostContentSettingsMap; |
[email protected] | 4f822f02 | 2012-12-20 19:11:42 | [diff] [blame] | 14 | class InfoBarService; |
[email protected] | 404063d | 2013-02-10 16:23:01 | [diff] [blame] | 15 | class TabSpecificContentSettings; |
[email protected] | 8c8fc29 | 2012-11-23 18:57:16 | [diff] [blame] | 16 | |
| 17 | namespace content { |
| 18 | class 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. |
| 24 | class PepperBrokerInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 25 | public: |
[email protected] | 0be0993 | 2013-01-08 02:03:50 | [diff] [blame] | 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 |
[email protected] | 39308cb | 2013-12-06 03:01:48 | [diff] [blame] | 28 | // broker infobar and delegate and adds the infobar to the InfoBarService |
| 29 | // associated with |web_contents|. |
[email protected] | 0be0993 | 2013-01-08 02:03:50 | [diff] [blame] | 30 | static void Create(content::WebContents* web_contents, |
| 31 | const GURL& url, |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 32 | const base::FilePath& plugin_path, |
[email protected] | 0be0993 | 2013-01-08 02:03:50 | [diff] [blame] | 33 | const base::Callback<void(bool)>& callback); |
[email protected] | 8c8fc29 | 2012-11-23 18:57:16 | [diff] [blame] | 34 | |
[email protected] | 8c8fc29 | 2012-11-23 18:57:16 | [diff] [blame] | 35 | private: |
[email protected] | 39308cb | 2013-12-06 03:01:48 | [diff] [blame] | 36 | PepperBrokerInfoBarDelegate(const GURL& url, |
[email protected] | 01a5527 | 2013-07-10 21:25:37 | [diff] [blame] | 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); |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 42 | ~PepperBrokerInfoBarDelegate() override; |
[email protected] | 8c8fc29 | 2012-11-23 18:57:16 | [diff] [blame] | 43 | |
[email protected] | da0ade7 | 2013-04-30 01:02:53 | [diff] [blame] | 44 | // ConfirmInfoBarDelegate: |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 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; |
[email protected] | da0ade7 | 2013-04-30 01:02:53 | [diff] [blame] | 52 | |
[email protected] | 8c8fc29 | 2012-11-23 18:57:16 | [diff] [blame] | 53 | void DispatchCallback(bool result); |
| 54 | |
| 55 | const GURL url_; |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 56 | const base::FilePath plugin_path_; |
[email protected] | 8c8fc29 | 2012-11-23 18:57:16 | [diff] [blame] | 57 | const std::string languages_; |
| 58 | HostContentSettingsMap* content_settings_; |
[email protected] | 404063d | 2013-02-10 16:23:01 | [diff] [blame] | 59 | TabSpecificContentSettings* tab_content_settings_; |
[email protected] | 8c8fc29 | 2012-11-23 18:57:16 | [diff] [blame] | 60 | base::Callback<void(bool)> callback_; |
| 61 | |
| 62 | DISALLOW_COPY_AND_ASSIGN(PepperBrokerInfoBarDelegate); |
| 63 | }; |
| 64 | |
| 65 | #endif // CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_ |