| 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 | 10 |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "chrome/browser/permissions/permission_util.h" | 13 #include "chrome/browser/permissions/permission_util.h" |
| 13 #include "components/content_settings/core/common/content_settings_types.h" | 14 #include "components/content_settings/core/common/content_settings_types.h" |
| 14 #include "components/infobars/core/confirm_infobar_delegate.h" | 15 #include "components/infobars/core/confirm_infobar_delegate.h" |
| 15 #include "content/public/browser/permission_type.h" | 16 #include "content/public/browser/permission_type.h" |
| 16 | 17 |
| 17 class Profile; | 18 class Profile; |
| 18 | 19 |
| 19 // Base class for permission infobars, it implements the default behavior | 20 // Base class for permission infobars, it implements the default behavior |
| 20 // so that the accept/deny buttons grant/deny the relevant permission. | 21 // so that the accept/deny buttons grant/deny the relevant permission. |
| 21 // A basic implementor only needs to implement the methods that | 22 // A basic implementor only needs to implement the methods that |
| 22 // provide an icon and a message text to the infobar. | 23 // provide an icon and a message text to the infobar. |
| 23 class PermissionInfoBarDelegate : public ConfirmInfoBarDelegate { | 24 class PermissionInfoBarDelegate : public ConfirmInfoBarDelegate { |
| 24 | 25 |
| 25 public: | 26 public: |
| 26 using PermissionSetCallback = base::Callback<void(bool, PermissionAction)>; | 27 using PermissionSetCallback = base::Callback<void(bool, PermissionAction)>; |
| 27 | 28 |
| 28 ~PermissionInfoBarDelegate() override; | 29 ~PermissionInfoBarDelegate() override; |
| 29 ContentSettingsType content_setting() const { return content_settings_type_; } | 30 virtual std::vector<int> content_settings() const; |
| 30 | 31 |
| 31 // Returns true if the infobar should display a toggle to allow users to | 32 // Returns true if the infobar should display a toggle to allow users to |
| 32 // opt-out of persisting their accept/deny decision. | 33 // opt-out of persisting their accept/deny decision. |
| 33 bool ShouldShowPersistenceToggle() const; | 34 bool ShouldShowPersistenceToggle() const; |
| 34 | 35 |
| 35 // Sets whether or not a decided permission should be persisted to content | 36 // Sets whether or not a decided permission should be persisted to content |
| 36 // settings. | 37 // settings. |
| 37 void set_persist(bool persist) { persist_ = persist; } | 38 void set_persist(bool persist) { persist_ = persist; } |
| 39 bool persist() const { return persist_; } |
| 38 | 40 |
| 39 // ConfirmInfoBarDelegate: | 41 // ConfirmInfoBarDelegate: |
| 40 base::string16 GetMessageText() const override; | 42 base::string16 GetMessageText() const override; |
| 41 | 43 |
| 42 protected: | 44 protected: |
| 43 PermissionInfoBarDelegate(const GURL& requesting_origin, | 45 PermissionInfoBarDelegate(const GURL& requesting_origin, |
| 44 content::PermissionType permission_type, | 46 content::PermissionType permission_type, |
| 45 ContentSettingsType content_settings_type, | 47 ContentSettingsType content_settings_type, |
| 46 bool user_gesture, | 48 bool user_gesture, |
| 47 Profile* profile, | 49 Profile* profile, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 69 bool persist_; | 71 bool persist_; |
| 70 | 72 |
| 71 DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarDelegate); | 73 DISALLOW_COPY_AND_ASSIGN(PermissionInfoBarDelegate); |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 // Implemented in platform-specific code. | 76 // Implemented in platform-specific code. |
| 75 std::unique_ptr<infobars::InfoBar> CreatePermissionInfoBar( | 77 std::unique_ptr<infobars::InfoBar> CreatePermissionInfoBar( |
| 76 std::unique_ptr<PermissionInfoBarDelegate> delegate); | 78 std::unique_ptr<PermissionInfoBarDelegate> delegate); |
| 77 | 79 |
| 78 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ | 80 #endif // CHROME_BROWSER_PERMISSIONS_PERMISSION_INFOBAR_DELEGATE_H_ |
| OLD | NEW |