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.h" | 12 #include "chrome/browser/content_settings/cookie_settings.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" | |
24 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
26 #include "chrome/common/render_messages.h" | 27 #include "chrome/common/render_messages.h" |
27 #include "chrome/grit/generated_resources.h" | 28 #include "chrome/grit/generated_resources.h" |
28 #include "components/content_settings/content/common/content_settings_messages.h " | 29 #include "components/content_settings/content/common/content_settings_messages.h " |
29 #include "components/content_settings/core/browser/content_settings_utils.h" | 30 #include "components/content_settings/core/browser/content_settings_utils.h" |
30 #include "components/content_settings/core/common/content_settings.h" | 31 #include "components/content_settings/core/common/content_settings.h" |
31 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
32 #include "content/public/browser/render_frame_host.h" | 33 #include "content/public/browser/render_frame_host.h" |
33 #include "content/public/browser/render_process_host.h" | 34 #include "content/public/browser/render_process_host.h" |
34 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
35 #include "content/public/browser/user_metrics.h" | 36 #include "content/public/browser/user_metrics.h" |
36 #include "content/public/browser/web_contents.h" | 37 #include "content/public/browser/web_contents.h" |
37 #include "content/public/browser/web_contents_delegate.h" | 38 #include "content/public/browser/web_contents_delegate.h" |
38 #include "content/public/common/origin_util.h" | 39 #include "content/public/common/origin_util.h" |
39 #include "grit/components_strings.h" | 40 #include "grit/components_strings.h" |
40 #include "grit/theme_resources.h" | 41 #include "grit/theme_resources.h" |
41 #include "net/base/net_util.h" | 42 #include "net/base/net_util.h" |
msw
2015/05/29 00:18:51
Can this be removed now?
palmer
2015/05/29 17:52:12
Done.
| |
42 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
43 #include "ui/base/resource/resource_bundle.h" | 44 #include "ui/base/resource/resource_bundle.h" |
44 #include "ui/resources/grit/ui_resources.h" | 45 #include "ui/resources/grit/ui_resources.h" |
45 | 46 |
46 using base::UserMetricsAction; | 47 using base::UserMetricsAction; |
47 using content::WebContents; | 48 using content::WebContents; |
48 using content_settings::SettingInfo; | 49 using content_settings::SettingInfo; |
49 using content_settings::SettingSource; | 50 using content_settings::SettingSource; |
50 using content_settings::SETTING_SOURCE_USER; | 51 using content_settings::SETTING_SOURCE_USER; |
51 using content_settings::SETTING_SOURCE_NONE; | 52 using content_settings::SETTING_SOURCE_NONE; |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
267 } | 268 } |
268 | 269 |
269 bool ContentSettingSingleRadioGroup::settings_changed() const { | 270 bool ContentSettingSingleRadioGroup::settings_changed() const { |
270 return selected_item_ != bubble_content().radio_group.default_item; | 271 return selected_item_ != bubble_content().radio_group.default_item; |
271 } | 272 } |
272 | 273 |
273 // Initialize the radio group by setting the appropriate labels for the | 274 // Initialize the radio group by setting the appropriate labels for the |
274 // 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. |
275 void ContentSettingSingleRadioGroup::SetRadioGroup() { | 276 void ContentSettingSingleRadioGroup::SetRadioGroup() { |
276 GURL url = web_contents()->GetURL(); | 277 GURL url = web_contents()->GetURL(); |
277 base::string16 display_host; | 278 base::string16 display_host = FormatOriginForDisplay( |
278 net::AppendFormattedHost( | 279 url, profile()->GetPrefs()->GetString(prefs::kAcceptLanguages), false); |
279 url, | |
280 profile()->GetPrefs()->GetString(prefs::kAcceptLanguages), | |
281 &display_host); | |
282 | |
283 if (display_host.empty()) | 280 if (display_host.empty()) |
284 display_host = base::ASCIIToUTF16(url.spec()); | 281 display_host = base::ASCIIToUTF16(url.spec()); |
285 | 282 |
286 TabSpecificContentSettings* content_settings = | 283 TabSpecificContentSettings* content_settings = |
287 TabSpecificContentSettings::FromWebContents(web_contents()); | 284 TabSpecificContentSettings::FromWebContents(web_contents()); |
288 bool allowed = | 285 bool allowed = |
289 !content_settings->IsContentBlocked(content_type()); | 286 !content_settings->IsContentBlocked(content_type()); |
290 DCHECK(!allowed || | 287 DCHECK(!allowed || |
291 content_settings->IsContentAllowed(content_type())); | 288 content_settings->IsContentAllowed(content_type())); |
292 | 289 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 web_contents, | 548 web_contents, |
552 profile, | 549 profile, |
553 CONTENT_SETTINGS_TYPE_POPUPS) { | 550 CONTENT_SETTINGS_TYPE_POPUPS) { |
554 if (web_contents) { | 551 if (web_contents) { |
555 // Build blocked popup list. | 552 // Build blocked popup list. |
556 std::map<int32, GURL> blocked_popups = | 553 std::map<int32, GURL> blocked_popups = |
557 PopupBlockerTabHelper::FromWebContents(web_contents) | 554 PopupBlockerTabHelper::FromWebContents(web_contents) |
558 ->GetBlockedPopupRequests(); | 555 ->GetBlockedPopupRequests(); |
559 for (const std::pair<int32, GURL>& blocked_popup : blocked_popups) { | 556 for (const std::pair<int32, GURL>& blocked_popup : blocked_popups) { |
560 std::string title(blocked_popup.second.spec()); | 557 std::string title(blocked_popup.second.spec()); |
561 // The popup may not have a valid URL. | 558 // The pop-up may not have a valid URL. |
562 if (title.empty()) | 559 if (title.empty()) |
563 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); | 560 title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); |
564 ListItem popup_item(ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 561 ListItem popup_item(ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
565 IDR_DEFAULT_FAVICON), | 562 IDR_DEFAULT_FAVICON), |
566 title, true, blocked_popup.first); | 563 title, true, blocked_popup.first); |
567 add_list_item(popup_item); | 564 add_list_item(popup_item); |
568 } | 565 } |
569 } | 566 } |
570 } | 567 } |
571 | 568 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
678 set_title(l10n_util::GetStringUTF8(title_id)); | 675 set_title(l10n_util::GetStringUTF8(title_id)); |
679 } | 676 } |
680 | 677 |
681 void ContentSettingMediaStreamBubbleModel::SetRadioGroup() { | 678 void ContentSettingMediaStreamBubbleModel::SetRadioGroup() { |
682 TabSpecificContentSettings* content_settings = | 679 TabSpecificContentSettings* content_settings = |
683 TabSpecificContentSettings::FromWebContents(web_contents()); | 680 TabSpecificContentSettings::FromWebContents(web_contents()); |
684 GURL url = content_settings->media_stream_access_origin(); | 681 GURL url = content_settings->media_stream_access_origin(); |
685 RadioGroup radio_group; | 682 RadioGroup radio_group; |
686 radio_group.url = url; | 683 radio_group.url = url; |
687 | 684 |
688 base::string16 display_host_utf16; | 685 base::string16 display_host_utf16 = FormatOriginForDisplay( |
689 net::AppendFormattedHost( | 686 url, profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)) |
msw
2015/05/29 00:18:51
Doesn't this need a bool argument and a semicolon?
palmer
2015/05/29 17:52:12
Done.
| |
690 url, | 687 std::string display_host(base::UTF16ToUTF8(display_host_utf16)); |
msw
2015/05/29 00:18:51
nit: fix indent.
palmer
2015/05/29 17:52:12
Done.
| |
691 profile()->GetPrefs()->GetString(prefs::kAcceptLanguages), | |
692 &display_host_utf16); | |
693 std::string display_host(base::UTF16ToUTF8(display_host_utf16)); | |
694 if (display_host.empty()) | 688 if (display_host.empty()) |
695 display_host = url.spec(); | 689 display_host = url.spec(); |
696 | 690 |
697 bool is_mic = (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) != 0; | 691 bool is_mic = (state_ & TabSpecificContentSettings::MICROPHONE_ACCESSED) != 0; |
698 bool is_cam = (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) != 0; | 692 bool is_cam = (state_ & TabSpecificContentSettings::CAMERA_ACCESSED) != 0; |
699 DCHECK(is_mic || is_cam); | 693 DCHECK(is_mic || is_cam); |
700 int radio_allow_label_id = 0; | 694 int radio_allow_label_id = 0; |
701 int radio_block_label_id = 0; | 695 int radio_block_label_id = 0; |
702 if (state_ & (TabSpecificContentSettings::MICROPHONE_BLOCKED | | 696 if (state_ & (TabSpecificContentSettings::MICROPHONE_BLOCKED | |
703 TabSpecificContentSettings::CAMERA_BLOCKED)) { | 697 TabSpecificContentSettings::CAMERA_BLOCKED)) { |
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1305 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1299 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
1306 DCHECK_EQ(web_contents_, | 1300 DCHECK_EQ(web_contents_, |
1307 content::Source<WebContents>(source).ptr()); | 1301 content::Source<WebContents>(source).ptr()); |
1308 web_contents_ = NULL; | 1302 web_contents_ = NULL; |
1309 } else { | 1303 } else { |
1310 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1304 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
1311 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1305 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
1312 profile_ = NULL; | 1306 profile_ = NULL; |
1313 } | 1307 } |
1314 } | 1308 } |
OLD | NEW |