summaryrefslogtreecommitdiffstats
path: root/chrome/browser/views
diff options
context:
space:
mode:
authorerg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-02 22:06:27 +0000
committererg@chromium.org <erg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-02 22:06:27 +0000
commit77767745f94bb6e2ae267260de97af697fd2af82 (patch)
treefa18692d1ce6a175bb4ce5c7b9481c5c4f87750e /chrome/browser/views
parent9d166afe522da91217060a34787b16fa705f15e3 (diff)
downloadchromium_src-77767745f94bb6e2ae267260de97af697fd2af82.zip
chromium_src-77767745f94bb6e2ae267260de97af697fd2af82.tar.gz
chromium_src-77767745f94bb6e2ae267260de97af697fd2af82.tar.bz2
Moves ActionComboboxModel class to its own header so we can share common code between windows and linux.
BUG=None TEST=compiles, and still works as before. Review URL: http://codereview.chromium.org/661225 Patch from thiago.farina@gmail.com. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40446 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r--chrome/browser/views/options/exception_editor_view.cc45
-rw-r--r--chrome/browser/views/options/exception_editor_view.h21
2 files changed, 4 insertions, 62 deletions
diff --git a/chrome/browser/views/options/exception_editor_view.cc b/chrome/browser/views/options/exception_editor_view.cc
index 0b28545..97f84e0 100644
--- a/chrome/browser/views/options/exception_editor_view.cc
+++ b/chrome/browser/views/options/exception_editor_view.cc
@@ -21,15 +21,6 @@
namespace {
-// The settings shown in the combobox if show_ask_ is false.
-const ContentSetting kNoAskSettings[] = { CONTENT_SETTING_ALLOW,
- CONTENT_SETTING_BLOCK };
-
-// The settings shown in the combobox if show_ask_ is true.
-const ContentSetting kAskSettings[] = { CONTENT_SETTING_ALLOW,
- CONTENT_SETTING_ASK,
- CONTENT_SETTING_BLOCK };
-
// Returns true if the host name is valid.
bool ValidHost(const std::string& host) {
if (host.empty())
@@ -41,38 +32,6 @@ bool ValidHost(const std::string& host) {
} // namespace
-int ExceptionEditorView::ActionComboboxModel::GetItemCount() {
- return show_ask_ ? arraysize(kAskSettings) : arraysize(kNoAskSettings);
-}
-
-std::wstring ExceptionEditorView::ActionComboboxModel::GetItemAt(int index) {
- switch (setting_for_index(index)) {
- case CONTENT_SETTING_ALLOW:
- return l10n_util::GetString(IDS_EXCEPTIONS_ALLOW_BUTTON);
- case CONTENT_SETTING_BLOCK:
- return l10n_util::GetString(IDS_EXCEPTIONS_BLOCK_BUTTON);
- case CONTENT_SETTING_ASK:
- return l10n_util::GetString(IDS_EXCEPTIONS_ASK_BUTTON);
- default:
- NOTREACHED();
- }
- return std::wstring();
-}
-
-ContentSetting ExceptionEditorView::ActionComboboxModel::setting_for_index(
- int index) {
- return show_ask_ ? kAskSettings[index] : kNoAskSettings[index];
-}
-
-int ExceptionEditorView::ActionComboboxModel::index_for_setting(
- ContentSetting setting) {
- for (int i = 0; i < GetItemCount(); ++i)
- if (setting_for_index(i) == setting)
- return i;
- NOTREACHED();
- return 0;
-}
-
ExceptionEditorView::ExceptionEditorView(Delegate* delegate,
ContentExceptionsTableModel* model,
int index,
@@ -120,7 +79,7 @@ bool ExceptionEditorView::Cancel() {
bool ExceptionEditorView::Accept() {
std::string new_host = UTF16ToUTF8(host_tf_->text());
ContentSetting setting =
- cb_model_.setting_for_index(action_cb_->selected_item());
+ cb_model_.SettingForIndex(action_cb_->selected_item());
delegate_->AcceptExceptionEdit(new_host, setting, index_, is_new());
return true;
}
@@ -154,7 +113,7 @@ void ExceptionEditorView::Init() {
action_cb_ = new views::Combobox(&cb_model_);
if (!is_new())
- action_cb_->SetSelectedItem(cb_model_.index_for_setting(setting_));
+ action_cb_->SetSelectedItem(cb_model_.IndexForSetting(setting_));
GridLayout* layout = CreatePanelGridLayout(this);
SetLayoutManager(layout);
diff --git a/chrome/browser/views/options/exception_editor_view.h b/chrome/browser/views/options/exception_editor_view.h
index 5523e9c..d542e99 100644
--- a/chrome/browser/views/options/exception_editor_view.h
+++ b/chrome/browser/views/options/exception_editor_view.h
@@ -7,7 +7,7 @@
#include <string>
-#include "app/combobox_model.h"
+#include "chrome/browser/content_setting_combo_model.h"
#include "chrome/common/content_settings.h"
#include "chrome/common/content_settings_types.h"
#include "views/window/dialog_delegate.h"
@@ -73,23 +73,6 @@ class ExceptionEditorView : public views::View,
const views::Textfield::Keystroke& key);
private:
- // Model for the combobox.
- class ActionComboboxModel : public ComboboxModel {
- public:
- explicit ActionComboboxModel(bool show_ask) : show_ask_(show_ask) {}
-
- virtual int GetItemCount();
- virtual std::wstring GetItemAt(int index);
-
- ContentSetting setting_for_index(int index);
- int index_for_setting(ContentSetting);
-
- private:
- const bool show_ask_;
-
- DISALLOW_COPY_AND_ASSIGN(ActionComboboxModel);
- };
-
void Init();
views::Label* CreateLabel(int message_id);
@@ -103,7 +86,7 @@ class ExceptionEditorView : public views::View,
Delegate* delegate_;
ContentExceptionsTableModel* model_;
- ActionComboboxModel cb_model_;
+ ContentSettingComboModel cb_model_;
// Index of the item being edited. If -1, indices this is a new entry.
const int index_;