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" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 Delegate* delegate, | 88 Delegate* delegate, |
89 WebContents* web_contents, | 89 WebContents* web_contents, |
90 Profile* profile, | 90 Profile* profile, |
91 ContentSettingsType content_type) | 91 ContentSettingsType content_type) |
92 : ContentSettingBubbleModel(web_contents, profile, content_type), | 92 : ContentSettingBubbleModel(web_contents, profile, content_type), |
93 delegate_(delegate) { | 93 delegate_(delegate) { |
94 // Notifications do not have a bubble. | 94 // Notifications do not have a bubble. |
95 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); | 95 DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); |
96 SetTitle(); | 96 SetTitle(); |
97 SetManageLink(); | 97 SetManageLink(); |
| 98 SetLearnMoreLink(); |
98 } | 99 } |
99 | 100 |
100 void ContentSettingTitleAndLinkModel::SetTitle() { | 101 void ContentSettingTitleAndLinkModel::SetTitle() { |
101 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = { | 102 static const ContentSettingsTypeIdEntry kBlockedTitleIDs[] = { |
102 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, | 103 {CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_TITLE}, |
103 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, | 104 {CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_TITLE}, |
104 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, | 105 {CONTENT_SETTINGS_TYPE_JAVASCRIPT, IDS_BLOCKED_JAVASCRIPT_TITLE}, |
105 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE}, | 106 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_BLOCKED_PLUGINS_MESSAGE}, |
106 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, | 107 {CONTENT_SETTINGS_TYPE_POPUPS, IDS_BLOCKED_POPUPS_TITLE}, |
107 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, | 108 {CONTENT_SETTINGS_TYPE_MIXEDSCRIPT, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 }; | 150 }; |
150 set_manage_link(l10n_util::GetStringUTF8( | 151 set_manage_link(l10n_util::GetStringUTF8( |
151 GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type()))); | 152 GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type()))); |
152 } | 153 } |
153 | 154 |
154 void ContentSettingTitleAndLinkModel::OnManageLinkClicked() { | 155 void ContentSettingTitleAndLinkModel::OnManageLinkClicked() { |
155 if (delegate_) | 156 if (delegate_) |
156 delegate_->ShowContentSettingsPage(content_type()); | 157 delegate_->ShowContentSettingsPage(content_type()); |
157 } | 158 } |
158 | 159 |
| 160 void ContentSettingTitleAndLinkModel::SetLearnMoreLink() { |
| 161 static const ContentSettingsTypeIdEntry kLearnMoreIDs[] = { |
| 162 {CONTENT_SETTINGS_TYPE_PLUGINS, IDS_LEARN_MORE}, |
| 163 }; |
| 164 int learn_more_id = |
| 165 GetIdForContentType(kLearnMoreIDs, arraysize(kLearnMoreIDs), |
| 166 content_type()); |
| 167 if (learn_more_id) |
| 168 set_learn_more_link(l10n_util::GetStringUTF8(learn_more_id)); |
| 169 } |
| 170 |
| 171 void ContentSettingTitleAndLinkModel::OnLearnMoreLinkClicked() { |
| 172 if (delegate_) |
| 173 delegate_->ShowLearnMorePage(content_type()); |
| 174 } |
| 175 |
159 class ContentSettingTitleLinkAndCustomModel | 176 class ContentSettingTitleLinkAndCustomModel |
160 : public ContentSettingTitleAndLinkModel { | 177 : public ContentSettingTitleAndLinkModel { |
161 public: | 178 public: |
162 ContentSettingTitleLinkAndCustomModel(Delegate* delegate, | 179 ContentSettingTitleLinkAndCustomModel(Delegate* delegate, |
163 WebContents* web_contents, | 180 WebContents* web_contents, |
164 Profile* profile, | 181 Profile* profile, |
165 ContentSettingsType content_type); | 182 ContentSettingsType content_type); |
166 virtual ~ContentSettingTitleLinkAndCustomModel() {} | 183 virtual ~ContentSettingTitleLinkAndCustomModel() {} |
167 | 184 |
168 private: | 185 private: |
(...skipping 1137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { | 1323 if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) { |
1307 DCHECK_EQ(web_contents_, | 1324 DCHECK_EQ(web_contents_, |
1308 content::Source<WebContents>(source).ptr()); | 1325 content::Source<WebContents>(source).ptr()); |
1309 web_contents_ = NULL; | 1326 web_contents_ = NULL; |
1310 } else { | 1327 } else { |
1311 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); | 1328 DCHECK_EQ(chrome::NOTIFICATION_PROFILE_DESTROYED, type); |
1312 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 1329 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
1313 profile_ = NULL; | 1330 profile_ = NULL; |
1314 } | 1331 } |
1315 } | 1332 } |
OLD | NEW |