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 "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 } // namespace | 29 } // namespace |
30 | 30 |
31 ContentSettingComboModel::ContentSettingComboModel(ContentSettingsType type) | 31 ContentSettingComboModel::ContentSettingComboModel(ContentSettingsType type) |
32 : content_type_(type) { | 32 : content_type_(type) { |
33 } | 33 } |
34 | 34 |
35 ContentSettingComboModel::~ContentSettingComboModel() { | 35 ContentSettingComboModel::~ContentSettingComboModel() { |
36 } | 36 } |
37 | 37 |
38 int ContentSettingComboModel::GetItemCount() { | 38 int ContentSettingComboModel::GetItemCount() { |
39 if (content_type_ == CONTENT_SETTINGS_TYPE_PLUGINS) | 39 if (content_type_ == CONTENT_SETTINGS_TYPE_PLUGINS && |
| 40 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableClickToPlay)) |
40 return arraysize(kAskSettings); | 41 return arraysize(kAskSettings); |
41 if (content_type_ == CONTENT_SETTINGS_TYPE_COOKIES) | 42 if (content_type_ == CONTENT_SETTINGS_TYPE_COOKIES) |
42 return arraysize(kSessionSettings); | 43 return arraysize(kSessionSettings); |
43 return arraysize(kNoSessionSettings); | 44 return arraysize(kNoSessionSettings); |
44 } | 45 } |
45 | 46 |
46 string16 ContentSettingComboModel::GetItemAt(int index) { | 47 string16 ContentSettingComboModel::GetItemAt(int index) { |
47 switch (SettingForIndex(index)) { | 48 switch (SettingForIndex(index)) { |
48 case CONTENT_SETTING_ALLOW: | 49 case CONTENT_SETTING_ALLOW: |
49 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON); | 50 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON); |
50 case CONTENT_SETTING_BLOCK: | 51 case CONTENT_SETTING_BLOCK: |
51 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON); | 52 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON); |
52 case CONTENT_SETTING_ASK: | 53 case CONTENT_SETTING_ASK: |
53 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON); | 54 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON); |
54 case CONTENT_SETTING_SESSION_ONLY: | 55 case CONTENT_SETTING_SESSION_ONLY: |
55 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON); | 56 return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON); |
56 default: | 57 default: |
57 NOTREACHED(); | 58 NOTREACHED(); |
58 } | 59 } |
59 return string16(); | 60 return string16(); |
60 } | 61 } |
61 | 62 |
62 ContentSetting ContentSettingComboModel::SettingForIndex(int index) { | 63 ContentSetting ContentSettingComboModel::SettingForIndex(int index) { |
63 if (content_type_ == CONTENT_SETTINGS_TYPE_PLUGINS) | 64 if (content_type_ == CONTENT_SETTINGS_TYPE_PLUGINS && |
| 65 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableClickToPlay)) |
64 return kAskSettings[index]; | 66 return kAskSettings[index]; |
65 if (content_type_ == CONTENT_SETTINGS_TYPE_COOKIES) | 67 if (content_type_ == CONTENT_SETTINGS_TYPE_COOKIES) |
66 return kSessionSettings[index]; | 68 return kSessionSettings[index]; |
67 return kNoSessionSettings[index]; | 69 return kNoSessionSettings[index]; |
68 } | 70 } |
69 | 71 |
70 int ContentSettingComboModel::IndexForSetting(ContentSetting setting) { | 72 int ContentSettingComboModel::IndexForSetting(ContentSetting setting) { |
71 for (int i = 0; i < GetItemCount(); ++i) | 73 for (int i = 0; i < GetItemCount(); ++i) |
72 if (SettingForIndex(i) == setting) | 74 if (SettingForIndex(i) == setting) |
73 return i; | 75 return i; |
74 NOTREACHED(); | 76 NOTREACHED(); |
75 return 0; | 77 return 0; |
76 } | 78 } |
77 | 79 |
OLD | NEW |