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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" | 11 #include "chrome/browser/content_settings/chrome_content_settings_utils.h" |
12 #include "chrome/browser/content_settings/cookie_settings_factory.h" | 12 #include "chrome/browser/content_settings/cookie_settings_factory.h" |
13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 13 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
14 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 14 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
15 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" | 15 #include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h" |
16 #include "chrome/browser/infobars/infobar_service.h" | 16 #include "chrome/browser/infobars/infobar_service.h" |
17 #include "chrome/browser/media/media_capture_devices_dispatcher.h" | 17 #include "chrome/browser/media/media_capture_devices_dispatcher.h" |
18 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 18 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" | 20 #include "chrome/browser/ui/blocked_content/popup_blocker_tab_helper.h" |
21 #include "chrome/browser/ui/browser_navigator.h" | 21 #include "chrome/browser/ui/browser_navigator.h" |
22 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 22 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
23 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega
te.h" | 23 #include "chrome/browser/ui/content_settings/content_setting_bubble_model_delega
te.h" |
24 #include "chrome/browser/ui/elide_url.h" | |
25 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
27 #include "chrome/common/render_messages.h" | 26 #include "chrome/common/render_messages.h" |
28 #include "chrome/grit/generated_resources.h" | 27 #include "chrome/grit/generated_resources.h" |
29 #include "components/content_settings/content/common/content_settings_messages.h
" | 28 #include "components/content_settings/content/common/content_settings_messages.h
" |
30 #include "components/content_settings/core/browser/content_settings_utils.h" | 29 #include "components/content_settings/core/browser/content_settings_utils.h" |
31 #include "components/content_settings/core/browser/cookie_settings.h" | 30 #include "components/content_settings/core/browser/cookie_settings.h" |
32 #include "components/content_settings/core/common/content_settings.h" | 31 #include "components/content_settings/core/common/content_settings.h" |
| 32 #include "components/secure_display/elide_url.h" |
33 #include "content/public/browser/notification_service.h" | 33 #include "content/public/browser/notification_service.h" |
34 #include "content/public/browser/render_frame_host.h" | 34 #include "content/public/browser/render_frame_host.h" |
35 #include "content/public/browser/render_process_host.h" | 35 #include "content/public/browser/render_process_host.h" |
36 #include "content/public/browser/render_view_host.h" | 36 #include "content/public/browser/render_view_host.h" |
37 #include "content/public/browser/user_metrics.h" | 37 #include "content/public/browser/user_metrics.h" |
38 #include "content/public/browser/web_contents.h" | 38 #include "content/public/browser/web_contents.h" |
39 #include "content/public/browser/web_contents_delegate.h" | 39 #include "content/public/browser/web_contents_delegate.h" |
40 #include "content/public/common/origin_util.h" | 40 #include "content/public/common/origin_util.h" |
41 #include "grit/components_strings.h" | 41 #include "grit/components_strings.h" |
42 #include "grit/theme_resources.h" | 42 #include "grit/theme_resources.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 268 } |
269 | 269 |
270 bool ContentSettingSingleRadioGroup::settings_changed() const { | 270 bool ContentSettingSingleRadioGroup::settings_changed() const { |
271 return selected_item_ != bubble_content().radio_group.default_item; | 271 return selected_item_ != bubble_content().radio_group.default_item; |
272 } | 272 } |
273 | 273 |
274 // Initialize the radio group by setting the appropriate labels for the | 274 // Initialize the radio group by setting the appropriate labels for the |
275 // content type and setting the default value based on the content setting. | 275 // content type and setting the default value based on the content setting. |
276 void ContentSettingSingleRadioGroup::SetRadioGroup() { | 276 void ContentSettingSingleRadioGroup::SetRadioGroup() { |
277 GURL url = web_contents()->GetURL(); | 277 GURL url = web_contents()->GetURL(); |
278 base::string16 display_host = FormatUrlForSecurityDisplay( | 278 base::string16 display_host = secure_display::FormatUrlForSecurityDisplay( |
279 url, profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 279 url, profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
280 if (display_host.empty()) | 280 if (display_host.empty()) |
281 display_host = base::ASCIIToUTF16(url.spec()); | 281 display_host = base::ASCIIToUTF16(url.spec()); |
282 | 282 |
283 TabSpecificContentSettings* content_settings = | 283 TabSpecificContentSettings* content_settings = |
284 TabSpecificContentSettings::FromWebContents(web_contents()); | 284 TabSpecificContentSettings::FromWebContents(web_contents()); |
285 bool allowed = | 285 bool allowed = |
286 !content_settings->IsContentBlocked(content_type()); | 286 !content_settings->IsContentBlocked(content_type()); |
287 DCHECK(!allowed || | 287 DCHECK(!allowed || |
288 content_settings->IsContentAllowed(content_type())); | 288 content_settings->IsContentAllowed(content_type())); |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 set_title(l10n_util::GetStringUTF8(title_id)); | 670 set_title(l10n_util::GetStringUTF8(title_id)); |
671 } | 671 } |
672 | 672 |
673 void ContentSettingMediaStreamBubbleModel::SetRadioGroup() { | 673 void ContentSettingMediaStreamBubbleModel::SetRadioGroup() { |
674 TabSpecificContentSettings* content_settings = | 674 TabSpecificContentSettings* content_settings = |
675 TabSpecificContentSettings::FromWebContents(web_contents()); | 675 TabSpecificContentSettings::FromWebContents(web_contents()); |
676 GURL url = content_settings->media_stream_access_origin(); | 676 GURL url = content_settings->media_stream_access_origin(); |
677 RadioGroup radio_group; | 677 RadioGroup radio_group; |
678 radio_group.url = url; | 678 radio_group.url = url; |
679 | 679 |
680 base::string16 display_host_utf16 = FormatUrlForSecurityDisplay( | 680 base::string16 display_host_utf16 = |
681 url, profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); | 681 secure_display::FormatUrlForSecurityDisplay( |
| 682 url, profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)); |
682 std::string display_host(base::UTF16ToUTF8(display_host_utf16)); | 683 std::string display_host(base::UTF16ToUTF8(display_host_utf16)); |
683 if (display_host.empty()) | 684 if (display_host.empty()) |
684 display_host = url.spec(); | 685 display_host = url.spec(); |
685 | 686 |
686 bool is_mic = (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) != 0; | 687 bool is_mic = (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) != 0; |
687 bool is_cam = (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) != 0; | 688 bool is_cam = (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) != 0; |
688 DCHECK(is_mic || is_cam); | 689 DCHECK(is_mic || is_cam); |
689 int radio_allow_label_id = 0; | 690 int radio_allow_label_id = 0; |
690 int radio_block_label_id = 0; | 691 int radio_block_label_id = 0; |
691 if (state_ & (TabSpecificContentSettings::MICROPHONE_BLOCKED | | 692 if (state_ & (TabSpecificContentSettings::MICROPHONE_BLOCKED | |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1298 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1299 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
1299 DCHECK_EQ(web_contents_, | 1300 DCHECK_EQ(web_contents_, |
1300 content::Source<WebContents>(source).ptr()); | 1301 content::Source<WebContents>(source).ptr()); |
1301 web_contents_ = NULL; | 1302 web_contents_ = NULL; |
1302 } else { | 1303 } else { |
1303 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1304 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
1304 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1305 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
1305 profile_ = NULL; | 1306 profile_ = NULL; |
1306 } | 1307 } |
1307 } | 1308 } |
OLD | NEW |