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_combo_model.h" | 5 #include "chrome/browser/content_setting_combo_model.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "grit/generated_resources.h" | 8 #include "grit/generated_resources.h" |
9 | 9 |
10 namespace { | 10 namespace { |
11 | 11 |
12 // The settings shown in the combobox if show_ask_ is false; | 12 // The settings shown in the combobox if show_ask_ is false; |
13 const ContentSetting kNoAskSettings[] = { CONTENT_SETTING_ALLOW, | 13 const ContentSetting kNoAskSettings[] = { CONTENT_SETTING_ALLOW, |
14 CONTENT_SETTING_BLOCK }; | 14 CONTENT_SETTING_BLOCK }; |
15 | 15 |
16 // The settings shown in the combobox if show_ask_ is true; | 16 // The settings shown in the combobox if show_ask_ is true; |
17 const ContentSetting kAskSettings[] = { CONTENT_SETTING_ALLOW, | 17 const ContentSetting kAskSettings[] = { CONTENT_SETTING_ALLOW, |
18 CONTENT_SETTING_ASK, | 18 CONTENT_SETTING_ASK, |
| 19 CONTENT_SETTING_SESSION_ONLY, |
19 CONTENT_SETTING_BLOCK }; | 20 CONTENT_SETTING_BLOCK }; |
20 | 21 |
21 } // namespace | 22 } // namespace |
22 | 23 |
23 ContentSettingComboModel::ContentSettingComboModel(bool show_ask) | 24 ContentSettingComboModel::ContentSettingComboModel(bool show_ask) |
24 : show_ask_(show_ask) { | 25 : show_ask_(show_ask) { |
25 } | 26 } |
26 | 27 |
27 ContentSettingComboModel::~ContentSettingComboModel() { | 28 ContentSettingComboModel::~ContentSettingComboModel() { |
28 } | 29 } |
29 | 30 |
30 int ContentSettingComboModel::GetItemCount() { | 31 int ContentSettingComboModel::GetItemCount() { |
31 return show_ask_ ? arraysize(kAskSettings) : arraysize(kNoAskSettings); | 32 return show_ask_ ? arraysize(kAskSettings) : arraysize(kNoAskSettings); |
32 } | 33 } |
33 | 34 |
34 std::wstring ContentSettingComboModel::GetItemAt(int index) { | 35 std::wstring ContentSettingComboModel::GetItemAt(int index) { |
35 switch (SettingForIndex(index)) { | 36 switch (SettingForIndex(index)) { |
36 case CONTENT_SETTING_ALLOW: | 37 case CONTENT_SETTING_ALLOW: |
37 return l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON); | 38 return l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON); |
38 case CONTENT_SETTING_BLOCK: | 39 case CONTENT_SETTING_BLOCK: |
39 return l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON); | 40 return l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON); |
40 case CONTENT_SETTING_ASK: | 41 case CONTENT_SETTING_ASK: |
41 return l10n_util::GetString(IDS_EXCEPTIONS_ASK_BUTTON); | 42 return l10n_util::GetString(IDS_EXCEPTIONS_ASK_BUTTON); |
| 43 case CONTENT_SETTING_SESSION_ONLY: |
| 44 return l10n_util::GetString(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON); |
42 default: | 45 default: |
43 NOTREACHED(); | 46 NOTREACHED(); |
44 } | 47 } |
45 return std::wstring(); | 48 return std::wstring(); |
46 } | 49 } |
47 | 50 |
48 ContentSetting ContentSettingComboModel::SettingForIndex(int index) { | 51 ContentSetting ContentSettingComboModel::SettingForIndex(int index) { |
49 return show_ask_ ? kAskSettings[index] : kNoAskSettings[index]; | 52 return show_ask_ ? kAskSettings[index] : kNoAskSettings[index]; |
50 } | 53 } |
51 | 54 |
52 int ContentSettingComboModel::IndexForSetting(ContentSetting setting) { | 55 int ContentSettingComboModel::IndexForSetting(ContentSetting setting) { |
53 for (int i = 0; i < GetItemCount(); ++i) | 56 for (int i = 0; i < GetItemCount(); ++i) |
54 if (SettingForIndex(i) == setting) | 57 if (SettingForIndex(i) == setting) |
55 return i; | 58 return i; |
56 NOTREACHED(); | 59 NOTREACHED(); |
57 return 0; | 60 return 0; |
58 } | 61 } |
59 | 62 |
OLD | NEW |