| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" | 10 #include "chrome/browser/api/infobars/confirm_infobar_delegate.h" |
| 11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 12 | 12 |
| 13 class HostContentSettingsMap; | 13 class HostContentSettingsMap; |
| 14 class InfoBarService; | 14 class InfoBarService; |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 class WebContents; | 17 class WebContents; |
| 18 } | 18 } |
| 19 | 19 |
| 20 // Shows an infobar that asks the user whether a Pepper plug-in is allowed | 20 // Shows an infobar that asks the user whether a Pepper plug-in is allowed |
| 21 // to connect to its (privileged) broker. The user decision is made "sticky" | 21 // to connect to its (privileged) broker. The user decision is made "sticky" |
| 22 // by storing a content setting for the site. | 22 // by storing a content setting for the site. |
| 23 class PepperBrokerInfoBarDelegate : public ConfirmInfoBarDelegate { | 23 class PepperBrokerInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 24 public: | 24 public: |
| 25 virtual ~PepperBrokerInfoBarDelegate(); | 25 // Determines whether the broker setting is allow, deny, or ask. In the first |
| 26 | 26 // two cases, runs the callback directly. In the third, creates a pepper |
| 27 static void Show( | 27 // broker delegate and adds it to the InfoBarService associated with |
| 28 content::WebContents* web_contents, | 28 // |web_contents|. |
| 29 const GURL& url, | 29 static void Create(content::WebContents* web_contents, |
| 30 const FilePath& plugin_path, | 30 const GURL& url, |
| 31 const base::Callback<void(bool)>& callback); | 31 const FilePath& plugin_path, |
| 32 const base::Callback<void(bool)>& callback); |
| 32 | 33 |
| 33 // ConfirmInfoBarDelegate: | 34 // ConfirmInfoBarDelegate: |
| 34 virtual string16 GetMessageText() const OVERRIDE; | 35 virtual string16 GetMessageText() const OVERRIDE; |
| 35 virtual int GetButtons() const OVERRIDE; | 36 virtual int GetButtons() const OVERRIDE; |
| 36 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; | 37 virtual string16 GetButtonLabel(InfoBarButton button) const OVERRIDE; |
| 37 virtual bool Accept() OVERRIDE; | 38 virtual bool Accept() OVERRIDE; |
| 38 virtual bool Cancel() OVERRIDE; | 39 virtual bool Cancel() OVERRIDE; |
| 39 virtual string16 GetLinkText() const OVERRIDE; | 40 virtual string16 GetLinkText() const OVERRIDE; |
| 40 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; | 41 virtual bool LinkClicked(WindowOpenDisposition disposition) OVERRIDE; |
| 41 virtual gfx::Image* GetIcon() const OVERRIDE; | 42 virtual gfx::Image* GetIcon() const OVERRIDE; |
| 42 | 43 |
| 43 private: | 44 private: |
| 44 PepperBrokerInfoBarDelegate( | 45 PepperBrokerInfoBarDelegate( |
| 45 InfoBarService* infobar_service, | 46 InfoBarService* infobar_service, |
| 46 const GURL& url, | 47 const GURL& url, |
| 47 const FilePath& plugin_path, | 48 const FilePath& plugin_path, |
| 48 const std::string& languages, | 49 const std::string& languages, |
| 49 HostContentSettingsMap* content_settings, | 50 HostContentSettingsMap* content_settings, |
| 50 const base::Callback<void(bool)>& callback); | 51 const base::Callback<void(bool)>& callback); |
| 52 virtual ~PepperBrokerInfoBarDelegate(); |
| 51 | 53 |
| 52 void DispatchCallback(bool result); | 54 void DispatchCallback(bool result); |
| 53 | 55 |
| 54 const GURL url_; | 56 const GURL url_; |
| 55 const FilePath plugin_path_; | 57 const FilePath plugin_path_; |
| 56 const std::string languages_; | 58 const std::string languages_; |
| 57 HostContentSettingsMap* content_settings_; | 59 HostContentSettingsMap* content_settings_; |
| 58 base::Callback<void(bool)> callback_; | 60 base::Callback<void(bool)> callback_; |
| 59 | 61 |
| 60 DISALLOW_COPY_AND_ASSIGN(PepperBrokerInfoBarDelegate); | 62 DISALLOW_COPY_AND_ASSIGN(PepperBrokerInfoBarDelegate); |
| 61 }; | 63 }; |
| 62 | 64 |
| 63 #endif // CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_ | 65 #endif // CHROME_BROWSER_PEPPER_BROKER_INFOBAR_DELEGATE_H_ |
| OLD | NEW |