| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "chrome/browser/permissions/permission_util.h" | 13 #include "chrome/browser/permissions/permission_util.h" |
| 14 #include "components/content_settings/core/common/content_settings_types.h" | 14 #include "components/content_settings/core/common/content_settings_types.h" |
| 15 #include "components/infobars/core/confirm_infobar_delegate.h" | 15 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 16 #include "content/public/browser/permission_type.h" | 16 #include "content/public/browser/permission_type.h" |
| 17 #include "url/gurl.h" |
| 17 | 18 |
| 19 namespace infobars { |
| 20 class InfoBar; |
| 21 } |
| 22 |
| 23 class InfoBarService; |
| 18 class Profile; | 24 class Profile; |
| 19 | 25 |
| 20 // Base class for permission infobars, it implements the default behavior | 26 // Base class for permission infobars, it implements the default behavior |
| 21 // so that the accept/deny buttons grant/deny the relevant permission. | 27 // so that the accept/deny buttons grant/deny the relevant permission. |
| 22 // A basic implementor only needs to implement the methods that | 28 // A basic implementor only needs to implement the methods that |
| 23 // provide an icon and a message text to the infobar. | 29 // provide an icon and a message text to the infobar. |
| 24 class PermissionInfoBarDelegate : public ConfirmInfoBarDelegate { | 30 class PermissionInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 25 | 31 |
| 26 public: | 32 public: |
| 27 using PermissionSetCallback = base::Callback<void(bool, PermissionAction)>; | 33 using PermissionSetCallback = base::Callback<void(bool, PermissionAction)>; |
| 28 | 34 |
| 35 // Creates an infobar for |type|. |
| 36 static infobars::InfoBar* Create(content::PermissionType type, |
| 37 InfoBarService* infobar_service, |
| 38 const GURL& requesting_frame, |
| 39 bool user_gesture, |
| 40 Profile* profile, |
| 41 const PermissionSetCallback& callback); |
| 42 |
| 29 ~PermissionInfoBarDelegate() override; | 43 ~PermissionInfoBarDelegate() override; |
| 30 virtual std::vector<int> content_settings() const; | 44 virtual std::vector<int> content_settings() const; |
| 31 | 45 |
| 32 // Returns true if the infobar should display a toggle to allow users to | 46 // Returns true if the infobar should display a toggle to allow users to |
| 33 // opt-out of persisting their accept/deny decision. | 47 // opt-out of persisting their accept/deny decision. |
| 34 bool ShouldShowPersistenceToggle() const; | 48 bool ShouldShowPersistenceToggle() const; |
| 35 | 49 |
| 36 // Sets whether or not a decided permission should be persisted to content | 50 // Sets whether or not a decided permission should be persisted to content |
| 37 // settings. | 51 // settings. |
| 38 void set_persist(bool persist) { persist_ = persist; } | 52 void set_persist(bool persist) { persist_ = persist; } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 bool persist_; | 85 bool persist_; |
| 72 | 86 |
| 73 DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarDelegate); | 87 DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarDelegate); |
| 74 }; | 88 }; |
| 75 | 89 |
| 76 // Implemented in platform-specific code. | 90 // Implemented in platform-specific code. |
| 77 std::unique_ptr<infobars::InfoBar> CreatePermissionInfoBar( | 91 std::unique_ptr<infobars::InfoBar> CreatePermissionInfoBar( |
| 78 std::unique_ptr<PermissionInfoBarDelegate> delegate); | 92 std::unique_ptr<PermissionInfoBarDelegate> delegate); |
| 79 | 93 |
| 80 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ | 94 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ |
| OLD | NEW |