| 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 "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/blocked_popup_container.h" | 10 #include "chrome/browser/blocked_popup_container.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 COMPILE_ASSERT(arraysize(kBlockedTitleIDs) == CONTENT_SETTINGS_NUM_TYPES, | 81 COMPILE_ASSERT(arraysize(kBlockedTitleIDs) == CONTENT_SETTINGS_NUM_TYPES, |
| 82 Need_a_setting_for_every_content_settings_type); | 82 Need_a_setting_for_every_content_settings_type); |
| 83 COMPILE_ASSERT(arraysize(kResourceSpecificBlockedTitleIDs) == | 83 COMPILE_ASSERT(arraysize(kResourceSpecificBlockedTitleIDs) == |
| 84 CONTENT_SETTINGS_NUM_TYPES, | 84 CONTENT_SETTINGS_NUM_TYPES, |
| 85 Need_a_setting_for_every_content_settings_type); | 85 Need_a_setting_for_every_content_settings_type); |
| 86 const int *title_ids = kBlockedTitleIDs; | 86 const int *title_ids = kBlockedTitleIDs; |
| 87 if (tab_contents() && | 87 if (tab_contents() && |
| 88 tab_contents()->GetTabSpecificContentSettings()->IsContentAccessed( | 88 tab_contents()->GetTabSpecificContentSettings()->IsContentAccessed( |
| 89 content_type()) && | 89 content_type()) && |
| 90 !tab_contents()->GetTabSpecificContentSettings()->IsContentBlocked( | 90 !tab_contents()->GetTabSpecificContentSettings()->IsContentBlocked( |
| 91 content_type()) && | 91 content_type())) { |
| 92 !CommandLine::ForCurrentProcess()->HasSwitch( | |
| 93 switches::kEnableCookiePrompt)) { | |
| 94 title_ids = kAccessedTitleIDs; | 92 title_ids = kAccessedTitleIDs; |
| 95 } else if (!bubble_content().resource_identifiers.empty()) { | 93 } else if (!bubble_content().resource_identifiers.empty()) { |
| 96 title_ids = kResourceSpecificBlockedTitleIDs; | 94 title_ids = kResourceSpecificBlockedTitleIDs; |
| 97 } | 95 } |
| 98 if (title_ids[content_type()]) | 96 if (title_ids[content_type()]) |
| 99 set_title(l10n_util::GetStringUTF8(title_ids[content_type()])); | 97 set_title(l10n_util::GetStringUTF8(title_ids[content_type()])); |
| 100 } | 98 } |
| 101 | 99 |
| 102 void SetManageLink() { | 100 void SetManageLink() { |
| 103 static const int kLinkIDs[] = { | 101 static const int kLinkIDs[] = { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 120 } | 118 } |
| 121 }; | 119 }; |
| 122 | 120 |
| 123 class ContentSettingTitleLinkAndInfoModel | 121 class ContentSettingTitleLinkAndInfoModel |
| 124 : public ContentSettingTitleAndLinkModel { | 122 : public ContentSettingTitleAndLinkModel { |
| 125 public: | 123 public: |
| 126 ContentSettingTitleLinkAndInfoModel(TabContents* tab_contents, | 124 ContentSettingTitleLinkAndInfoModel(TabContents* tab_contents, |
| 127 Profile* profile, | 125 Profile* profile, |
| 128 ContentSettingsType content_type) | 126 ContentSettingsType content_type) |
| 129 : ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) { | 127 : ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) { |
| 130 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 128 SetInfoLink(); |
| 131 switches::kEnableCookiePrompt)) | |
| 132 SetInfoLink(); | |
| 133 } | 129 } |
| 134 | 130 |
| 135 private: | 131 private: |
| 136 void SetInfoLink() { | 132 void SetInfoLink() { |
| 137 static const int kInfoIDs[] = { | 133 static const int kInfoIDs[] = { |
| 138 IDS_BLOCKED_COOKIES_INFO, | 134 IDS_BLOCKED_COOKIES_INFO, |
| 139 0, // Images do not have an info link. | 135 0, // Images do not have an info link. |
| 140 0, // Javascript doesn't have an info link. | 136 0, // Javascript doesn't have an info link. |
| 141 0, // Plugins do not have an info link. | 137 0, // Plugins do not have an info link. |
| 142 0, // Popups do not have an info link. | 138 0, // Popups do not have an info link. |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 bubble_content_.resource_identifiers.insert(resource_identifier); | 467 bubble_content_.resource_identifiers.insert(resource_identifier); |
| 472 } | 468 } |
| 473 | 469 |
| 474 void ContentSettingBubbleModel::Observe(NotificationType type, | 470 void ContentSettingBubbleModel::Observe(NotificationType type, |
| 475 const NotificationSource& source, | 471 const NotificationSource& source, |
| 476 const NotificationDetails& details) { | 472 const NotificationDetails& details) { |
| 477 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); | 473 DCHECK(type == NotificationType::TAB_CONTENTS_DESTROYED); |
| 478 DCHECK(source == Source<TabContents>(tab_contents_)); | 474 DCHECK(source == Source<TabContents>(tab_contents_)); |
| 479 tab_contents_ = NULL; | 475 tab_contents_ = NULL; |
| 480 } | 476 } |
| OLD | NEW |