Popular sites on the NTP: check that experiment group StartsWith (rather than IS...
[chromium-blink-merge.git] / chrome / browser / ui / webui / options / pepper_flash_content_settings_utils.h
blob1e488239a3cc8b9c48fb31b48e91b5bedd41405a
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_
8 #include <vector>
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"
16 namespace options {
18 struct MediaException {
19 MediaException(const ContentSettingsPattern& in_pattern,
20 ContentSetting in_setting);
21 ~MediaException();
23 bool operator==(const MediaException& other) const;
25 ContentSettingsPattern pattern;
26 ContentSetting setting;
29 typedef std::vector<MediaException> MediaExceptions;
31 class PepperFlashContentSettingsUtils {
32 public:
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|,
50 // and vice versa.
51 static bool AreMediaExceptionsEqual(ContentSetting default_setting_1,
52 const MediaExceptions& exceptions_1,
53 ContentSetting default_setting_2,
54 const MediaExceptions& exceptions_2);
56 private:
57 DISALLOW_IMPLICIT_CONSTRUCTORS(PepperFlashContentSettingsUtils);
60 } // namespace options
62 #endif // CHROME_BROWSER_UI_WEBUI_OPTIONS_PEPPER_FLASH_CONTENT_SETTINGS_UTILS_H_