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.
5 #ifndef CHROME_BROWSER_UI_WEBUI_OPTIONS_PEPPER_FLASH_CONTENT_SETTINGS_UTILS_H_
6 #define CHROME_BROWSER_UI_WEBUI_OPTIONS_PEPPER_FLASH_CONTENT_SETTINGS_UTILS_H_
10 #include "base/macros.h"
11 #include "components/content_settings/core/common/content_settings.h"
12 #include "components/content_settings/core/common/content_settings_pattern.h"
13 #include "ppapi/c/private/ppp_flash_browser_operations.h"
14 #include "ppapi/shared_impl/ppp_flash_browser_operations_shared.h"
18 struct MediaException
{
19 MediaException(const ContentSettingsPattern
& in_pattern
,
20 ContentSetting in_setting
);
23 bool operator==(const MediaException
& other
) const;
25 ContentSettingsPattern pattern
;
26 ContentSetting setting
;
29 typedef std::vector
<MediaException
> MediaExceptions
;
31 class PepperFlashContentSettingsUtils
{
33 static ContentSetting
FlashPermissionToContentSetting(
34 PP_Flash_BrowserOperations_Permission permission
);
36 static void FlashSiteSettingsToMediaExceptions(
37 const ppapi::FlashSiteSettings
& site_settings
,
38 MediaExceptions
* media_exceptions
);
40 // Sorts |media_exceptions| in ascending order by comparing the |pattern|
41 // field of the elements.
42 static void SortMediaExceptions(MediaExceptions
* media_exceptions
);
44 // Checks whether |exceptions_1| and |exceptions_2| describe the same set of
45 // exceptions. |exceptions_1| and |exceptions_2| should be sorted by
46 // SortMediaExceptions() before passing into this method.
48 // When an element of |exceptions_1| has a pattern that doesn't match any
49 // element of |exceptions_2|, it would be compared with |default_setting_2|,
51 static bool AreMediaExceptionsEqual(ContentSetting default_setting_1
,
52 const MediaExceptions
& exceptions_1
,
53 ContentSetting default_setting_2
,
54 const MediaExceptions
& exceptions_2
);
57 DISALLOW_IMPLICIT_CONSTRUCTORS(PepperFlashContentSettingsUtils
);
60 } // namespace options
62 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_PEPPER_FLASH_CONTENT_SETTINGS_UTILS_H_