Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / ui / content_settings / content_setting_bubble_model.cc
index 3b58ae7..885c667 100644 (file)
@@ -8,7 +8,6 @@
 #include "base/prefs/pref_service.h"
 #include "base/strings/utf_string_conversions.h"
 #include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/content_settings/content_settings_utils.h"
 #include "chrome/browser/content_settings/cookie_settings.h"
 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
 #include "chrome/browser/ui/browser_navigator.h"
 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h"
 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delegate.h"
-#include "chrome/browser/ui/content_settings/media_setting_changed_infobar_delegate.h"
 #include "chrome/common/chrome_switches.h"
-#include "chrome/common/content_settings.h"
 #include "chrome/common/pref_names.h"
 #include "chrome/common/render_messages.h"
+#include "chrome/grit/generated_resources.h"
+#include "components/content_settings/core/browser/content_settings_utils.h"
+#include "components/content_settings/core/common/content_settings.h"
 #include "content/public/browser/notification_service.h"
+#include "content/public/browser/render_frame_host.h"
 #include "content/public/browser/render_process_host.h"
 #include "content/public/browser/render_view_host.h"
 #include "content/public/browser/user_metrics.h"
 #include "content/public/browser/web_contents.h"
 #include "content/public/browser/web_contents_delegate.h"
-#include "grit/generated_resources.h"
-#include "grit/theme_resources.h"
-#include "grit/ui_resources.h"
+#include "grit/components_strings.h"
 #include "net/base/net_util.h"
 #include "ui/base/l10n/l10n_util.h"
 #include "ui/base/resource/resource_bundle.h"
+#include "ui/resources/grit/ui_resources.h"
 
 using base::UserMetricsAction;
 using content::WebContents;
@@ -94,6 +94,7 @@ ContentSettingTitleAndLinkModel::ContentSettingTitleAndLinkModel(
   DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
   SetTitle();
   SetManageLink();
+  SetLearnMoreLink();
 }
 
 void ContentSettingTitleAndLinkModel::SetTitle() {
@@ -155,6 +156,22 @@ void ContentSettingTitleAndLinkModel::OnManageLinkClicked() {
     delegate_->ShowContentSettingsPage(content_type());
 }
 
+void ContentSettingTitleAndLinkModel::SetLearnMoreLink() {
+  static const ContentSettingsTypeIdEntry kLearnMoreIDs[] = {
+    {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_LEARN_MORE},
+  };
+  int learn_more_id =
+      GetIdForContentType(kLearnMoreIDs, arraysize(kLearnMoreIDs),
+                          content_type());
+  if (learn_more_id)
+    set_learn_more_link(l10n_util::GetStringUTF8(learn_more_id));
+}
+
+void ContentSettingTitleAndLinkModel::OnLearnMoreLinkClicked() {
+  if (delegate_)
+    delegate_->ShowLearnMorePage(content_type());
+}
+
 class ContentSettingTitleLinkAndCustomModel
     : public ContentSettingTitleAndLinkModel {
  public:
@@ -162,11 +179,11 @@ class ContentSettingTitleLinkAndCustomModel
                                         WebContents* web_contents,
                                         Profile* profile,
                                         ContentSettingsType content_type);
-  virtual ~ContentSettingTitleLinkAndCustomModel() {}
+  ~ContentSettingTitleLinkAndCustomModel() override {}
 
  private:
   void SetCustomLink();
-  virtual void OnCustomLinkClicked() OVERRIDE {}
+  void OnCustomLinkClicked() override {}
 };
 
 ContentSettingTitleLinkAndCustomModel::ContentSettingTitleLinkAndCustomModel(
@@ -198,7 +215,7 @@ class ContentSettingSingleRadioGroup
                                  WebContents* web_contents,
                                  Profile* profile,
                                  ContentSettingsType content_type);
-  virtual ~ContentSettingSingleRadioGroup();
+  ~ContentSettingSingleRadioGroup() override;
 
  protected:
   bool settings_changed() const;
@@ -207,7 +224,7 @@ class ContentSettingSingleRadioGroup
  private:
   void SetRadioGroup();
   void AddException(ContentSetting setting);
-  virtual void OnRadioClicked(int radio_index) OVERRIDE;
+  void OnRadioClicked(int radio_index) override;
 
   ContentSetting block_setting_;
   int selected_item_;
@@ -338,8 +355,8 @@ void ContentSettingSingleRadioGroup::SetRadioGroup() {
   } else {
     SettingInfo info;
     HostContentSettingsMap* map = profile()->GetHostContentSettingsMap();
-    scoped_ptr<base::Value> value(map->GetWebsiteSetting(
-        url, url, content_type(), std::string(), &info));
+    scoped_ptr<base::Value> value =
+        map->GetWebsiteSetting(url, url, content_type(), std::string(), &info);
     setting = content_settings::ValueToContentSetting(value.get());
     setting_source = info.source;
     setting_is_wildcard =
@@ -393,10 +410,10 @@ class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup {
                                    Profile* profile,
                                    ContentSettingsType content_type);
 
-  virtual ~ContentSettingCookiesBubbleModel();
+  ~ContentSettingCookiesBubbleModel() override;
 
  private:
-  virtual void OnCustomLinkClicked() OVERRIDE;
+  void OnCustomLinkClicked() override;
 };
 
 ContentSettingCookiesBubbleModel::ContentSettingCookiesBubbleModel(
@@ -437,10 +454,10 @@ class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup {
                                   Profile* profile,
                                   ContentSettingsType content_type);
 
-  virtual ~ContentSettingPluginBubbleModel();
+  ~ContentSettingPluginBubbleModel() override;
 
  private:
-  virtual void OnCustomLinkClicked() OVERRIDE;
+  void OnCustomLinkClicked() override;
 };
 
 ContentSettingPluginBubbleModel::ContentSettingPluginBubbleModel(
@@ -487,11 +504,11 @@ class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup {
                                  WebContents* web_contents,
                                  Profile* profile,
                                  ContentSettingsType content_type);
-  virtual ~ContentSettingPopupBubbleModel() {}
+  ~ContentSettingPopupBubbleModel() override {}
 
  private:
   void SetPopups();
-  virtual void OnPopupClicked(int index) OVERRIDE;
+  void OnPopupClicked(int index) override;
 };
 
 ContentSettingPopupBubbleModel::ContentSettingPopupBubbleModel(
@@ -540,7 +557,7 @@ class ContentSettingMediaStreamBubbleModel
                                        WebContents* web_contents,
                                        Profile* profile);
 
-  virtual ~ContentSettingMediaStreamBubbleModel();
+  ~ContentSettingMediaStreamBubbleModel() override;
 
  private:
   void SetTitle();
@@ -548,6 +565,7 @@ class ContentSettingMediaStreamBubbleModel
   void SetRadioGroup();
   // Sets the data for the media menus of the bubble.
   void SetMediaMenus();
+  void SetCustomLink();
   // Updates the camera and microphone setting with the passed |setting|.
   void UpdateSettings(ContentSetting setting);
   // Updates the camera and microphone default device with the passed |type|
@@ -556,9 +574,9 @@ class ContentSettingMediaStreamBubbleModel
                                   const std::string& device);
 
   // ContentSettingBubbleModel implementation.
-  virtual void OnRadioClicked(int radio_index) OVERRIDE;
-  virtual void OnMediaMenuClicked(content::MediaStreamType type,
-                                  const std::string& selected_device) OVERRIDE;
+  void OnRadioClicked(int radio_index) override;
+  void OnMediaMenuClicked(content::MediaStreamType type,
+                          const std::string& selected_device) override;
 
   // The index of the selected radio item.
   int selected_item_;
@@ -586,10 +604,13 @@ ContentSettingMediaStreamBubbleModel::ContentSettingMediaStreamBubbleModel(
   TabSpecificContentSettings* content_settings =
       TabSpecificContentSettings::FromWebContents(web_contents);
   state_ = content_settings->GetMicrophoneCameraState();
+  DCHECK(state_ & (TabSpecificContentSettings::MICROPHONE_ACCESSED |
+                   TabSpecificContentSettings::CAMERA_ACCESSED));
 
   SetTitle();
   SetRadioGroup();
   SetMediaMenus();
+  SetCustomLink();
 }
 
 ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() {
@@ -598,55 +619,32 @@ ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() {
   if (!web_contents())
     return;
 
-  bool media_setting_changed = false;
   for (MediaMenuMap::const_iterator it = bubble_content().media_menus.begin();
       it != bubble_content().media_menus.end(); ++it) {
     if (it->second.selected_device.id != it->second.default_device.id) {
       UpdateDefaultDeviceForType(it->first, it->second.selected_device.id);
-      media_setting_changed = true;
     }
   }
 
   // Update the media settings if the radio button selection was changed.
   if (selected_item_ != bubble_content().radio_group.default_item) {
     UpdateSettings(radio_item_setting_[selected_item_]);
-    media_setting_changed = true;
-  }
-
-  // Trigger the reload infobar if the media setting has been changed.
-  if (media_setting_changed) {
-    MediaSettingChangedInfoBarDelegate::Create(
-        InfoBarService::FromWebContents(web_contents()));
   }
 }
 
 void ContentSettingMediaStreamBubbleModel::SetTitle() {
+  DCHECK_NE(TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED, state_);
   int title_id = 0;
-  switch (state_) {
-    case TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED:
-      // If neither microphone nor camera stream was accessed, then there is no
-      // icon didplayed in the omnibox and no settings bubble availbale. Hence
-      // there is no title.
-      NOTREACHED();
-      return;
-    case TabSpecificContentSettings::MICROPHONE_ACCESSED:
-      title_id = IDS_MICROPHONE_ACCESSED;
-      break;
-    case TabSpecificContentSettings::CAMERA_ACCESSED:
-      title_id = IDS_CAMERA_ACCESSED;
-      break;
-    case TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED:
-      title_id = IDS_MICROPHONE_CAMERA_ALLOWED;
-      break;
-    case TabSpecificContentSettings::MICROPHONE_BLOCKED:
-      title_id = IDS_MICROPHONE_BLOCKED;
-      break;
-    case TabSpecificContentSettings::CAMERA_BLOCKED:
-      title_id = IDS_CAMERA_BLOCKED;
-      break;
-    case TabSpecificContentSettings::MICROPHONE_CAMERA_BLOCKED:
-      title_id = IDS_MICROPHONE_CAMERA_BLOCKED;
-      break;
+  if (state_ & TabSpecificContentSettings::MICROPHONE_BLOCKED) {
+    title_id = (state_ & TabSpecificContentSettings::CAMERA_BLOCKED) ?
+        IDS_MICROPHONE_CAMERA_BLOCKED : IDS_MICROPHONE_BLOCKED;
+  } else if (state_ & TabSpecificContentSettings::CAMERA_BLOCKED) {
+    title_id = IDS_CAMERA_BLOCKED;
+  } else if (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) {
+    title_id = (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) ?
+        IDS_MICROPHONE_CAMERA_ALLOWED : IDS_MICROPHONE_ACCESSED;
+  } else if (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) {
+    title_id = IDS_CAMERA_ACCESSED;
   }
   set_title(l10n_util::GetStringUTF8(title_id));
 }
@@ -667,61 +665,49 @@ void ContentSettingMediaStreamBubbleModel::SetRadioGroup() {
   if (display_host.empty())
     display_host = url.spec();
 
+  bool is_mic = (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) != 0;
+  bool is_cam = (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) != 0;
+  DCHECK(is_mic || is_cam);
   int radio_allow_label_id = 0;
   int radio_block_label_id = 0;
-  switch (state_) {
-    case TabSpecificContentSettings::MICROPHONE_CAMERA_NOT_ACCESSED:
-      NOTREACHED();
-      return;
-    case TabSpecificContentSettings::MICROPHONE_ACCESSED:
+  if (state_ & (TabSpecificContentSettings::MICROPHONE_BLOCKED |
+                TabSpecificContentSettings::CAMERA_BLOCKED)) {
+    if (url.SchemeIsSecure()) {
+      radio_item_setting_[0] = CONTENT_SETTING_ALLOW;
+      radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_ALLOW;
+      if (is_mic)
+        radio_allow_label_id = is_cam ?
+            IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_ALLOW :
+            IDS_BLOCKED_MEDIASTREAM_MIC_ALLOW;
+    } else {
+      radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_ASK;
+      if (is_mic)
+        radio_allow_label_id = is_cam ?
+            IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_ASK :
+            IDS_BLOCKED_MEDIASTREAM_MIC_ASK;
+    }
+    radio_block_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_NO_ACTION;
+    if (is_mic)
+      radio_block_label_id = is_cam ?
+          IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION :
+          IDS_BLOCKED_MEDIASTREAM_MIC_NO_ACTION;
+  } else {
+    if (is_mic && is_cam) {
+      radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION;
+      radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK;
+    } else if (is_mic) {
       radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_NO_ACTION;
       radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_BLOCK;
-      selected_item_ = 0;
-      break;
-    case TabSpecificContentSettings::CAMERA_ACCESSED:
+    } else {
       radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_CAMERA_NO_ACTION;
       radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_CAMERA_BLOCK;
-      selected_item_ = 0;
-      break;
-    case TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED:
-      radio_allow_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION;
-      radio_block_label_id = IDS_ALLOWED_MEDIASTREAM_MIC_AND_CAMERA_BLOCK;
-      selected_item_ = 0;
-      break;
-    case TabSpecificContentSettings::MICROPHONE_BLOCKED:
-      if (url.SchemeIsSecure()) {
-        radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_MIC_ALLOW;
-        radio_item_setting_[0] = CONTENT_SETTING_ALLOW;
-      } else {
-        radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_MIC_ASK;
-      }
-
-      radio_block_label_id = IDS_BLOCKED_MEDIASTREAM_MIC_NO_ACTION;
-      selected_item_ = 1;
-      break;
-    case TabSpecificContentSettings::CAMERA_BLOCKED:
-      if (url.SchemeIsSecure()) {
-        radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_ALLOW;
-        radio_item_setting_[0] = CONTENT_SETTING_ALLOW;
-      } else {
-        radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_ASK;
-      }
-
-      radio_block_label_id = IDS_BLOCKED_MEDIASTREAM_CAMERA_NO_ACTION;
-      selected_item_ = 1;
-      break;
-    case TabSpecificContentSettings::MICROPHONE_CAMERA_BLOCKED:
-      if (url.SchemeIsSecure()) {
-        radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_ALLOW;
-        radio_item_setting_[0] = CONTENT_SETTING_ALLOW;
-      } else {
-        radio_allow_label_id = IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_ASK;
-      }
-
-      radio_block_label_id = IDS_BLOCKED_MEDIASTREAM_MIC_AND_CAMERA_NO_ACTION;
-      selected_item_ = 1;
-      break;
+    }
   }
+  selected_item_ =
+      (is_mic && content_settings->IsContentBlocked(
+          CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC)) ||
+      (is_cam && content_settings->IsContentBlocked(
+          CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA)) ? 1 : 0;
 
   std::string radio_allow_label = l10n_util::GetStringFUTF8(
       radio_allow_label_id, base::UTF8ToUTF16(display_host));
@@ -752,18 +738,12 @@ void ContentSettingMediaStreamBubbleModel::UpdateSettings(
             tab_content_settings->media_stream_access_origin());
     ContentSettingsPattern secondary_pattern =
         ContentSettingsPattern::Wildcard();
-    if (state_ == TabSpecificContentSettings::MICROPHONE_ACCESSED ||
-        state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED ||
-        state_ == TabSpecificContentSettings::MICROPHONE_BLOCKED ||
-        state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_BLOCKED) {
+    if (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) {
       content_settings->SetContentSetting(
           primary_pattern, secondary_pattern,
           CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC, std::string(), setting);
     }
-    if (state_ == TabSpecificContentSettings::CAMERA_ACCESSED ||
-        state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED ||
-        state_ == TabSpecificContentSettings::CAMERA_BLOCKED ||
-        state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_BLOCKED) {
+    if (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) {
       content_settings->SetContentSetting(
           primary_pattern, secondary_pattern,
           CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA, std::string(), setting);
@@ -788,8 +768,8 @@ void ContentSettingMediaStreamBubbleModel::SetMediaMenus() {
       TabSpecificContentSettings::FromWebContents(web_contents());
   const std::string& requested_microphone =
        content_settings->media_stream_requested_audio_device();
-   const std::string& requested_camera =
-       content_settings->media_stream_requested_video_device();
+  const std::string& requested_camera =
+      content_settings->media_stream_requested_video_device();
 
   // Add microphone menu.
   PrefService* prefs = profile()->GetPrefs();
@@ -798,19 +778,7 @@ void ContentSettingMediaStreamBubbleModel::SetMediaMenus() {
   const content::MediaStreamDevices& microphones =
       dispatcher->GetAudioCaptureDevices();
 
-  bool show_mic_menu =
-      (state_ == TabSpecificContentSettings::MICROPHONE_ACCESSED ||
-       state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED ||
-       state_ == TabSpecificContentSettings::MICROPHONE_BLOCKED ||
-       state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_BLOCKED);
-  bool show_camera_menu =
-      (state_ == TabSpecificContentSettings::CAMERA_ACCESSED ||
-       state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_ACCESSED ||
-       state_ == TabSpecificContentSettings::CAMERA_BLOCKED ||
-       state_ == TabSpecificContentSettings::MICROPHONE_CAMERA_BLOCKED);
-  DCHECK(show_mic_menu || show_camera_menu);
-
-  if (show_mic_menu) {
+  if (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) {
     MediaMenu mic_menu;
     mic_menu.label = l10n_util::GetStringUTF8(IDS_MEDIA_SELECTED_MIC_LABEL);
     if (!microphones.empty()) {
@@ -832,7 +800,7 @@ void ContentSettingMediaStreamBubbleModel::SetMediaMenus() {
     add_media_menu(content::MEDIA_DEVICE_AUDIO_CAPTURE, mic_menu);
   }
 
-  if (show_camera_menu) {
+  if (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) {
     const content::MediaStreamDevices& cameras =
         dispatcher->GetVideoCaptureDevices();
     MediaMenu camera_menu;
@@ -858,6 +826,15 @@ void ContentSettingMediaStreamBubbleModel::SetMediaMenus() {
   }
 }
 
+void ContentSettingMediaStreamBubbleModel::SetCustomLink() {
+  TabSpecificContentSettings* content_settings =
+      TabSpecificContentSettings::FromWebContents(web_contents());
+  if (content_settings->IsMicrophoneCameraStateChanged()) {
+    set_custom_link(l10n_util::GetStringUTF8(
+        IDS_MEDIASTREAM_SETTING_CHANGED_MESSAGE));
+  }
+}
+
 void ContentSettingMediaStreamBubbleModel::OnRadioClicked(int radio_index) {
   selected_item_ = radio_index;
 }
@@ -884,12 +861,12 @@ class ContentSettingDomainListBubbleModel
                                       WebContents* web_contents,
                                       Profile* profile,
                                       ContentSettingsType content_type);
-  virtual ~ContentSettingDomainListBubbleModel() {}
+  ~ContentSettingDomainListBubbleModel() override {}
 
  private:
   void MaybeAddDomainList(const std::set<std::string>& hosts, int title_id);
   void SetDomainsAndCustomLink();
-  virtual void OnCustomLinkClicked() OVERRIDE;
+  void OnCustomLinkClicked() override;
 };
 
 ContentSettingDomainListBubbleModel::ContentSettingDomainListBubbleModel(
@@ -973,10 +950,10 @@ class ContentSettingMixedScriptBubbleModel
                                        Profile* profile,
                                        ContentSettingsType content_type);
 
-  virtual ~ContentSettingMixedScriptBubbleModel() {}
+  ~ContentSettingMixedScriptBubbleModel() override {}
 
  private:
-  virtual void OnCustomLinkClicked() OVERRIDE;
+  void OnCustomLinkClicked() override;
 };
 
 ContentSettingMixedScriptBubbleModel::ContentSettingMixedScriptBubbleModel(
@@ -987,15 +964,19 @@ ContentSettingMixedScriptBubbleModel::ContentSettingMixedScriptBubbleModel(
     : ContentSettingTitleLinkAndCustomModel(
         delegate, web_contents, profile, content_type) {
   DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_MIXEDSCRIPT);
+  TabSpecificContentSettings::RecordMixedScriptAction(
+      TabSpecificContentSettings::MIXED_SCRIPT_ACTION_DISPLAYED_BUBBLE);
   set_custom_link_enabled(true);
 }
 
 void ContentSettingMixedScriptBubbleModel::OnCustomLinkClicked() {
-  content::RecordAction(UserMetricsAction("MixedScript_LoadAnyway_Bubble"));
+  TabSpecificContentSettings::RecordMixedScriptAction(
+      TabSpecificContentSettings::MIXED_SCRIPT_ACTION_CLICKED_ALLOW);
   DCHECK(web_contents());
-  content::RenderViewHost* host = web_contents()->GetRenderViewHost();
-  host->Send(new ChromeViewMsg_SetAllowRunningInsecureContent(
-      host->GetRoutingID(), true));
+  web_contents()->SendToAllFrames(
+      new ChromeViewMsg_SetAllowRunningInsecureContent(MSG_ROUTING_NONE, true));
+  web_contents()->GetMainFrame()->Send(new ChromeViewMsg_ReloadFrame(
+      web_contents()->GetMainFrame()->GetRoutingID()));
 }
 
 ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel(
@@ -1010,7 +991,6 @@ ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel(
       registry_(registry),
       pending_handler_(ProtocolHandler::EmptyProtocolHandler()),
       previous_handler_(ProtocolHandler::EmptyProtocolHandler()) {
-
   DCHECK_EQ(CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, content_type);
 
   TabSpecificContentSettings* content_settings =
@@ -1029,23 +1009,22 @@ ContentSettingRPHBubbleModel::ContentSettingRPHBubbleModel(
     protocol = base::UTF8ToUTF16(pending_handler_.protocol());
   }
 
+  // Note that we ignore the |title| parameter.
   if (previous_handler_.IsEmpty()) {
     set_title(l10n_util::GetStringFUTF8(
         IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM,
-        pending_handler_.title(),
         base::UTF8ToUTF16(pending_handler_.url().host()),
         protocol));
   } else {
     set_title(l10n_util::GetStringFUTF8(
         IDS_REGISTER_PROTOCOL_HANDLER_CONFIRM_REPLACE,
-        pending_handler_.title(),
         base::UTF8ToUTF16(pending_handler_.url().host()),
-        protocol, previous_handler_.title()));
+        protocol,
+        base::UTF8ToUTF16(previous_handler_.url().host())));
   }
 
   std::string radio_allow_label =
-      l10n_util::GetStringFUTF8(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT,
-                                pending_handler_.title());
+      l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_ACCEPT);
   std::string radio_deny_label =
       l10n_util::GetStringUTF8(IDS_REGISTER_PROTOCOL_HANDLER_DENY);
   std::string radio_ignore_label =
@@ -1131,23 +1110,22 @@ void ContentSettingRPHBubbleModel::ClearOrSetPreviousHandler() {
   }
 }
 
-// TODO(toyoshim): Should share as many code with geolocation as possible.
-class ContentSettingMIDISysExBubbleModel
+class ContentSettingMidiSysExBubbleModel
     : public ContentSettingTitleAndLinkModel {
  public:
-  ContentSettingMIDISysExBubbleModel(Delegate* delegate,
+  ContentSettingMidiSysExBubbleModel(Delegate* delegate,
                                      WebContents* web_contents,
                                      Profile* profile,
                                      ContentSettingsType content_type);
-  virtual ~ContentSettingMIDISysExBubbleModel() {}
+  ~ContentSettingMidiSysExBubbleModel() override {}
 
  private:
   void MaybeAddDomainList(const std::set<std::string>& hosts, int title_id);
   void SetDomainsAndCustomLink();
-  virtual void OnCustomLinkClicked() OVERRIDE;
+  void OnCustomLinkClicked() override;
 };
 
-ContentSettingMIDISysExBubbleModel::ContentSettingMIDISysExBubbleModel(
+ContentSettingMidiSysExBubbleModel::ContentSettingMidiSysExBubbleModel(
     Delegate* delegate,
     WebContents* web_contents,
     Profile* profile,
@@ -1158,7 +1136,7 @@ ContentSettingMIDISysExBubbleModel::ContentSettingMIDISysExBubbleModel(
   SetDomainsAndCustomLink();
 }
 
-void ContentSettingMIDISysExBubbleModel::MaybeAddDomainList(
+void ContentSettingMidiSysExBubbleModel::MaybeAddDomainList(
     const std::set<std::string>& hosts, int title_id) {
   if (!hosts.empty()) {
     DomainList domain_list;
@@ -1168,7 +1146,7 @@ void ContentSettingMIDISysExBubbleModel::MaybeAddDomainList(
   }
 }
 
-void ContentSettingMIDISysExBubbleModel::SetDomainsAndCustomLink() {
+void ContentSettingMidiSysExBubbleModel::SetDomainsAndCustomLink() {
   TabSpecificContentSettings* content_settings =
       TabSpecificContentSettings::FromWebContents(web_contents());
   const ContentSettingsUsagesState& usages_state =
@@ -1195,7 +1173,7 @@ void ContentSettingMIDISysExBubbleModel::SetDomainsAndCustomLink() {
   }
 }
 
-void ContentSettingMIDISysExBubbleModel::OnCustomLinkClicked() {
+void ContentSettingMidiSysExBubbleModel::OnCustomLinkClicked() {
   if (!web_contents())
     return;
   // Reset this embedder's entry to default for each of the requesting
@@ -1251,12 +1229,12 @@ ContentSettingBubbleModel*
   }
   if (content_type == CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS) {
     ProtocolHandlerRegistry* registry =
-        ProtocolHandlerRegistryFactory::GetForProfile(profile);
+        ProtocolHandlerRegistryFactory::GetForBrowserContext(profile);
     return new ContentSettingRPHBubbleModel(delegate, web_contents, profile,
                                             registry, content_type);
   }
   if (content_type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) {
-    return new ContentSettingMIDISysExBubbleModel(delegate, web_contents,
+    return new ContentSettingMidiSysExBubbleModel(delegate, web_contents,
                                                   profile, content_type);
   }
   return new ContentSettingSingleRadioGroup(delegate, web_contents, profile,