Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / content_settings / content_settings_utils.cc
index 5c27fdb..c207870 100644 (file)
 #include "base/memory/scoped_vector.h"
 #include "base/strings/string_split.h"
 #include "base/values.h"
-#include "chrome/browser/content_settings/content_settings_provider.h"
-#include "chrome/browser/content_settings/content_settings_rule.h"
 #include "chrome/browser/content_settings/host_content_settings_map.h"
 #include "chrome/common/chrome_switches.h"
-#include "chrome/common/content_settings_pattern.h"
+#include "components/content_settings/core/browser/content_settings_provider.h"
+#include "components/content_settings/core/browser/content_settings_rule.h"
+#include "components/content_settings/core/common/content_settings_pattern.h"
 #include "url/gurl.h"
 
 namespace {
@@ -76,6 +76,39 @@ bool GetTypeFromName(const std::string& name,
   return false;
 }
 
+std::string ContentSettingToString(ContentSetting setting) {
+  switch (setting) {
+    case CONTENT_SETTING_ALLOW:
+      return "allow";
+    case CONTENT_SETTING_ASK:
+      return "ask";
+    case CONTENT_SETTING_BLOCK:
+      return "block";
+    case CONTENT_SETTING_SESSION_ONLY:
+      return "session";
+    case CONTENT_SETTING_DEFAULT:
+      return "default";
+    case CONTENT_SETTING_NUM_SETTINGS:
+      NOTREACHED();
+  }
+
+  return std::string();
+}
+
+ContentSetting ContentSettingFromString(const std::string& name) {
+  if (name == "allow")
+    return CONTENT_SETTING_ALLOW;
+  if (name == "ask")
+    return CONTENT_SETTING_ASK;
+  if (name == "block")
+    return CONTENT_SETTING_BLOCK;
+  if (name == "session")
+    return CONTENT_SETTING_SESSION_ONLY;
+
+  NOTREACHED() << name << " is not a recognized content setting.";
+  return CONTENT_SETTING_DEFAULT;
+}
+
 std::string CreatePatternString(
     const ContentSettingsPattern& item_pattern,
     const ContentSettingsPattern& top_level_frame_pattern) {