diff options
author | chocobo@chromium.org <chocobo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-26 22:32:06 +0000 |
---|---|---|
committer | chocobo@chromium.org <chocobo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-26 22:32:06 +0000 |
commit | 5dcbc02fef541561a2ff97a73e231fe751e05829 (patch) | |
tree | 7b409ff83b05bd599de7b84bc367391853348e15 | |
parent | 67afac662aa2d527a5993fa9eaf5b8f52ebe73e1 (diff) | |
download | chromium_src-5dcbc02fef541561a2ff97a73e231fe751e05829.zip chromium_src-5dcbc02fef541561a2ff97a73e231fe751e05829.tar.gz chromium_src-5dcbc02fef541561a2ff97a73e231fe751e05829.tar.bz2 |
Split chromeos options page into system and internet.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/548152
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37155 0039d316-1c4b-4281-b951-d872f2087c98
18 files changed, 423 insertions, 350 deletions
diff --git a/chrome/app/chrome_dll_resource.h b/chrome/app/chrome_dll_resource.h index b1351c5..6d1090b 100644 --- a/chrome/app/chrome_dll_resource.h +++ b/chrome/app/chrome_dll_resource.h @@ -246,7 +246,8 @@ // Placed in a common file to help insure they never collide. #define IDC_BOOKMARK_MENU 43000 // OSX only #define IDC_VIEW_MENU 44000 // OSX only -#define IDC_CONTROL_PANEL 45000 // Linux2 only +#define IDC_SYSTEM_OPTIONS 45000 // ChromeOS only +#define IDC_INTERNET_OPTIONS 45100 // ChromeOS only #define IDC_HISTORY_MENU 46000 // OSX only #define IDC_HISTORY_MENU_VISITED 46100 // OSX only #define IDC_HISTORY_MENU_CLOSED 46200 // OSX only diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd index 61a4d08..c4e1e82 100644 --- a/chrome/app/generated_resources.grd +++ b/chrome/app/generated_resources.grd @@ -4662,6 +4662,14 @@ Keep your key file in a safe place. You will need it to create new versions of y <message name="IDS_OPTIONS_DIALOG_TITLE" desc="The title of the Options dialog box"> <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> Options </message> + <if expr="pp_ifdef('chromeos')"> + <message name="IDS_OPTIONS_SYSTEM_TAB_LABEL" desc="The title of the System tab"> + System + </message> + <message name="IDS_OPTIONS_INTERNET_TAB_LABEL" desc="The title of the Internet tab"> + Internet + </message> + </if> <message name="IDS_OPTIONS_GENERAL_TAB_LABEL" desc="The title of the Basics tab"> Basics </message> diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index d6d9122..88c9c6e 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -4,6 +4,9 @@ #include "chrome/browser/browser.h" +#include <algorithm> +#include <string> + #include "app/animation.h" #include "app/l10n_util.h" #include "base/base_paths.h" @@ -1322,9 +1325,14 @@ void Browser::OpenThemeGalleryTabAndActivate() { } #if defined(OS_CHROMEOS) -void Browser::ShowControlPanel() { - UserMetrics::RecordAction("ShowControlPanel", profile_); - ShowOptionsWindow(OPTIONS_PAGE_SETTINGS, OPTIONS_GROUP_NONE, profile_); +void Browser::OpenSystemOptionsDialog() { + UserMetrics::RecordAction("OpenSystemOptionsDialog", profile_); + ShowOptionsWindow(OPTIONS_PAGE_SYSTEM, OPTIONS_GROUP_NONE, profile_); +} + +void Browser::OpenInternetOptionsDialog() { + UserMetrics::RecordAction("OpenInternetOptionsDialog", profile_); + ShowOptionsWindow(OPTIONS_PAGE_INTERNET, OPTIONS_GROUP_NONE, profile_); } #endif @@ -1420,7 +1428,7 @@ void Browser::ExecuteCommandWithDisposition( if (block_command_execution_) { // We actually only allow no more than one blocked command, otherwise some // commands maybe lost. - DCHECK(last_blocked_command_id_ == -1); + DCHECK_EQ(last_blocked_command_id_, -1); last_blocked_command_id_ = id; last_blocked_command_disposition_ = disposition; return; @@ -1578,7 +1586,8 @@ void Browser::ExecuteCommandWithDisposition( case IDC_ABOUT: OpenAboutChromeDialog(); break; case IDC_HELP_PAGE: OpenHelpTab(); break; #if defined(OS_CHROMEOS) - case IDC_CONTROL_PANEL: ShowControlPanel(); break; + case IDC_SYSTEM_OPTIONS: OpenSystemOptionsDialog(); break; + case IDC_INTERNET_OPTIONS: OpenInternetOptionsDialog(); break; #endif default: @@ -2560,7 +2569,8 @@ void Browser::InitCommandState() { enable_extensions); #if defined(OS_CHROMEOS) - command_updater_.UpdateCommandEnabled(IDC_CONTROL_PANEL, true); + command_updater_.UpdateCommandEnabled(IDC_SYSTEM_OPTIONS, true); + command_updater_.UpdateCommandEnabled(IDC_INTERNET_OPTIONS, true); #endif // Initialize other commands based on the window type. diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h index e43db31..cea9389 100644 --- a/chrome/browser/browser.h +++ b/chrome/browser/browser.h @@ -432,7 +432,8 @@ class Browser : public TabStripModelDelegate, // Used by the "Get themes" link in the options dialog. void OpenThemeGalleryTabAndActivate(); #if defined(OS_CHROMEOS) - void ShowControlPanel(); + void OpenSystemOptionsDialog(); + void OpenInternetOptionsDialog(); #endif virtual void UpdateDownloadShelfVisibility(bool visible); @@ -806,7 +807,7 @@ class Browser : public TabStripModelDelegate, // UI update coalescing and handling //////////////////////////////////////// - typedef std::map<const TabContents*,int> UpdateMap; + typedef std::map<const TabContents*, int> UpdateMap; // Maps from TabContents to pending UI updates that need to be processed. // We don't update things like the URL or tab title right away to avoid diff --git a/chrome/browser/chromeos/clock_menu_button.cc b/chrome/browser/chromeos/clock_menu_button.cc index 78f1310..5eb786d 100644 --- a/chrome/browser/chromeos/clock_menu_button.cc +++ b/chrome/browser/chromeos/clock_menu_button.cc @@ -131,7 +131,7 @@ bool ClockMenuButton::IsEnabledAt(int index) const { } void ClockMenuButton::ActivatedAt(int index) { - browser_->ShowControlPanel(); + browser_->OpenSystemOptionsDialog(); } //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/chromeos/internet_page_view.cc b/chrome/browser/chromeos/internet_page_view.cc new file mode 100644 index 0000000..99f0e54 --- /dev/null +++ b/chrome/browser/chromeos/internet_page_view.cc @@ -0,0 +1,217 @@ +// Copyright (c) 2009 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. + +#include "chrome/browser/chromeos/internet_page_view.h" + +#include <string> + +#include "app/combobox_model.h" +#include "chrome/browser/chromeos/network_library.h" +#include "chrome/browser/chromeos/password_dialog_view.h" +#include "grit/generated_resources.h" +#include "views/controls/combobox/combobox.h" +#include "views/window/window.h" + +namespace chromeos { + +//////////////////////////////////////////////////////////////////////////////// +// NetworkSection + +// Network section for wifi settings +class NetworkSection : public SettingsPageSection, + public views::Combobox::Listener, + public PasswordDialogDelegate, + public NetworkLibrary::Observer { + public: + explicit NetworkSection(Profile* profile); + virtual ~NetworkSection(); + + // Overridden from views::Combobox::Listener: + virtual void ItemChanged(views::Combobox* sender, + int prev_index, + int new_index); + + // PasswordDialogDelegate implementation. + virtual bool OnPasswordDialogCancel(); + virtual bool OnPasswordDialogAccept(const std::string& ssid, + const string16& password); + + // NetworkLibrary::Observer implementation. + virtual void NetworkChanged(NetworkLibrary* obj); + virtual void NetworkTraffic(NetworkLibrary* obj, int traffic_type) {} + + protected: + // SettingsPageSection overrides: + virtual void InitContents(GridLayout* layout); + + private: + // The Combobox model for the list of wifi networks + class WifiNetworkComboModel : public ComboboxModel { + public: + WifiNetworkComboModel() { + wifi_networks_ = NetworkLibrary::Get()->wifi_networks(); + } + + virtual int GetItemCount() { + // Item count is always 1 more than number of networks. + // If there are no networks, then we show a message stating that. + // If there are networks, the first item is empty. + return static_cast<int>(wifi_networks_.size()) + 1; + } + + virtual std::wstring GetItemAt(int index) { + if (index == 0) { + return wifi_networks_.empty() ? + l10n_util::GetString(IDS_STATUSBAR_NO_NETWORKS_MESSAGE) : + std::wstring(); + } + // If index is greater than one, we get the corresponding network, + // which is in the wifi_networks_ list in [index-1] position. + return ASCIIToWide(wifi_networks_[index-1].ssid); + } + + virtual bool HasWifiNetworks() { + return !wifi_networks_.empty(); + } + + virtual const WifiNetwork& GetWifiNetworkAt(int index) { + return wifi_networks_[index-1]; + } + + private: + WifiNetworkVector wifi_networks_; + + DISALLOW_COPY_AND_ASSIGN(WifiNetworkComboModel); + }; + + // This method will change the combobox selection to the passed in wifi ssid. + void SelectWifi(const std::string& wifi_ssid); + + // Controls for this section: + views::Combobox* wifi_ssid_combobox_; + + // Used to store the index (in combobox) of the currently connected wifi. + int last_selected_wifi_ssid_index_; + + // The activated wifi network. + WifiNetwork activated_wifi_network_; + + // The wifi ssid models. + WifiNetworkComboModel wifi_ssid_model_; + + DISALLOW_COPY_AND_ASSIGN(NetworkSection); +}; + +NetworkSection::NetworkSection(Profile* profile) + : SettingsPageSection(profile, IDS_OPTIONS_SETTINGS_SECTION_TITLE_NETWORK), + wifi_ssid_combobox_(NULL), + last_selected_wifi_ssid_index_(0) { + NetworkLibrary::Get()->AddObserver(this); +} + +NetworkSection::~NetworkSection() { + NetworkLibrary::Get()->RemoveObserver(this); +} + +void NetworkSection::ItemChanged(views::Combobox* sender, + int prev_index, + int new_index) { + if (new_index == prev_index) + return; + + // Don't allow switching to the first item (which is empty). + if (new_index == 0) { + wifi_ssid_combobox_->SetSelectedItem(prev_index); + return; + } + + if (!wifi_ssid_model_.HasWifiNetworks()) + return; + + last_selected_wifi_ssid_index_ = prev_index; + activated_wifi_network_ = wifi_ssid_model_.GetWifiNetworkAt(new_index); + // Connect to wifi here. Open password page if appropriate. + if (activated_wifi_network_.encrypted) { + views::Window* window = views::Window::CreateChromeWindow( + NULL, + gfx::Rect(), + new PasswordDialogView(this, activated_wifi_network_.ssid)); + window->SetIsAlwaysOnTop(true); + window->Show(); + } else { + NetworkLibrary::Get()->ConnectToWifiNetwork(activated_wifi_network_, + string16()); + } +} + +bool NetworkSection::OnPasswordDialogCancel() { + // Change combobox to previous setting. + wifi_ssid_combobox_->SetSelectedItem(last_selected_wifi_ssid_index_); + return true; +} + +bool NetworkSection::OnPasswordDialogAccept(const std::string& ssid, + const string16& password) { + NetworkLibrary::Get()->ConnectToWifiNetwork(activated_wifi_network_, + password); + return true; +} + +void NetworkSection::NetworkChanged(NetworkLibrary* obj) { + SelectWifi(obj->wifi_ssid()); +} + +void NetworkSection::InitContents(GridLayout* layout) { + wifi_ssid_combobox_ = new views::Combobox(&wifi_ssid_model_); + wifi_ssid_combobox_->SetSelectedItem(last_selected_wifi_ssid_index_); + wifi_ssid_combobox_->set_listener(this); + + layout->StartRow(0, single_column_view_set_id()); + layout->AddView(wifi_ssid_combobox_); + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + + // Select the initial connected wifi network. + SelectWifi(NetworkLibrary::Get()->wifi_ssid()); +} + +void NetworkSection::SelectWifi(const std::string& wifi_ssid) { + if (wifi_ssid_model_.HasWifiNetworks() && wifi_ssid_combobox_) { + // If we are not connected to any wifi network, wifi_ssid will be empty. + // So we select the first item. + if (wifi_ssid.empty()) { + wifi_ssid_combobox_->SetSelectedItem(0); + } else { + // Loop through the list and select the ssid that matches. + for (int i = 1; i < wifi_ssid_model_.GetItemCount(); i++) { + if (wifi_ssid_model_.GetWifiNetworkAt(i).ssid == wifi_ssid) { + last_selected_wifi_ssid_index_ = i; + wifi_ssid_combobox_->SetSelectedItem(i); + return; + } + } + } + } +} + +//////////////////////////////////////////////////////////////////////////////// +// InternetPageView + +//////////////////////////////////////////////////////////////////////////////// +// InternetPageView, SettingsPageView implementation: + +void InternetPageView::InitControlLayout() { + GridLayout* layout = CreatePanelGridLayout(this); + SetLayoutManager(layout); + + int single_column_view_set_id = 0; + ColumnSet* column_set = layout->AddColumnSet(single_column_view_set_id); + column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, + GridLayout::USE_PREF, 0, 0); + + layout->StartRow(0, single_column_view_set_id); + layout->AddView(new NetworkSection(profile())); + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); +} + +} // namespace chromeos diff --git a/chrome/browser/chromeos/internet_page_view.h b/chrome/browser/chromeos/internet_page_view.h new file mode 100644 index 0000000..0dd2bf6 --- /dev/null +++ b/chrome/browser/chromeos/internet_page_view.h @@ -0,0 +1,27 @@ +// Copyright (c) 2006-2008 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. + +#ifndef CHROME_BROWSER_CHROMEOS_INTERNET_PAGE_VIEW_H_ +#define CHROME_BROWSER_CHROMEOS_INTERNET_PAGE_VIEW_H_ + +#include "chrome/browser/chromeos/settings_page_view.h" + +namespace chromeos { + +// Internet settings page for Chrome OS +class InternetPageView : public SettingsPageView { + public: + explicit InternetPageView(Profile* profile) : SettingsPageView(profile) {} + virtual ~InternetPageView() {} + + protected: + // SettingsPageView implementation: + virtual void InitControlLayout(); + + DISALLOW_COPY_AND_ASSIGN(InternetPageView); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_INTERNET_PAGE_VIEW_H_ diff --git a/chrome/browser/chromeos/language_menu_button.cc b/chrome/browser/chromeos/language_menu_button.cc index 89850bb..6bb20b3 100644 --- a/chrome/browser/chromeos/language_menu_button.cc +++ b/chrome/browser/chromeos/language_menu_button.cc @@ -267,7 +267,7 @@ void LanguageMenuButton::ActivatedAt(int index) { DCHECK(language_list_.get()); if (IndexPointsToConfigureImeMenuItem(index)) { - browser_->ShowControlPanel(); + browser_->OpenSystemOptionsDialog(); return; } diff --git a/chrome/browser/chromeos/network_menu_button.cc b/chrome/browser/chromeos/network_menu_button.cc index 0313e0c..2ed70de 100644 --- a/chrome/browser/chromeos/network_menu_button.cc +++ b/chrome/browser/chromeos/network_menu_button.cc @@ -344,6 +344,10 @@ void NetworkMenuButton::InitMenuItems() { menu_items_.clear(); // Populate our MenuItems with the current list of wifi networks. NetworkLibrary* cros = NetworkLibrary::Get(); + // If cros is not loaded, then have an empty menu. + if (!cros->EnsureLoaded()) + return; + bool offline_mode = cros->offline_mode(); // Wifi: Status. diff --git a/chrome/browser/chromeos/settings_contents_view.h b/chrome/browser/chromeos/settings_contents_view.h deleted file mode 100644 index 06d91c0..0000000 --- a/chrome/browser/chromeos/settings_contents_view.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2006-2008 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. - -#ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_CONTENTS_VIEW_H_ -#define CHROME_BROWSER_CHROMEOS_SETTINGS_CONTENTS_VIEW_H_ - -#include "chrome/browser/views/options/options_page_view.h" - -namespace chromeos { - -// Contents of the settings page for Chrome OS -class SettingsContentsView : public OptionsPageView { - public: - explicit SettingsContentsView(Profile* profile) : OptionsPageView(profile) {} - virtual ~SettingsContentsView() {} - - protected: - // OptionsPageView implementation: - virtual void InitControlLayout(); - - DISALLOW_COPY_AND_ASSIGN(SettingsContentsView); -}; - -} // namespace chromeos - -#endif // CHROME_BROWSER_CHROMEOS_SETTINGS_CONTENTS_VIEW_H_ diff --git a/chrome/browser/chromeos/settings_page_view.cc b/chrome/browser/chromeos/settings_page_view.cc index 87aa7ee..779eb1a 100644 --- a/chrome/browser/chromeos/settings_page_view.cc +++ b/chrome/browser/chromeos/settings_page_view.cc @@ -4,7 +4,6 @@ #include "chrome/browser/chromeos/settings_page_view.h" -#include "chrome/browser/chromeos/settings_contents_view.h" #include "skia/ext/skia_utils_gtk.h" #include "views/controls/label.h" #include "views/fill_layout.h" @@ -36,10 +35,59 @@ GtkWidget* SettingsPageView::WrapInGtkWidget() { return widget->GetNativeView(); } -void SettingsPageView::InitControlLayout() { - // We'll likely need to make this scrollable - settings_contents_view_ = new SettingsContentsView(profile()); - AddChildView(settings_contents_view_); + +//////////////////////////////////////////////////////////////////////////////// +// SettingsPageSection + +SettingsPageSection::SettingsPageSection(Profile* profile, int title_msg_id) + : OptionsPageView(profile), + title_msg_id_(title_msg_id), + single_column_view_set_id_(0), + double_column_view_set_id_(1) { +} + +void SettingsPageSection::InitControlLayout() { + GridLayout* layout = new GridLayout(this); + SetLayoutManager(layout); + + int single_column_layout_id = 0; + ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); + column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0, + GridLayout::USE_PREF, 0, 0); + int inset_column_layout_id = 1; + column_set = layout->AddColumnSet(inset_column_layout_id); + column_set->AddPaddingColumn(0, kUnrelatedControlHorizontalSpacing); + column_set->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1, + GridLayout::USE_PREF, 0, 0); + + layout->StartRow(0, single_column_layout_id); + views::Label* title_label = new views::Label( + l10n_util::GetString(title_msg_id_)); + ResourceBundle& rb = ResourceBundle::GetSharedInstance(); + gfx::Font title_font = + rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD); + title_label->SetFont(title_font); + layout->AddView(title_label); + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + layout->StartRow(0, inset_column_layout_id); + + views::View* contents = new views::View; + GridLayout* child_layout = new GridLayout(contents); + contents->SetLayoutManager(child_layout); + + column_set = child_layout->AddColumnSet(single_column_view_set_id_); + column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, + GridLayout::USE_PREF, 0, 0); + + column_set = child_layout->AddColumnSet(double_column_view_set_id_); + column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, + GridLayout::USE_PREF, 0, 0); + column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); + column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, + GridLayout::USE_PREF, 0, 0); + + InitContents(child_layout); + layout->AddView(contents); } } // namespace chromeos diff --git a/chrome/browser/chromeos/settings_page_view.h b/chrome/browser/chromeos/settings_page_view.h index a908b2a..b123f0c 100644 --- a/chrome/browser/chromeos/settings_page_view.h +++ b/chrome/browser/chromeos/settings_page_view.h @@ -9,6 +9,14 @@ #include "chrome/browser/views/options/options_page_view.h" +#include "app/l10n_util.h" +#include "app/resource_bundle.h" +#include "views/grid_layout.h" +#include "views/standard_layout.h" + +using views::ColumnSet; +using views::GridLayout; + namespace chromeos { class SettingsContentsView; @@ -24,13 +32,33 @@ class SettingsPageView : public OptionsPageView { GtkWidget* WrapInGtkWidget(); protected: + virtual void InitControlLayout() = 0; + + DISALLOW_COPY_AND_ASSIGN(SettingsPageView); +}; + +// Base section class settings +class SettingsPageSection : public OptionsPageView { + public: + explicit SettingsPageSection(Profile* profile, int title_msg_id); + virtual ~SettingsPageSection() {} + + protected: + // OptionsPageView overrides: virtual void InitControlLayout(); + virtual void InitContents(GridLayout* layout) = 0; + + int single_column_view_set_id() const { return single_column_view_set_id_; } + int double_column_view_set_id() const { return double_column_view_set_id_; } private: - // Controls for the Settings page - SettingsContentsView* settings_contents_view_; + // The message id for the title of this section. + int title_msg_id_; - DISALLOW_COPY_AND_ASSIGN(SettingsPageView); + int single_column_view_set_id_; + int double_column_view_set_id_; + + DISALLOW_COPY_AND_ASSIGN(SettingsPageSection); }; } // namespace chromeos diff --git a/chrome/browser/chromeos/settings_contents_view.cc b/chrome/browser/chromeos/system_page_view.cc index d1ea9a5..93b193d 100644 --- a/chrome/browser/chromeos/settings_contents_view.cc +++ b/chrome/browser/chromeos/system_page_view.cc @@ -2,125 +2,30 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/chromeos/settings_contents_view.h" +#include "chrome/browser/chromeos/system_page_view.h" -#include <map> #include <string> #include <vector> #include "app/combobox_model.h" -#include "app/l10n_util.h" -#include "app/resource_bundle.h" -#include "base/basictypes.h" #include "base/stl_util-inl.h" -#include "base/string_util.h" #include "chrome/browser/chromeos/language_library.h" -#include "chrome/browser/chromeos/network_library.h" -#include "chrome/browser/chromeos/password_dialog_view.h" #include "chrome/browser/profile.h" #include "chrome/common/pref_member.h" #include "chrome/common/pref_names.h" -#include "grit/chromium_strings.h" #include "grit/generated_resources.h" -#include "unicode/strenum.h" #include "unicode/timezone.h" -#include "views/background.h" #include "views/controls/button/checkbox.h" #include "views/controls/combobox/combobox.h" #include "views/controls/slider/slider.h" -#include "views/grid_layout.h" -#include "views/standard_layout.h" -#include "views/window/window.h" - -using views::GridLayout; -using views::ColumnSet; namespace chromeos { //////////////////////////////////////////////////////////////////////////////// -// SettingsContentsSection - -// Base section class settings -class SettingsContentsSection : public OptionsPageView { - public: - explicit SettingsContentsSection(Profile* profile, int title_msg_id); - virtual ~SettingsContentsSection() {} - - protected: - // OptionsPageView overrides: - virtual void InitControlLayout(); - virtual void InitContents(GridLayout* layout) = 0; - - int single_column_view_set_id() const { return single_column_view_set_id_; } - int double_column_view_set_id() const { return double_column_view_set_id_; } - - private: - // The message id for the title of this section. - int title_msg_id_; - - int single_column_view_set_id_; - int double_column_view_set_id_; - - DISALLOW_COPY_AND_ASSIGN(SettingsContentsSection); -}; - -SettingsContentsSection::SettingsContentsSection(Profile* profile, - int title_msg_id) - : OptionsPageView(profile), - title_msg_id_(title_msg_id), - single_column_view_set_id_(0), - double_column_view_set_id_(1) { -} - -void SettingsContentsSection::InitControlLayout() { - GridLayout* layout = new GridLayout(this); - SetLayoutManager(layout); - - int single_column_layout_id = 0; - ColumnSet* column_set = layout->AddColumnSet(single_column_layout_id); - column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0, - GridLayout::USE_PREF, 0, 0); - int inset_column_layout_id = 1; - column_set = layout->AddColumnSet(inset_column_layout_id); - column_set->AddPaddingColumn(0, kUnrelatedControlHorizontalSpacing); - column_set->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1, - GridLayout::USE_PREF, 0, 0); - - layout->StartRow(0, single_column_layout_id); - views::Label* title_label = new views::Label( - l10n_util::GetString(title_msg_id_)); - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - gfx::Font title_font = - rb.GetFont(ResourceBundle::BaseFont).DeriveFont(0, gfx::Font::BOLD); - title_label->SetFont(title_font); - layout->AddView(title_label); - layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - layout->StartRow(0, inset_column_layout_id); - - views::View* contents = new views::View; - GridLayout* child_layout = new GridLayout(contents); - contents->SetLayoutManager(child_layout); - - column_set = child_layout->AddColumnSet(single_column_view_set_id_); - column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, - GridLayout::USE_PREF, 0, 0); - - column_set = child_layout->AddColumnSet(double_column_view_set_id_); - column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 0, - GridLayout::USE_PREF, 0, 0); - column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); - column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, - GridLayout::USE_PREF, 0, 0); - - InitContents(child_layout); - layout->AddView(contents); -} - -//////////////////////////////////////////////////////////////////////////////// // DateTimeSection // Date/Time section for datetime settings -class DateTimeSection : public SettingsContentsSection, +class DateTimeSection : public SettingsPageSection, public views::Combobox::Listener { public: explicit DateTimeSection(Profile* profile); @@ -132,7 +37,7 @@ class DateTimeSection : public SettingsContentsSection, int new_index); protected: - // SettingsContentsSection overrides: + // SettingsPageSection overrides: virtual void InitContents(GridLayout* layout); virtual void NotifyPrefChanged(const std::wstring* pref_name); @@ -207,8 +112,7 @@ class DateTimeSection : public SettingsContentsSection, }; DateTimeSection::DateTimeSection(Profile* profile) - : SettingsContentsSection(profile, - IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME), + : SettingsPageSection(profile, IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME), timezone_combobox_(NULL) { } @@ -251,189 +155,9 @@ void DateTimeSection::SelectTimeZone(const std::wstring& id) { } //////////////////////////////////////////////////////////////////////////////// -// NetworkSection - -// Network section for wifi settings -class NetworkSection : public SettingsContentsSection, - public views::Combobox::Listener, - public PasswordDialogDelegate, - public NetworkLibrary::Observer { - public: - explicit NetworkSection(Profile* profile); - virtual ~NetworkSection(); - - // Overridden from views::Combobox::Listener: - virtual void ItemChanged(views::Combobox* sender, - int prev_index, - int new_index); - - // PasswordDialogDelegate implementation. - virtual bool OnPasswordDialogCancel(); - virtual bool OnPasswordDialogAccept(const std::string& ssid, - const string16& password); - - // NetworkLibrary::Observer implementation. - virtual void NetworkChanged(NetworkLibrary* obj); - virtual void NetworkTraffic(NetworkLibrary* obj, int traffic_type) {} - - protected: - // SettingsContentsSection overrides: - virtual void InitContents(GridLayout* layout); - - private: - // The Combobox model for the list of wifi networks - class WifiNetworkComboModel : public ComboboxModel { - public: - WifiNetworkComboModel() { - wifi_networks_ = NetworkLibrary::Get()->wifi_networks(); - } - - virtual int GetItemCount() { - // Item count is always 1 more than number of networks. - // If there are no networks, then we show a message stating that. - // If there are networks, the first item is empty. - return static_cast<int>(wifi_networks_.size()) + 1; - } - - virtual std::wstring GetItemAt(int index) { - if (index == 0) { - return wifi_networks_.empty() ? - l10n_util::GetString(IDS_STATUSBAR_NO_NETWORKS_MESSAGE) : - std::wstring(); - } - // If index is greater than one, we get the corresponding network, - // which is in the wifi_networks_ list in [index-1] position. - return ASCIIToWide(wifi_networks_[index-1].ssid); - } - - virtual bool HasWifiNetworks() { - return !wifi_networks_.empty(); - } - - virtual const WifiNetwork& GetWifiNetworkAt(int index) { - return wifi_networks_[index-1]; - } - - private: - WifiNetworkVector wifi_networks_; - - DISALLOW_COPY_AND_ASSIGN(WifiNetworkComboModel); - }; - - // This method will change the combobox selection to the passed in wifi ssid. - void SelectWifi(const std::string& wifi_ssid); - - // Controls for this section: - views::Combobox* wifi_ssid_combobox_; - - // Used to store the index (in combobox) of the currently connected wifi. - int last_selected_wifi_ssid_index_; - - // The activated wifi network. - WifiNetwork activated_wifi_network_; - - // The wifi ssid models. - WifiNetworkComboModel wifi_ssid_model_; - - DISALLOW_COPY_AND_ASSIGN(NetworkSection); -}; - -NetworkSection::NetworkSection(Profile* profile) - : SettingsContentsSection(profile, - IDS_OPTIONS_SETTINGS_SECTION_TITLE_NETWORK), - wifi_ssid_combobox_(NULL), - last_selected_wifi_ssid_index_(0) { - NetworkLibrary::Get()->AddObserver(this); -} - -NetworkSection::~NetworkSection() { - NetworkLibrary::Get()->RemoveObserver(this); -} - -void NetworkSection::ItemChanged(views::Combobox* sender, - int prev_index, - int new_index) { - if (new_index == prev_index) - return; - - // Don't allow switching to the first item (which is empty). - if (new_index == 0) { - wifi_ssid_combobox_->SetSelectedItem(prev_index); - return; - } - - if (!wifi_ssid_model_.HasWifiNetworks()) - return; - - last_selected_wifi_ssid_index_ = prev_index; - activated_wifi_network_ = wifi_ssid_model_.GetWifiNetworkAt(new_index); - // Connect to wifi here. Open password page if appropriate. - if (activated_wifi_network_.encrypted) { - views::Window* window = views::Window::CreateChromeWindow( - NULL, - gfx::Rect(), - new PasswordDialogView(this, activated_wifi_network_.ssid)); - window->SetIsAlwaysOnTop(true); - window->Show(); - } else { - NetworkLibrary::Get()->ConnectToWifiNetwork(activated_wifi_network_, - string16()); - } -} - -bool NetworkSection::OnPasswordDialogCancel() { - // Change combobox to previous setting. - wifi_ssid_combobox_->SetSelectedItem(last_selected_wifi_ssid_index_); - return true; -} - -bool NetworkSection::OnPasswordDialogAccept(const std::string& ssid, - const string16& password) { - NetworkLibrary::Get()->ConnectToWifiNetwork(activated_wifi_network_, - password); - return true; -} - -void NetworkSection::NetworkChanged(NetworkLibrary* obj) { - SelectWifi(obj->wifi_ssid()); -} - -void NetworkSection::InitContents(GridLayout* layout) { - wifi_ssid_combobox_ = new views::Combobox(&wifi_ssid_model_); - wifi_ssid_combobox_->SetSelectedItem(last_selected_wifi_ssid_index_); - wifi_ssid_combobox_->set_listener(this); - - layout->StartRow(0, single_column_view_set_id()); - layout->AddView(wifi_ssid_combobox_); - layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - - // Select the initial connected wifi network. - SelectWifi(NetworkLibrary::Get()->wifi_ssid()); -} - -void NetworkSection::SelectWifi(const std::string& wifi_ssid) { - if (wifi_ssid_model_.HasWifiNetworks() && wifi_ssid_combobox_) { - // If we are not connected to any wifi network, wifi_ssid will be empty. - // So we select the first item. - if (wifi_ssid.empty()) { - wifi_ssid_combobox_->SetSelectedItem(0); - } else { - // Loop through the list and select the ssid that matches. - for (int i = 1; i < wifi_ssid_model_.GetItemCount(); i++) { - if (wifi_ssid_model_.GetWifiNetworkAt(i).ssid == wifi_ssid) { - last_selected_wifi_ssid_index_ = i; - wifi_ssid_combobox_->SetSelectedItem(i); - return; - } - } - } - } -} - -//////////////////////////////////////////////////////////////////////////////// // TouchpadSection -class TouchpadSection : public SettingsContentsSection, +class TouchpadSection : public SettingsPageSection, public views::ButtonListener, public views::SliderListener { public: @@ -447,7 +171,7 @@ class TouchpadSection : public SettingsContentsSection, virtual void SliderValueChanged(views::Slider* sender); protected: - // SettingsContentsSection overrides: + // SettingsPageSection overrides: virtual void InitContents(GridLayout* layout); virtual void NotifyPrefChanged(const std::wstring* pref_name); @@ -471,8 +195,7 @@ class TouchpadSection : public SettingsContentsSection, }; TouchpadSection::TouchpadSection(Profile* profile) - : SettingsContentsSection(profile, - IDS_OPTIONS_SETTINGS_SECTION_TITLE_TOUCHPAD), + : SettingsPageSection(profile, IDS_OPTIONS_SETTINGS_SECTION_TITLE_TOUCHPAD), enable_tap_to_click_checkbox_(NULL), enable_vert_edge_scroll_checkbox_(NULL), speed_factor_slider_(NULL), @@ -602,14 +325,14 @@ class LanguageCheckbox : public views::Checkbox { }; // TextInput section for text input settings. -class TextInputSection : public SettingsContentsSection, +class TextInputSection : public SettingsPageSection, public views::ButtonListener { public: explicit TextInputSection(Profile* profile); virtual ~TextInputSection() {} private: - // Overridden from SettingsContentsSection: + // Overridden from SettingsPageSection: virtual void InitContents(GridLayout* layout); // Overridden from views::ButtonListener: @@ -619,8 +342,8 @@ class TextInputSection : public SettingsContentsSection, }; TextInputSection::TextInputSection(Profile* profile) - : SettingsContentsSection(profile, - IDS_OPTIONS_SETTINGS_SECTION_TITLE_TEXT_INPUT) { + : SettingsPageSection(profile, + IDS_OPTIONS_SETTINGS_SECTION_TITLE_TEXT_INPUT) { } void TextInputSection::ButtonPressed( @@ -677,12 +400,12 @@ void TextInputSection::InitContents(GridLayout* layout) { } //////////////////////////////////////////////////////////////////////////////// -// SettingsContentsView +// SystemPageView //////////////////////////////////////////////////////////////////////////////// -// SettingsContentsView, OptionsPageView implementation: +// SystemPageView, SettingsPageView implementation: -void SettingsContentsView::InitControlLayout() { +void SystemPageView::InitControlLayout() { GridLayout* layout = CreatePanelGridLayout(this); SetLayoutManager(layout); @@ -694,10 +417,6 @@ void SettingsContentsView::InitControlLayout() { layout->StartRow(0, single_column_view_set_id); layout->AddView(new DateTimeSection(profile())); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - // TODO(chocobo): Add NetworkSection back once we have the UI finalized. -// layout->StartRow(0, single_column_view_set_id); -// layout->AddView(new NetworkSection(profile())); -// layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); layout->StartRow(0, single_column_view_set_id); layout->AddView(new TouchpadSection(profile())); layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); diff --git a/chrome/browser/chromeos/system_page_view.h b/chrome/browser/chromeos/system_page_view.h new file mode 100644 index 0000000..dbcac45 --- /dev/null +++ b/chrome/browser/chromeos/system_page_view.h @@ -0,0 +1,27 @@ +// Copyright (c) 2006-2008 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. + +#ifndef CHROME_BROWSER_CHROMEOS_SYSTEM_PAGE_VIEW_H_ +#define CHROME_BROWSER_CHROMEOS_SYSTEM_PAGE_VIEW_H_ + +#include "chrome/browser/chromeos/settings_page_view.h" + +namespace chromeos { + +// System settings page for Chrome OS +class SystemPageView : public SettingsPageView { + public: + explicit SystemPageView(Profile* profile) : SettingsPageView(profile) {} + virtual ~SystemPageView() {} + + protected: + // SettingsPageView implementation: + virtual void InitControlLayout(); + + DISALLOW_COPY_AND_ASSIGN(SystemPageView); +}; + +} // namespace chromeos + +#endif // CHROME_BROWSER_CHROMEOS_SYSTEM_PAGE_VIEW_H_ diff --git a/chrome/browser/gtk/options/options_window_gtk.cc b/chrome/browser/gtk/options/options_window_gtk.cc index fe30dc4..2a12e12 100644 --- a/chrome/browser/gtk/options/options_window_gtk.cc +++ b/chrome/browser/gtk/options/options_window_gtk.cc @@ -24,7 +24,8 @@ #include "grit/generated_resources.h" #if defined(OS_CHROMEOS) -#include "chrome/browser/chromeos/settings_page_view.h" +#include "chrome/browser/chromeos/internet_page_view.h" +#include "chrome/browser/chromeos/system_page_view.h" #endif /////////////////////////////////////////////////////////////////////////////// @@ -109,9 +110,15 @@ OptionsWindowGtk::OptionsWindowGtk(Profile* profile) #if defined(OS_CHROMEOS) gtk_notebook_append_page( GTK_NOTEBOOK(notebook_), - (new chromeos::SettingsPageView(profile_))->WrapInGtkWidget(), + (new chromeos::SystemPageView(profile_))->WrapInGtkWidget(), gtk_label_new( - l10n_util::GetStringUTF8(IDS_PRODUCT_OS_NAME).c_str())); + l10n_util::GetStringUTF8(IDS_OPTIONS_SYSTEM_TAB_LABEL).c_str())); + + gtk_notebook_append_page( + GTK_NOTEBOOK(notebook_), + (new chromeos::InternetPageView(profile_))->WrapInGtkWidget(), + gtk_label_new( + l10n_util::GetStringUTF8(IDS_OPTIONS_INTERNET_TAB_LABEL).c_str())); #endif gtk_notebook_append_page( diff --git a/chrome/browser/options_window.h b/chrome/browser/options_window.h index 8e9a74f..a54e7b9 100644 --- a/chrome/browser/options_window.h +++ b/chrome/browser/options_window.h @@ -14,7 +14,8 @@ class Profile; enum OptionsPage { OPTIONS_PAGE_DEFAULT = -1, #if defined(OS_CHROMEOS) - OPTIONS_PAGE_SETTINGS, + OPTIONS_PAGE_SYSTEM, + OPTIONS_PAGE_INTERNET, #endif OPTIONS_PAGE_GENERAL, OPTIONS_PAGE_CONTENT, diff --git a/chrome/browser/views/accelerator_table_gtk.cc b/chrome/browser/views/accelerator_table_gtk.cc index 5544310..971d05a4 100644 --- a/chrome/browser/views/accelerator_table_gtk.cc +++ b/chrome/browser/views/accelerator_table_gtk.cc @@ -120,7 +120,7 @@ const AcceleratorMapping kAcceleratorMap[] = { { base::VKEY_ESCAPE, true, false, false, IDC_TASK_MANAGER }, { base::VKEY_F11, false, true, true, IDC_FULLSCREEN }, { base::VKEY_DELETE, false, true, true, IDC_TASK_MANAGER }, - { base::VKEY_OEM_COMMA, false, true, false, IDC_CONTROL_PANEL }, + { base::VKEY_OEM_COMMA, false, true, false, IDC_SYSTEM_OPTIONS }, { base::VKEY_B, true, true, false, IDC_SHOW_BOOKMARK_MANAGER }, { base::VKEY_F1, false, false, false, IDC_HELP_PAGE }, { base::VKEY_Q, true, true, false, IDC_EXIT }, diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 04c9712..791c46d 100755 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -275,17 +275,19 @@ 'browser/chromeos/external_protocol_dialog.h', 'browser/chromeos/gview_request_interceptor.cc', 'browser/chromeos/gview_request_interceptor.h', + 'browser/chromeos/internet_page_view.cc', + 'browser/chromeos/internet_page_view.h', 'browser/chromeos/ipc_message.h', 'browser/chromeos/language_library.cc', 'browser/chromeos/language_library.h', 'browser/chromeos/language_menu_button.cc', 'browser/chromeos/language_menu_button.h', + 'browser/chromeos/login_library.cc', + 'browser/chromeos/login_library.h', 'browser/chromeos/login_manager_view.cc', 'browser/chromeos/login_manager_view.h', 'browser/chromeos/main_menu.cc', 'browser/chromeos/main_menu.h', - 'browser/chromeos/login_library.cc', - 'browser/chromeos/login_library.h', 'browser/chromeos/mount_library.cc', 'browser/chromeos/mount_library.h', 'browser/chromeos/network_library.cc', @@ -312,8 +314,6 @@ 'browser/chromeos/power_menu_button.h', 'browser/chromeos/preferences.cc', 'browser/chromeos/preferences.h', - 'browser/chromeos/settings_contents_view.cc', - 'browser/chromeos/settings_contents_view.h', 'browser/chromeos/settings_page_view.cc', 'browser/chromeos/settings_page_view.h', 'browser/chromeos/status_area_button.cc', @@ -322,6 +322,8 @@ 'browser/chromeos/status_area_view.h', 'browser/chromeos/synaptics_library.cc', 'browser/chromeos/synaptics_library.h', + 'browser/chromeos/system_page_view.cc', + 'browser/chromeos/system_page_view.h', 'browser/chromeos/usb_mount_observer.cc', 'browser/chromeos/usb_mount_observer.h', 'browser/chromeos/version_loader.cc', |