| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include <windows.h> | 4 #include <windows.h> |
| 5 #include <shlobj.h> | 5 #include <shlobj.h> |
| 6 #include <vsstyle.h> | 6 #include <vsstyle.h> |
| 7 #include <vssym32.h> | 7 #include <vssym32.h> |
| 8 | 8 |
| 9 #include "chrome/browser/views/options/languages_page_view.h" | 9 #include "chrome/browser/views/options/languages_page_view.h" |
| 10 | 10 |
| 11 #include "app/gfx/canvas.h" | 11 #include "app/gfx/canvas.h" |
| 12 #include "app/gfx/font.h" | 12 #include "app/gfx/font.h" |
| 13 #include "app/l10n_util.h" | 13 #include "app/l10n_util.h" |
| 14 #include "app/resource_bundle.h" | 14 #include "app/resource_bundle.h" |
| 15 #include "app/table_model.h" |
| 16 #include "app/table_model_observer.h" |
| 15 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 16 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 17 #include "base/string_util.h" | 19 #include "base/string_util.h" |
| 18 #include "base/gfx/native_theme.h" | 20 #include "base/gfx/native_theme.h" |
| 19 #include "base/string_util.h" | 21 #include "base/string_util.h" |
| 20 #include "chrome/browser/browser_process.h" | 22 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/shell_dialogs.h" | 23 #include "chrome/browser/shell_dialogs.h" |
| 22 #include "chrome/browser/spellchecker.h" | 24 #include "chrome/browser/spellchecker.h" |
| 23 #include "chrome/browser/views/options/language_combobox_model.h" | 25 #include "chrome/browser/views/options/language_combobox_model.h" |
| 24 #include "chrome/browser/views/restart_message_box.h" | 26 #include "chrome/browser/views/restart_message_box.h" |
| 25 #include "chrome/common/chrome_switches.h" | 27 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 27 #include "chrome/common/pref_service.h" | 29 #include "chrome/common/pref_service.h" |
| 28 #include "grit/chromium_strings.h" | 30 #include "grit/chromium_strings.h" |
| 29 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
| 30 #include "grit/theme_resources.h" | 32 #include "grit/theme_resources.h" |
| 31 #include "third_party/skia/include/core/SkBitmap.h" | 33 #include "third_party/skia/include/core/SkBitmap.h" |
| 32 #include "unicode/uloc.h" | 34 #include "unicode/uloc.h" |
| 33 #include "views/controls/button/radio_button.h" | 35 #include "views/controls/button/radio_button.h" |
| 34 #include "views/controls/tabbed_pane.h" | 36 #include "views/controls/tabbed_pane.h" |
| 35 #include "views/controls/table/table_model.h" | |
| 36 #include "views/controls/table/table_model_observer.h" | |
| 37 #include "views/controls/table/table_view.h" | 37 #include "views/controls/table/table_view.h" |
| 38 #include "views/grid_layout.h" | 38 #include "views/grid_layout.h" |
| 39 #include "views/standard_layout.h" | 39 #include "views/standard_layout.h" |
| 40 #include "views/widget/widget.h" | 40 #include "views/widget/widget.h" |
| 41 #include "views/window/window.h" | 41 #include "views/window/window.h" |
| 42 | 42 |
| 43 static const char* const accept_language_list[] = { | 43 static const char* const accept_language_list[] = { |
| 44 "af", // Afrikaans | 44 "af", // Afrikaans |
| 45 "am", // Amharic | 45 "am", // Amharic |
| 46 "ar", // Arabic | 46 "ar", // Arabic |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 } | 307 } |
| 308 accept_language_combobox_model_.reset(new LanguageComboboxModel( | 308 accept_language_combobox_model_.reset(new LanguageComboboxModel( |
| 309 profile_, locale_codes)); | 309 profile_, locale_codes)); |
| 310 accept_language_combobox_ = new views::Combobox( | 310 accept_language_combobox_ = new views::Combobox( |
| 311 accept_language_combobox_model_.get()); | 311 accept_language_combobox_model_.get()); |
| 312 accept_language_combobox_->SetSelectedItem(0); | 312 accept_language_combobox_->SetSelectedItem(0); |
| 313 accept_language_combobox_->set_listener(this); | 313 accept_language_combobox_->set_listener(this); |
| 314 AddChildView(accept_language_combobox_); | 314 AddChildView(accept_language_combobox_); |
| 315 } | 315 } |
| 316 | 316 |
| 317 class LanguageOrderTableModel : public views::TableModel { | 317 class LanguageOrderTableModel : public TableModel { |
| 318 public: | 318 public: |
| 319 LanguageOrderTableModel(); | 319 LanguageOrderTableModel(); |
| 320 | 320 |
| 321 // Set Language List. | 321 // Set Language List. |
| 322 void SetAcceptLanguagesString(const std::string& language_list); | 322 void SetAcceptLanguagesString(const std::string& language_list); |
| 323 | 323 |
| 324 // Add at the end. | 324 // Add at the end. |
| 325 void Add(const std::string& language); | 325 void Add(const std::string& language); |
| 326 | 326 |
| 327 // Removes the entry at the specified index. | 327 // Removes the entry at the specified index. |
| 328 void Remove(int index); | 328 void Remove(int index); |
| 329 | 329 |
| 330 // Returns index corresponding to a given language. Returns -1 if the | 330 // Returns index corresponding to a given language. Returns -1 if the |
| 331 // language is not found. | 331 // language is not found. |
| 332 int GetIndex(const std::string& language); | 332 int GetIndex(const std::string& language); |
| 333 | 333 |
| 334 // Move down the entry at the specified index. | 334 // Move down the entry at the specified index. |
| 335 void MoveDown(int index); | 335 void MoveDown(int index); |
| 336 | 336 |
| 337 // Move up the entry at the specified index. | 337 // Move up the entry at the specified index. |
| 338 void MoveUp(int index); | 338 void MoveUp(int index); |
| 339 | 339 |
| 340 // Returns the set of languagess this model contains. | 340 // Returns the set of languagess this model contains. |
| 341 std::string GetLanguageList() { return VectorToList(languages_); } | 341 std::string GetLanguageList() { return VectorToList(languages_); } |
| 342 | 342 |
| 343 // views::TableModel overrides: | 343 // TableModel overrides: |
| 344 virtual int RowCount(); | 344 virtual int RowCount(); |
| 345 virtual std::wstring GetText(int row, int column_id); | 345 virtual std::wstring GetText(int row, int column_id); |
| 346 virtual void SetObserver(views::TableModelObserver* observer); | 346 virtual void SetObserver(TableModelObserver* observer); |
| 347 | 347 |
| 348 private: | 348 private: |
| 349 // This method converts a comma separated list to a vector of strings. | 349 // This method converts a comma separated list to a vector of strings. |
| 350 void ListToVector(const std::string& list, | 350 void ListToVector(const std::string& list, |
| 351 std::vector<std::string>* vector); | 351 std::vector<std::string>* vector); |
| 352 | 352 |
| 353 // This method returns a comma separated string given a string vector. | 353 // This method returns a comma separated string given a string vector. |
| 354 std::string VectorToList(const std::vector<std::string>& vector); | 354 std::string VectorToList(const std::vector<std::string>& vector); |
| 355 | 355 |
| 356 // Set of entries we're showing. | 356 // Set of entries we're showing. |
| 357 std::vector<std::string> languages_; | 357 std::vector<std::string> languages_; |
| 358 std::string comma_separated_language_list_; | 358 std::string comma_separated_language_list_; |
| 359 | 359 |
| 360 views::TableModelObserver* observer_; | 360 TableModelObserver* observer_; |
| 361 | 361 |
| 362 DISALLOW_COPY_AND_ASSIGN(LanguageOrderTableModel); | 362 DISALLOW_COPY_AND_ASSIGN(LanguageOrderTableModel); |
| 363 }; | 363 }; |
| 364 | 364 |
| 365 LanguageOrderTableModel::LanguageOrderTableModel() | 365 LanguageOrderTableModel::LanguageOrderTableModel() |
| 366 : observer_(NULL) { | 366 : observer_(NULL) { |
| 367 } | 367 } |
| 368 | 368 |
| 369 void LanguageOrderTableModel::SetAcceptLanguagesString( | 369 void LanguageOrderTableModel::SetAcceptLanguagesString( |
| 370 const std::string& language_list) { | 370 const std::string& language_list) { |
| 371 std::vector<std::string> languages_vector; | 371 std::vector<std::string> languages_vector; |
| 372 ListToVector(language_list, &languages_vector); | 372 ListToVector(language_list, &languages_vector); |
| 373 for (int i = 0; i < static_cast<int>(languages_vector.size()); i++) { | 373 for (int i = 0; i < static_cast<int>(languages_vector.size()); i++) { |
| 374 Add(languages_vector.at(i)); | 374 Add(languages_vector.at(i)); |
| 375 } | 375 } |
| 376 } | 376 } |
| 377 | 377 |
| 378 void LanguageOrderTableModel::SetObserver( | 378 void LanguageOrderTableModel::SetObserver(TableModelObserver* observer) { |
| 379 views::TableModelObserver* observer) { | |
| 380 observer_ = observer; | 379 observer_ = observer; |
| 381 } | 380 } |
| 382 | 381 |
| 383 std::wstring LanguageOrderTableModel::GetText(int row, int column_id) { | 382 std::wstring LanguageOrderTableModel::GetText(int row, int column_id) { |
| 384 DCHECK(row >= 0 && row < RowCount()); | 383 DCHECK(row >= 0 && row < RowCount()); |
| 385 const std::wstring app_locale = g_browser_process->GetApplicationLocale(); | 384 const std::wstring app_locale = g_browser_process->GetApplicationLocale(); |
| 386 return l10n_util::GetLocalName(languages_.at(row), app_locale, true); | 385 return l10n_util::GetLocalName(languages_.at(row), app_locale, true); |
| 387 } | 386 } |
| 388 | 387 |
| 389 void LanguageOrderTableModel::Add(const std::string& language) { | 388 void LanguageOrderTableModel::Add(const std::string& language) { |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 l10n_util::GetString( | 561 l10n_util::GetString( |
| 563 IDS_FONT_LANGUAGE_SETTING_LANGUAGES_INSTRUCTIONS)); | 562 IDS_FONT_LANGUAGE_SETTING_LANGUAGES_INSTRUCTIONS)); |
| 564 languages_instructions_->SetMultiLine(true); | 563 languages_instructions_->SetMultiLine(true); |
| 565 languages_instructions_->SetHorizontalAlignment( | 564 languages_instructions_->SetHorizontalAlignment( |
| 566 views::Label::ALIGN_LEFT); | 565 views::Label::ALIGN_LEFT); |
| 567 layout->StartRow(0, single_column_view_set_id); | 566 layout->StartRow(0, single_column_view_set_id); |
| 568 layout->AddView(languages_instructions_); | 567 layout->AddView(languages_instructions_); |
| 569 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); | 568 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); |
| 570 | 569 |
| 571 // Add two columns - for table, and for button stack. | 570 // Add two columns - for table, and for button stack. |
| 572 std::vector<views::TableColumn> columns; | 571 std::vector<TableColumn> columns; |
| 573 columns.push_back(views::TableColumn()); | 572 columns.push_back(TableColumn()); |
| 574 language_order_table_model_.reset(new LanguageOrderTableModel); | 573 language_order_table_model_.reset(new LanguageOrderTableModel); |
| 575 language_order_table_ = new views::TableView( | 574 language_order_table_ = new views::TableView( |
| 576 language_order_table_model_.get(), columns, | 575 language_order_table_model_.get(), columns, |
| 577 views::TEXT_ONLY, false, true, true); | 576 views::TEXT_ONLY, false, true, true); |
| 578 language_order_table_->SetObserver(this); | 577 language_order_table_->SetObserver(this); |
| 579 | 578 |
| 580 const int double_column_view_set_id = 1; | 579 const int double_column_view_set_id = 1; |
| 581 column_set = layout->AddColumnSet(double_column_view_set_id); | 580 column_set = layout->AddColumnSet(double_column_view_set_id); |
| 582 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, | 581 column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, |
| 583 GridLayout::USE_PREF, 0, 0); | 582 GridLayout::USE_PREF, 0, 0); |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 } | 870 } |
| 872 | 871 |
| 873 if (enable_spellcheck_checkbox_clicked_) | 872 if (enable_spellcheck_checkbox_clicked_) |
| 874 enable_spellcheck_.SetValue(enable_spellchecking_checkbox_->checked()); | 873 enable_spellcheck_.SetValue(enable_spellchecking_checkbox_->checked()); |
| 875 | 874 |
| 876 if (enable_autospellcorrect_checkbox_clicked_) { | 875 if (enable_autospellcorrect_checkbox_clicked_) { |
| 877 enable_autospellcorrect_.SetValue( | 876 enable_autospellcorrect_.SetValue( |
| 878 enable_autospellcorrect_checkbox_->checked()); | 877 enable_autospellcorrect_checkbox_->checked()); |
| 879 } | 878 } |
| 880 } | 879 } |
| OLD | NEW |