| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/content_setting_bubble_model.h" | 5 #include "chrome/browser/content_setting_bubble_model.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "chrome/browser/blocked_popup_container.h" | 8 #include "chrome/browser/blocked_popup_container.h" |
| 9 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" | 9 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
| 10 #include "chrome/browser/host_content_settings_map.h" | 10 #include "chrome/browser/host_content_settings_map.h" |
| 11 #include "chrome/browser/pref_service.h" | 11 #include "chrome/browser/pref_service.h" |
| 12 #include "chrome/browser/profile.h" | 12 #include "chrome/browser/profile.h" |
| 13 #include "chrome/browser/tab_contents/tab_contents.h" | 13 #include "chrome/browser/tab_contents/tab_contents.h" |
| 14 #include "chrome/browser/tab_contents/tab_contents_delegate.h" | 14 #include "chrome/browser/tab_contents/tab_contents_delegate.h" |
| 15 #include "chrome/common/notification_service.h" | 15 #include "chrome/common/notification_service.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
| 18 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
| 19 | 19 |
| 20 class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel { | 20 class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel { |
| 21 public: | 21 public: |
| 22 ContentSettingTitleAndLinkModel(TabContents* tab_contents, Profile* profile, | 22 ContentSettingTitleAndLinkModel(TabContents* tab_contents, Profile* profile, |
| 23 ContentSettingsType content_type) | 23 ContentSettingsType content_type) |
| 24 : ContentSettingBubbleModel(tab_contents, profile, content_type) { | 24 : ContentSettingBubbleModel(tab_contents, profile, content_type) { |
| 25 // Notifications do not have a bubble. |
| 26 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
| 25 SetTitle(); | 27 SetTitle(); |
| 26 SetManageLink(); | 28 SetManageLink(); |
| 27 } | 29 } |
| 28 | 30 |
| 29 private: | 31 private: |
| 30 void SetTitle() { | 32 void SetTitle() { |
| 31 static const int kTitleIDs[] = { | 33 static const int kTitleIDs[] = { |
| 32 IDS_BLOCKED_COOKIES_TITLE, | 34 IDS_BLOCKED_COOKIES_TITLE, |
| 33 IDS_BLOCKED_IMAGES_TITLE, | 35 IDS_BLOCKED_IMAGES_TITLE, |
| 34 IDS_BLOCKED_JAVASCRIPT_TITLE, | 36 IDS_BLOCKED_JAVASCRIPT_TITLE, |
| 35 IDS_BLOCKED_PLUGINS_TITLE, | 37 IDS_BLOCKED_PLUGINS_TITLE, |
| 36 IDS_BLOCKED_POPUPS_TITLE, | 38 IDS_BLOCKED_POPUPS_TITLE, |
| 37 0, // Geolocation does not have an overall title. | 39 0, // Geolocation does not have an overall title. |
| 40 0, // Notifications do not have a bubble. |
| 38 }; | 41 }; |
| 39 COMPILE_ASSERT(arraysize(kTitleIDs) == CONTENT_SETTINGS_NUM_TYPES, | 42 COMPILE_ASSERT(arraysize(kTitleIDs) == CONTENT_SETTINGS_NUM_TYPES, |
| 40 Need_a_setting_for_every_content_settings_type); | 43 Need_a_setting_for_every_content_settings_type); |
| 41 if (kTitleIDs[content_type()]) | 44 if (kTitleIDs[content_type()]) |
| 42 set_title(l10n_util::GetStringUTF8(kTitleIDs[content_type()])); | 45 set_title(l10n_util::GetStringUTF8(kTitleIDs[content_type()])); |
| 43 } | 46 } |
| 44 | 47 |
| 45 void SetManageLink() { | 48 void SetManageLink() { |
| 46 static const int kLinkIDs[] = { | 49 static const int kLinkIDs[] = { |
| 47 IDS_BLOCKED_COOKIES_LINK, | 50 IDS_BLOCKED_COOKIES_LINK, |
| 48 IDS_BLOCKED_IMAGES_LINK, | 51 IDS_BLOCKED_IMAGES_LINK, |
| 49 IDS_BLOCKED_JAVASCRIPT_LINK, | 52 IDS_BLOCKED_JAVASCRIPT_LINK, |
| 50 IDS_BLOCKED_PLUGINS_LINK, | 53 IDS_BLOCKED_PLUGINS_LINK, |
| 51 IDS_BLOCKED_POPUPS_LINK, | 54 IDS_BLOCKED_POPUPS_LINK, |
| 52 IDS_GEOLOCATION_BUBBLE_MANAGE_LINK, | 55 IDS_GEOLOCATION_BUBBLE_MANAGE_LINK, |
| 56 0, // Notifications do not have a bubble. |
| 53 }; | 57 }; |
| 54 COMPILE_ASSERT(arraysize(kLinkIDs) == CONTENT_SETTINGS_NUM_TYPES, | 58 COMPILE_ASSERT(arraysize(kLinkIDs) == CONTENT_SETTINGS_NUM_TYPES, |
| 55 Need_a_setting_for_every_content_settings_type); | 59 Need_a_setting_for_every_content_settings_type); |
| 56 set_manage_link(l10n_util::GetStringUTF8(kLinkIDs[content_type()])); | 60 set_manage_link(l10n_util::GetStringUTF8(kLinkIDs[content_type()])); |
| 57 } | 61 } |
| 58 | 62 |
| 59 virtual void OnManageLinkClicked() { | 63 virtual void OnManageLinkClicked() { |
| 60 if (tab_contents()) | 64 if (tab_contents()) |
| 61 tab_contents()->delegate()->ShowContentSettingsWindow(content_type()); | 65 tab_contents()->delegate()->ShowContentSettingsWindow(content_type()); |
| 62 } | 66 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 82 RadioGroup radio_group; | 86 RadioGroup radio_group; |
| 83 radio_group.url = url; | 87 radio_group.url = url; |
| 84 | 88 |
| 85 static const int kAllowIDs[] = { | 89 static const int kAllowIDs[] = { |
| 86 0, // We don't manage cookies here. | 90 0, // We don't manage cookies here. |
| 87 IDS_BLOCKED_IMAGES_UNBLOCK, | 91 IDS_BLOCKED_IMAGES_UNBLOCK, |
| 88 IDS_BLOCKED_JAVASCRIPT_UNBLOCK, | 92 IDS_BLOCKED_JAVASCRIPT_UNBLOCK, |
| 89 IDS_BLOCKED_PLUGINS_UNBLOCK, | 93 IDS_BLOCKED_PLUGINS_UNBLOCK, |
| 90 IDS_BLOCKED_POPUPS_UNBLOCK, | 94 IDS_BLOCKED_POPUPS_UNBLOCK, |
| 91 0, // We don't manage geolocation here. | 95 0, // We don't manage geolocation here. |
| 96 0, // Notifications do not have a bubble. |
| 92 }; | 97 }; |
| 93 COMPILE_ASSERT(arraysize(kAllowIDs) == CONTENT_SETTINGS_NUM_TYPES, | 98 COMPILE_ASSERT(arraysize(kAllowIDs) == CONTENT_SETTINGS_NUM_TYPES, |
| 94 Need_a_setting_for_every_content_settings_type); | 99 Need_a_setting_for_every_content_settings_type); |
| 95 std::string radio_allow_label; | 100 std::string radio_allow_label; |
| 96 radio_allow_label = l10n_util::GetStringFUTF8( | 101 radio_allow_label = l10n_util::GetStringFUTF8( |
| 97 kAllowIDs[content_type()], UTF8ToUTF16(display_host)); | 102 kAllowIDs[content_type()], UTF8ToUTF16(display_host)); |
| 98 | 103 |
| 99 static const int kBlockIDs[] = { | 104 static const int kBlockIDs[] = { |
| 100 0, // We don't manage cookies here. | 105 0, // We don't manage cookies here. |
| 101 IDS_BLOCKED_IMAGES_NO_ACTION, | 106 IDS_BLOCKED_IMAGES_NO_ACTION, |
| 102 IDS_BLOCKED_JAVASCRIPT_NO_ACTION, | 107 IDS_BLOCKED_JAVASCRIPT_NO_ACTION, |
| 103 IDS_BLOCKED_PLUGINS_NO_ACTION, | 108 IDS_BLOCKED_PLUGINS_NO_ACTION, |
| 104 IDS_BLOCKED_POPUPS_NO_ACTION, | 109 IDS_BLOCKED_POPUPS_NO_ACTION, |
| 105 0, // We don't manage geolocation here. | 110 0, // We don't manage geolocation here. |
| 111 0, // Notifications do not have a bubble. |
| 106 }; | 112 }; |
| 107 COMPILE_ASSERT(arraysize(kBlockIDs) == CONTENT_SETTINGS_NUM_TYPES, | 113 COMPILE_ASSERT(arraysize(kBlockIDs) == CONTENT_SETTINGS_NUM_TYPES, |
| 108 Need_a_setting_for_every_content_settings_type); | 114 Need_a_setting_for_every_content_settings_type); |
| 109 std::string radio_block_label; | 115 std::string radio_block_label; |
| 110 radio_block_label = l10n_util::GetStringFUTF8( | 116 radio_block_label = l10n_util::GetStringFUTF8( |
| 111 kBlockIDs[content_type()], UTF8ToUTF16(display_host)); | 117 kBlockIDs[content_type()], UTF8ToUTF16(display_host)); |
| 112 | 118 |
| 113 radio_group.radio_items.push_back(radio_allow_label); | 119 radio_group.radio_items.push_back(radio_allow_label); |
| 114 radio_group.radio_items.push_back(radio_block_label); | 120 radio_group.radio_items.push_back(radio_block_label); |
| 115 radio_group.default_item = | 121 radio_group.default_item = |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 ContentSettingBubbleModel::~ContentSettingBubbleModel() { | 279 ContentSettingBubbleModel::~ContentSettingBubbleModel() { |
| 274 } | 280 } |
| 275 | 281 |
| 276 void ContentSettingBubbleModel::Observe(NotificationType type, | 282 void ContentSettingBubbleModel::Observe(NotificationType type, |
| 277 const NotificationSource& source, | 283 const NotificationSource& source, |
| 278 const NotificationDetails& details) { | 284 const NotificationDetails& details) { |
| 279 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); | 285 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); |
| 280 DCHECK(source == Source<TabContents>(tab_contents_)); | 286 DCHECK(source == Source<TabContents>(tab_contents_)); |
| 281 tab_contents_ = NULL; | 287 tab_contents_ = NULL; |
| 282 } | 288 } |
| OLD | NEW |