diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-19 01:04:54 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-19 01:04:54 +0000 |
commit | 9b82ad7a837506f27669a1465c215b80bcec2d68 (patch) | |
tree | dd32f492f2ca3f395804fd7c6015c62be0dc2596 /chrome/browser/views | |
parent | 4eb2ac96bb677b63173fab432bc66903a53f79b0 (diff) | |
download | chromium_src-9b82ad7a837506f27669a1465c215b80bcec2d68.zip chromium_src-9b82ad7a837506f27669a1465c215b80bcec2d68.tar.gz chromium_src-9b82ad7a837506f27669a1465c215b80bcec2d68.tar.bz2 |
gtk: Split DefaultEncodingComboboxModel into its own file so it can be shared with the views UI side.
BUG=None
TEST=manually, everything should works as before.
Review URL: http://codereview.chromium.org/1993004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47609 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/views')
-rw-r--r-- | chrome/browser/views/options/fonts_page_view.cc | 68 |
1 files changed, 3 insertions, 65 deletions
diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc index 2854bbd..4fd923e 100644 --- a/chrome/browser/views/options/fonts_page_view.cc +++ b/chrome/browser/views/options/fonts_page_view.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,14 +11,12 @@ #include <vector> -#include "app/combobox_model.h" #include "app/l10n_util.h" #include "app/l10n_util_collator.h" #include "app/resource_bundle.h" #include "base/file_util.h" #include "base/string_util.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/character_encoding.h" +#include "chrome/browser/default_encoding_combo_model.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/shell_dialogs.h" @@ -35,66 +33,6 @@ #include "views/standard_layout.h" #include "views/widget/widget.h" -namespace { - -static std::vector<CharacterEncoding::EncodingInfo> sorted_encoding_list; - -} // namespace - -class DefaultEncodingComboboxModel : public ComboboxModel { - public: - DefaultEncodingComboboxModel() { - canonical_encoding_names_length_ = - CharacterEncoding::GetSupportCanonicalEncodingCount(); - // Initialize the vector of all sorted encodings according to current - // UI locale. - if (!sorted_encoding_list.size()) { - std::string locale = g_browser_process->GetApplicationLocale(); - for (int i = 0; i < canonical_encoding_names_length_; i++) { - sorted_encoding_list.push_back(CharacterEncoding::EncodingInfo( - CharacterEncoding::GetEncodingCommandIdByIndex(i))); - } - l10n_util::SortVectorWithStringKey(locale, &sorted_encoding_list, true); - } - } - - virtual ~DefaultEncodingComboboxModel() {} - - // Overridden from ComboboxModel. - virtual int GetItemCount() { - return canonical_encoding_names_length_; - } - - virtual std::wstring GetItemAt(int index) { - DCHECK(index >= 0 && canonical_encoding_names_length_ > index); - return sorted_encoding_list[index].encoding_display_name; - } - - std::string GetEncodingCharsetByIndex(int index) { - DCHECK(index >= 0 && canonical_encoding_names_length_ > index); - int encoding_id = sorted_encoding_list[index].encoding_id; - return CharacterEncoding::GetCanonicalEncodingNameByCommandId(encoding_id); - } - - int GetSelectedEncodingIndex(Profile* profile) { - StringPrefMember current_encoding_string; - current_encoding_string.Init(prefs::kDefaultCharset, - profile->GetPrefs(), - NULL); - const std::wstring current_encoding = current_encoding_string.GetValue(); - for (int i = 0; i < canonical_encoding_names_length_; i++) { - if (GetEncodingCharsetByIndex(i) == WideToASCII(current_encoding)) - return i; - } - - return 0; - } - - private: - int canonical_encoding_names_length_; - DISALLOW_COPY_AND_ASSIGN(DefaultEncodingComboboxModel); -}; - //////////////////////////////////////////////////////////////////////////////// // FontDisplayView @@ -127,7 +65,7 @@ class FontDisplayView : public views::View { static const int kFontDisplayMaxHeightChars = 1; static const int kFontDisplayLabelPadding = 5; - DISALLOW_EVIL_CONSTRUCTORS(FontDisplayView); + DISALLOW_COPY_AND_ASSIGN(FontDisplayView); }; FontDisplayView::FontDisplayView() |