Adding <keygen> Content Setting (UI)

Adding the KEYGEN content setting non-Android UI.

BUG=514767

Review URL: https://codereview.chromium.org/1412523003

Cr-Commit-Position: refs/heads/master@{#369542}
diff --git a/chrome/browser/resources/options/content_settings.html b/chrome/browser/resources/options/content_settings.html
index 3ff17ec..c4278cb9 100644
--- a/chrome/browser/resources/options/content_settings.html
+++ b/chrome/browser/resources/options/content_settings.html
@@ -113,6 +113,36 @@
         </div>
       </div>
     </section>
+    <!-- Keygen filter -->
+    <section>
+      <h3 i18n-content="keygenTabLabel"></h3>
+      <div>
+        <div class="radio controlled-setting-with-label">
+          <label>
+            <input type="radio" name="keygen" value="allow">
+            <span>
+              <span i18n-content="keygenAllow"></span>
+              <span class="controlled-setting-indicator"
+                  content-setting="keygen" value="allow"></span>
+            </span>
+          </label>
+        </div>
+        <div class="radio controlled-setting-with-label">
+          <label>
+            <input type="radio" name="keygen" value="block">
+            <span>
+              <span i18n-content="keygenBlock"></span>
+              <span class="controlled-setting-indicator"
+                  content-setting="keygen" value="block"></span>
+            </span>
+          </label>
+        </div>
+        <div class="settings-row">
+          <button class="exceptions-list-button" contentType="keygen"
+              i18n-content="manageExceptions"></button>
+        </div>
+      </div>
+    </section>
     <!-- Handlers settings -->
     <section id="handlers-section">
       <h3 i18n-content="handlersTabLabel"></h3>
diff --git a/chrome/browser/resources/options/content_settings.js b/chrome/browser/resources/options/content_settings.js
index eb16ca2..e60496d 100644
--- a/chrome/browser/resources/options/content_settings.js
+++ b/chrome/browser/resources/options/content_settings.js
@@ -24,6 +24,7 @@
     'cookies': 'cookies',
     'images': 'images',
     'javascript': 'javascript',
+    'keygen': 'keygen',
     'location': 'location',
     'media-stream-camera': 'mediaStreamCamera',
     'media-stream-mic': 'mediaStreamMic',
diff --git a/chrome/browser/resources/options/content_settings_exceptions_area.html b/chrome/browser/resources/options/content_settings_exceptions_area.html
index db66445..bd4db34 100644
--- a/chrome/browser/resources/options/content_settings_exceptions_area.html
+++ b/chrome/browser/resources/options/content_settings_exceptions_area.html
@@ -164,6 +164,14 @@
         <list mode="otr"></list>
       </div>
     </div>
+    <div contentType="keygen">
+      <list mode="normal"></list>
+      <div>
+        <span class="otr-explanation" i18n-content="otrExceptionsExplanation">
+        </span>
+        <list mode="otr"></list>
+      </div>
+    </div>
   </div>
   <div class="action-area">
     <div class="hbox stretch">
diff --git a/chrome/browser/ui/website_settings/website_settings.cc b/chrome/browser/ui/website_settings/website_settings.cc
index 5a7fa7b..dfc92c8 100644
--- a/chrome/browser/ui/website_settings/website_settings.cc
+++ b/chrome/browser/ui/website_settings/website_settings.cc
@@ -107,6 +107,7 @@
 #if defined(OS_ANDROID)
     CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
 #endif
+    CONTENT_SETTINGS_TYPE_KEYGEN,
 };
 
 // Determines whether to show permission |type| in the Website Settings UI. Only
@@ -709,8 +710,11 @@
                                                       NULL);
     }
 
-    if (permission_info.setting != CONTENT_SETTING_DEFAULT &&
-        permission_info.setting != permission_info.default_setting) {
+    if ((permission_info.setting != CONTENT_SETTING_DEFAULT &&
+         permission_info.setting != permission_info.default_setting) ||
+        (permission_info.type == CONTENT_SETTINGS_TYPE_KEYGEN &&
+         tab_specific_content_settings()->IsContentBlocked(
+             permission_info.type))) {
       permission_info_list.push_back(permission_info);
     }
   }
diff --git a/chrome/browser/ui/website_settings/website_settings_ui.cc b/chrome/browser/ui/website_settings/website_settings_ui.cc
index 72c1bb9..936e5bd 100644
--- a/chrome/browser/ui/website_settings/website_settings_ui.cc
+++ b/chrome/browser/ui/website_settings/website_settings_ui.cc
@@ -110,6 +110,8 @@
      IDR_ALLOWED_DOWNLOADS},
     {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_WEBSITE_SETTINGS_TYPE_MIDI_SYSEX,
      IDR_BLOCKED_MIDI_SYSEX, IDR_ALLOWED_MIDI_SYSEX},
+    {CONTENT_SETTINGS_TYPE_KEYGEN, IDS_WEBSITE_SETTINGS_TYPE_KEYGEN,
+     IDR_BLOCKED_KEYGEN, IDR_ALLOWED_KEYGEN},
 };
 
 }  // namespace
diff --git a/chrome/browser/ui/webui/options/content_settings_handler.cc b/chrome/browser/ui/webui/options/content_settings_handler.cc
index 7d9794d..f3c697cd 100644
--- a/chrome/browser/ui/webui/options/content_settings_handler.cc
+++ b/chrome/browser/ui/webui/options/content_settings_handler.cc
@@ -162,6 +162,7 @@
 #if defined(OS_CHROMEOS)
   {CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER, "protectedContent"},
 #endif
+  {CONTENT_SETTINGS_TYPE_KEYGEN, "keygen"},
 };
 
 ChooserContextBase* GetUsbChooserContext(Profile* profile) {
@@ -235,6 +236,10 @@
             UserMetricsAction(
                 "Options_DefaultProtectedMediaIdentifierSettingChanged"))));
 #endif
+    exceptions_info_map.insert(std::make_pair(
+        CONTENT_SETTINGS_TYPE_KEYGEN,
+        ContentSettingWithExceptions(
+            true, UserMetricsAction("Options_DefaultKeygenSettingChanged"))));
 
     // Without OTR exceptions.
     exceptions_info_map.insert(std::make_pair(
@@ -626,6 +631,11 @@
     {"usbDevicesManage", IDS_USB_DEVICES_MANAGE_BUTTON},
     {"zoomlevelsHeader", IDS_ZOOMLEVELS_HEADER_AND_TAB_LABEL},
     {"zoomLevelsManage", IDS_ZOOMLEVELS_MANAGE_BUTTON},
+    // Keygen filter.
+    {"keygenTabLabel", IDS_KEYGEN_TAB_LABEL},
+    {"keygenHeader", IDS_KEYGEN_HEADER},
+    {"keygenAllow", IDS_KEYGEN_ALLOW_RADIO},
+    {"keygenBlock", IDS_KEYGEN_DONOTALLOW_RADIO},
   };
 
   RegisterStrings(localized_strings, resources, arraysize(resources));
@@ -682,6 +692,7 @@
                 IDS_USB_DEVICES_HEADER_AND_TAB_LABEL);
   RegisterTitle(localized_strings, "zoomlevels",
                 IDS_ZOOMLEVELS_HEADER_AND_TAB_LABEL);
+  RegisterTitle(localized_strings, "keygen", IDS_KEYGEN_TAB_LABEL);
 
   localized_strings->SetString("exceptionsLearnMoreUrl",
                                kExceptionsLearnMoreUrl);