OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" | 5 #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 ContentSettingSimpleBubbleModel::ContentSettingSimpleBubbleModel( | 108 ContentSettingSimpleBubbleModel::ContentSettingSimpleBubbleModel( |
109 Delegate* delegate, | 109 Delegate* delegate, |
110 WebContents* web_contents, | 110 WebContents* web_contents, |
111 Profile* profile, | 111 Profile* profile, |
112 ContentSettingsType content_type) | 112 ContentSettingsType content_type) |
113 : ContentSettingBubbleModel(delegate, web_contents, profile), | 113 : ContentSettingBubbleModel(delegate, web_contents, profile), |
114 content_type_(content_type) { | 114 content_type_(content_type) { |
115 // Notifications do not have a bubble. | 115 // Notifications do not have a bubble. |
116 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 116 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
117 SetTitle(); | 117 SetTitle(); |
118 SetManageLink(); | 118 SetManageText(); |
119 SetCustomLink(); | 119 SetCustomLink(); |
120 } | 120 } |
121 | 121 |
122 ContentSettingSimpleBubbleModel* | 122 ContentSettingSimpleBubbleModel* |
123 ContentSettingSimpleBubbleModel::AsSimpleBubbleModel() { | 123 ContentSettingSimpleBubbleModel::AsSimpleBubbleModel() { |
124 return this; | 124 return this; |
125 } | 125 } |
126 | 126 |
127 void ContentSettingSimpleBubbleModel::SetTitle() { | 127 void ContentSettingSimpleBubbleModel::SetTitle() { |
128 TabSpecificContentSettings* content_settings = NULL; | 128 TabSpecificContentSettings* content_settings = NULL; |
(...skipping 26 matching lines...) Expand all Loading... |
155 !content_settings->IsContentBlocked(content_type())) { | 155 !content_settings->IsContentBlocked(content_type())) { |
156 title_ids = kAccessedTitleIDs; | 156 title_ids = kAccessedTitleIDs; |
157 num_title_ids = arraysize(kAccessedTitleIDs); | 157 num_title_ids = arraysize(kAccessedTitleIDs); |
158 } | 158 } |
159 int title_id = | 159 int title_id = |
160 GetIdForContentType(title_ids, num_title_ids, content_type()); | 160 GetIdForContentType(title_ids, num_title_ids, content_type()); |
161 if (title_id) | 161 if (title_id) |
162 set_title(l10n_util::GetStringUTF16(title_id)); | 162 set_title(l10n_util::GetStringUTF16(title_id)); |
163 } | 163 } |
164 | 164 |
165 void ContentSettingSimpleBubbleModel::SetManageLink() { | 165 void ContentSettingSimpleBubbleModel::SetManageText() { |
166 static const ContentSettingsTypeIdEntry kLinkIDs[] = { | 166 static const ContentSettingsTypeIdEntry kLinkIDs[] = { |
167 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK}, | 167 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK}, |
168 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_LINK}, | 168 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_LINK}, |
169 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_LINK}, | 169 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_LINK}, |
170 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK}, | 170 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_LINK}, |
171 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK}, | 171 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_LINK}, |
172 {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK}, | 172 {CONTENT_SETTINGS_TYPE_GEOLOCATION, IDS_GEOLOCATION_BUBBLE_MANAGE_LINK}, |
173 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_LEARN_MORE}, | 173 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, IDS_LEARN_MORE}, |
174 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, IDS_HANDLERS_BUBBLE_MANAGE_LINK}, | 174 {CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS, IDS_HANDLERS_BUBBLE_MANAGE_LINK}, |
175 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_PPAPI_BROKER_BUBBLE_MANAGE_LINK}, | 175 {CONTENT_SETTINGS_TYPE_PPAPI_BROKER, IDS_PPAPI_BROKER_BUBBLE_MANAGE_LINK}, |
176 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOADS_LINK}, | 176 {CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOADS_LINK}, |
177 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_MIDI_SYSEX_BUBBLE_MANAGE_LINK}, | 177 {CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_MIDI_SYSEX_BUBBLE_MANAGE_LINK}, |
178 }; | 178 }; |
179 set_manage_link(l10n_util::GetStringUTF8( | 179 set_manage_text(l10n_util::GetStringUTF8( |
180 GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type()))); | 180 GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type()))); |
181 } | 181 } |
182 | 182 |
183 void ContentSettingSimpleBubbleModel::OnManageLinkClicked() { | 183 void ContentSettingSimpleBubbleModel::OnManageLinkClicked() { |
184 if (delegate()) | 184 if (delegate()) |
185 delegate()->ShowContentSettingsPage(content_type()); | 185 delegate()->ShowContentSettingsPage(content_type()); |
186 | 186 |
187 if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS) { | 187 if (content_type() == CONTENT_SETTINGS_TYPE_PLUGINS) { |
188 content_settings::RecordPluginsAction( | 188 content_settings::RecordPluginsAction( |
189 content_settings::PLUGINS_ACTION_CLICKED_MANAGE_PLUGIN_BLOCKING); | 189 content_settings::PLUGINS_ACTION_CLICKED_MANAGE_PLUGIN_BLOCKING); |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 radio_item_setting_[1] = CONTENT_SETTING_BLOCK; | 610 radio_item_setting_[1] = CONTENT_SETTING_BLOCK; |
611 | 611 |
612 TabSpecificContentSettings* content_settings = | 612 TabSpecificContentSettings* content_settings = |
613 TabSpecificContentSettings::FromWebContents(web_contents); | 613 TabSpecificContentSettings::FromWebContents(web_contents); |
614 state_ = content_settings->GetMicrophoneCameraState(); | 614 state_ = content_settings->GetMicrophoneCameraState(); |
615 DCHECK(CameraAccessed() || MicrophoneAccessed()); | 615 DCHECK(CameraAccessed() || MicrophoneAccessed()); |
616 | 616 |
617 SetTitle(); | 617 SetTitle(); |
618 SetRadioGroup(); | 618 SetRadioGroup(); |
619 SetMediaMenus(); | 619 SetMediaMenus(); |
620 SetManageLink(); | 620 SetManageText(); |
621 SetCustomLink(); | 621 SetCustomLink(); |
622 } | 622 } |
623 | 623 |
624 ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() { | 624 ContentSettingMediaStreamBubbleModel::~ContentSettingMediaStreamBubbleModel() { |
625 // On some platforms (e.g. MacOS X) it is possible to close a tab while the | 625 // On some platforms (e.g. MacOS X) it is possible to close a tab while the |
626 // media stream bubble is open. This resets the web contents to NULL. | 626 // media stream bubble is open. This resets the web contents to NULL. |
627 if (!web_contents()) | 627 if (!web_contents()) |
628 return; | 628 return; |
629 | 629 |
630 for (const std::pair<content::MediaStreamType, MediaMenu>& media_menu : | 630 for (const std::pair<content::MediaStreamType, MediaMenu>& media_menu : |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 } | 853 } |
854 | 854 |
855 camera_menu.default_device = | 855 camera_menu.default_device = |
856 GetMediaDeviceById(preferred_camera, cameras); | 856 GetMediaDeviceById(preferred_camera, cameras); |
857 camera_menu.selected_device = camera_menu.default_device; | 857 camera_menu.selected_device = camera_menu.default_device; |
858 } | 858 } |
859 add_media_menu(content::MEDIA_DEVICE_VIDEO_CAPTURE, camera_menu); | 859 add_media_menu(content::MEDIA_DEVICE_VIDEO_CAPTURE, camera_menu); |
860 } | 860 } |
861 } | 861 } |
862 | 862 |
863 void ContentSettingMediaStreamBubbleModel::SetManageLink() { | 863 void ContentSettingMediaStreamBubbleModel::SetManageText() { |
864 // By default, the manage link refers to both media types. We only need | 864 // By default, the manage link refers to both media types. We only need |
865 // to change the link text if only one media type was accessed. | 865 // to change the link text if only one media type was accessed. |
866 int link_id; | 866 int link_id; |
867 if (CameraAccessed() && MicrophoneAccessed()) { | 867 if (CameraAccessed() && MicrophoneAccessed()) { |
868 link_id = IDS_MEDIASTREAM_BUBBLE_MANAGE_LINK; | 868 link_id = IDS_MEDIASTREAM_BUBBLE_MANAGE_LINK; |
869 } else if (CameraAccessed()) { | 869 } else if (CameraAccessed()) { |
870 link_id = IDS_MEDIASTREAM_CAMERA_BUBBLE_MANAGE_LINK; | 870 link_id = IDS_MEDIASTREAM_CAMERA_BUBBLE_MANAGE_LINK; |
871 } else if (MicrophoneAccessed()) { | 871 } else if (MicrophoneAccessed()) { |
872 link_id = IDS_MEDIASTREAM_MICROPHONE_BUBBLE_MANAGE_LINK; | 872 link_id = IDS_MEDIASTREAM_MICROPHONE_BUBBLE_MANAGE_LINK; |
873 } else { | 873 } else { |
874 NOTREACHED(); | 874 NOTREACHED(); |
875 return; | 875 return; |
876 } | 876 } |
877 | 877 |
878 set_manage_link(l10n_util::GetStringUTF8(link_id)); | 878 set_manage_text(l10n_util::GetStringUTF8(link_id)); |
879 } | 879 } |
880 | 880 |
881 void ContentSettingMediaStreamBubbleModel::SetCustomLink() { | 881 void ContentSettingMediaStreamBubbleModel::SetCustomLink() { |
882 TabSpecificContentSettings* content_settings = | 882 TabSpecificContentSettings* content_settings = |
883 TabSpecificContentSettings::FromWebContents(web_contents()); | 883 TabSpecificContentSettings::FromWebContents(web_contents()); |
884 if (content_settings->IsMicrophoneCameraStateChanged()) { | 884 if (content_settings->IsMicrophoneCameraStateChanged()) { |
885 set_custom_link(l10n_util::GetStringUTF8( | 885 set_custom_link(l10n_util::GetStringUTF8( |
886 IDS_MEDIASTREAM_SETTING_CHANGED_MESSAGE)); | 886 IDS_MEDIASTREAM_SETTING_CHANGED_MESSAGE)); |
887 } | 887 } |
888 } | 888 } |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 | 1193 |
1194 // ContentSettingSubresourceFilterBubbleModel ---------------------------------- | 1194 // ContentSettingSubresourceFilterBubbleModel ---------------------------------- |
1195 | 1195 |
1196 ContentSettingSubresourceFilterBubbleModel:: | 1196 ContentSettingSubresourceFilterBubbleModel:: |
1197 ContentSettingSubresourceFilterBubbleModel(Delegate* delegate, | 1197 ContentSettingSubresourceFilterBubbleModel(Delegate* delegate, |
1198 WebContents* web_contents, | 1198 WebContents* web_contents, |
1199 Profile* profile) | 1199 Profile* profile) |
1200 : ContentSettingBubbleModel(delegate, web_contents, profile) { | 1200 : ContentSettingBubbleModel(delegate, web_contents, profile) { |
1201 SetTitle(); | 1201 SetTitle(); |
1202 SetMessage(); | 1202 SetMessage(); |
1203 SetManageLink(); | 1203 SetManageText(); |
1204 } | 1204 } |
1205 | 1205 |
1206 ContentSettingSubresourceFilterBubbleModel:: | 1206 ContentSettingSubresourceFilterBubbleModel:: |
1207 ~ContentSettingSubresourceFilterBubbleModel() {} | 1207 ~ContentSettingSubresourceFilterBubbleModel() {} |
1208 | 1208 |
1209 void ContentSettingSubresourceFilterBubbleModel::SetTitle() { | 1209 void ContentSettingSubresourceFilterBubbleModel::SetTitle() { |
1210 set_title( | 1210 set_title( |
1211 l10n_util::GetStringUTF16(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE)); | 1211 l10n_util::GetStringUTF16(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE)); |
1212 } | 1212 } |
1213 | 1213 |
1214 void ContentSettingSubresourceFilterBubbleModel::SetManageLink() { | 1214 void ContentSettingSubresourceFilterBubbleModel::SetManageText() { |
1215 // TODO(melandory): introduce the button instead of link. | 1215 set_manage_text( |
1216 set_manage_link( | |
1217 l10n_util::GetStringUTF8(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_RELOAD)); | 1216 l10n_util::GetStringUTF8(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_RELOAD)); |
| 1217 set_show_manage_text_as_button(true); |
1218 } | 1218 } |
1219 | 1219 |
1220 void ContentSettingSubresourceFilterBubbleModel::SetMessage() { | 1220 void ContentSettingSubresourceFilterBubbleModel::SetMessage() { |
1221 set_message(l10n_util::GetStringUTF16( | 1221 set_message(l10n_util::GetStringUTF16( |
1222 IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_EXPLANATION)); | 1222 IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_EXPLANATION)); |
1223 } | 1223 } |
1224 | 1224 |
1225 void ContentSettingSubresourceFilterBubbleModel::OnManageLinkClicked() { | 1225 void ContentSettingSubresourceFilterBubbleModel::OnManageLinkClicked() { |
1226 subresource_filter::ContentSubresourceFilterDriverFactory* driver_factory = | 1226 subresource_filter::ContentSubresourceFilterDriverFactory* driver_factory = |
1227 subresource_filter::ContentSubresourceFilterDriverFactory:: | 1227 subresource_filter::ContentSubresourceFilterDriverFactory:: |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1398 | 1398 |
1399 ContentSettingBubbleModel::MediaMenu::MediaMenu() : disabled(false) {} | 1399 ContentSettingBubbleModel::MediaMenu::MediaMenu() : disabled(false) {} |
1400 | 1400 |
1401 ContentSettingBubbleModel::MediaMenu::MediaMenu(const MediaMenu& other) = | 1401 ContentSettingBubbleModel::MediaMenu::MediaMenu(const MediaMenu& other) = |
1402 default; | 1402 default; |
1403 | 1403 |
1404 ContentSettingBubbleModel::MediaMenu::~MediaMenu() {} | 1404 ContentSettingBubbleModel::MediaMenu::~MediaMenu() {} |
1405 | 1405 |
1406 ContentSettingBubbleModel::BubbleContent::BubbleContent() | 1406 ContentSettingBubbleModel::BubbleContent::BubbleContent() |
1407 : radio_group_enabled(false), | 1407 : radio_group_enabled(false), |
1408 custom_link_enabled(false) { | 1408 custom_link_enabled(false), |
1409 } | 1409 show_manage_text_as_button(false) {} |
1410 | 1410 |
1411 ContentSettingBubbleModel::BubbleContent::~BubbleContent() {} | 1411 ContentSettingBubbleModel::BubbleContent::~BubbleContent() {} |
1412 | 1412 |
1413 void ContentSettingBubbleModel::Observe( | 1413 void ContentSettingBubbleModel::Observe( |
1414 int type, | 1414 int type, |
1415 const content::NotificationSource& source, | 1415 const content::NotificationSource& source, |
1416 const content::NotificationDetails& details) { | 1416 const content::NotificationDetails& details) { |
1417 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1417 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
1418 DCHECK_EQ(web_contents_, | 1418 DCHECK_EQ(web_contents_, |
1419 content::Source<WebContents>(source).ptr()); | 1419 content::Source<WebContents>(source).ptr()); |
(...skipping 14 matching lines...) Expand all Loading... |
1434 ContentSettingMediaStreamBubbleModel* | 1434 ContentSettingMediaStreamBubbleModel* |
1435 ContentSettingBubbleModel::AsMediaStreamBubbleModel() { | 1435 ContentSettingBubbleModel::AsMediaStreamBubbleModel() { |
1436 // In general, bubble models might not inherit from the media bubble model. | 1436 // In general, bubble models might not inherit from the media bubble model. |
1437 return nullptr; | 1437 return nullptr; |
1438 } | 1438 } |
1439 | 1439 |
1440 ContentSettingSubresourceFilterBubbleModel* | 1440 ContentSettingSubresourceFilterBubbleModel* |
1441 ContentSettingBubbleModel::AsSubresourceFilterBubbleModel() { | 1441 ContentSettingBubbleModel::AsSubresourceFilterBubbleModel() { |
1442 return nullptr; | 1442 return nullptr; |
1443 } | 1443 } |
OLD | NEW |