Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: chrome/browser/content_setting_combo_model.cc

Issue 2963006: Remove the cookie prompt from the settings UI and migrate prefs from ask to block. (Closed)
Patch Set: updates Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_session_ is false;
13 const ContentSetting kNoAskSettings[] = { CONTENT_SETTING_ALLOW, 13 const ContentSetting kNoSessionSettings[] = { 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_session_ is true;
17 const ContentSetting kAskSettings[] = { CONTENT_SETTING_ALLOW, 17 const ContentSetting kSessionSettings[] = { CONTENT_SETTING_ALLOW,
18 CONTENT_SETTING_ASK, 18 CONTENT_SETTING_SESSION_ONLY,
19 CONTENT_SETTING_SESSION_ONLY, 19 CONTENT_SETTING_BLOCK };
20 CONTENT_SETTING_BLOCK };
21 20
22 } // namespace 21 } // namespace
23 22
24 ContentSettingComboModel::ContentSettingComboModel(bool show_ask) 23 ContentSettingComboModel::ContentSettingComboModel(bool show_session)
25 : show_ask_(show_ask) { 24 : show_session_(show_session) {
26 } 25 }
27 26
28 ContentSettingComboModel::~ContentSettingComboModel() { 27 ContentSettingComboModel::~ContentSettingComboModel() {
29 } 28 }
30 29
31 int ContentSettingComboModel::GetItemCount() { 30 int ContentSettingComboModel::GetItemCount() {
32 return show_ask_ ? arraysize(kAskSettings) : arraysize(kNoAskSettings); 31 return show_session_ ?
32 arraysize(kSessionSettings) : arraysize(kNoSessionSettings);
33 } 33 }
34 34
35 std::wstring ContentSettingComboModel::GetItemAt(int index) { 35 std::wstring ContentSettingComboModel::GetItemAt(int index) {
36 switch (SettingForIndex(index)) { 36 switch (SettingForIndex(index)) {
37 case CONTENT_SETTING_ALLOW: 37 case CONTENT_SETTING_ALLOW:
38 return l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON); 38 return l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON);
39 case CONTENT_SETTING_BLOCK: 39 case CONTENT_SETTING_BLOCK:
40 return l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON); 40 return l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON);
41 case CONTENT_SETTING_ASK:
42 return l10n_util::GetString(IDS_EXCEPTIONS_ASK_BUTTON);
43 case CONTENT_SETTING_SESSION_ONLY: 41 case CONTENT_SETTING_SESSION_ONLY:
44 return l10n_util::GetString(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON); 42 return l10n_util::GetString(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON);
45 default: 43 default:
46 NOTREACHED(); 44 NOTREACHED();
47 } 45 }
48 return std::wstring(); 46 return std::wstring();
49 } 47 }
50 48
51 ContentSetting ContentSettingComboModel::SettingForIndex(int index) { 49 ContentSetting ContentSettingComboModel::SettingForIndex(int index) {
52 return show_ask_ ? kAskSettings[index] : kNoAskSettings[index]; 50 return show_session_ ? kSessionSettings[index] : kNoSessionSettings[index];
53 } 51 }
54 52
55 int ContentSettingComboModel::IndexForSetting(ContentSetting setting) { 53 int ContentSettingComboModel::IndexForSetting(ContentSetting setting) {
56 for (int i = 0; i < GetItemCount(); ++i) 54 for (int i = 0; i < GetItemCount(); ++i)
57 if (SettingForIndex(i) == setting) 55 if (SettingForIndex(i) == setting)
58 return i; 56 return i;
59 NOTREACHED(); 57 NOTREACHED();
60 return 0; 58 return 0;
61 } 59 }
62 60
OLDNEW
« no previous file with comments | « chrome/browser/content_setting_combo_model.h ('k') | chrome/browser/dom_ui/content_settings_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698