summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 01:00:53 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-05-14 01:00:53 +0000
commit0e3e3e3315a4233ba97c401a59bfd0bc452f46c5 (patch)
tree3df57fad23330446089545a470f8e7ca725986ca
parent98b2361a19da857b0f663dd23e70483761360d76 (diff)
downloadchromium_src-0e3e3e3315a4233ba97c401a59bfd0bc452f46c5.zip
chromium_src-0e3e3e3315a4233ba97c401a59bfd0bc452f46c5.tar.gz
chromium_src-0e3e3e3315a4233ba97c401a59bfd0bc452f46c5.tar.bz2
Add GTK options window (no options actually configurable yet.)
BUG=11507 Review URL: http://codereview.chromium.org/113377 Patch from Matt Mueller <mattm@google.com>. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16023 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser.cc6
-rw-r--r--chrome/browser/browser.h2
-rw-r--r--chrome/browser/gtk/options/options_window_gtk.cc192
-rw-r--r--chrome/browser/metrics/metrics_log.cc2
-rw-r--r--chrome/chrome.gyp1
-rw-r--r--chrome/common/temp_scaffolding_stubs.cc11
6 files changed, 211 insertions, 3 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index 5edfafc..dc35140 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/location_bar.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/net/url_fixer_upper.h"
+#include "chrome/browser/options_window.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/sessions/session_service.h"
#include "chrome/browser/sessions/session_types.h"
@@ -68,7 +69,6 @@
#include "chrome/browser/debugger/debugger_window.h"
#include "chrome/browser/dock_info.h"
#include "chrome/browser/download/save_package.h"
-#include "chrome/browser/options_window.h"
#include "chrome/browser/ssl/ssl_error_info.h"
#include "chrome/browser/task_manager.h"
#include "chrome/browser/user_data_manager.h"
@@ -1116,12 +1116,14 @@ void Browser::OpenClearBrowsingDataDialog() {
UserMetrics::RecordAction(L"ClearBrowsingData_ShowDlg", profile_);
window_->ShowClearBrowsingDataDialog();
}
+#endif
void Browser::OpenOptionsDialog() {
UserMetrics::RecordAction(L"ShowOptions", profile_);
ShowOptionsWindow(OPTIONS_PAGE_DEFAULT, OPTIONS_GROUP_NONE, profile_);
}
+#if defined(OS_WIN)
void Browser::OpenKeywordEditor() {
UserMetrics::RecordAction(L"EditSearchEngines", profile_);
window_->ShowSearchEnginesDialog();
@@ -1351,7 +1353,9 @@ void Browser::ExecuteCommandWithDisposition(
Personalization::HandleMenuItemClick(profile()); break;
#endif
case IDC_CLEAR_BROWSING_DATA: OpenClearBrowsingDataDialog(); break;
+#endif
case IDC_OPTIONS: OpenOptionsDialog(); break;
+#if defined(OS_WIN)
case IDC_EDIT_SEARCH_ENGINES: OpenKeywordEditor(); break;
case IDC_VIEW_PASSWORDS: OpenPasswordManager(); break;
#endif
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 68c7037..a1b5e46 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -372,7 +372,9 @@ class Browser : public TabStripModelDelegate,
void ShowDownloadsTab();
#if defined(OS_WIN)
void OpenClearBrowsingDataDialog();
+#endif
void OpenOptionsDialog();
+#if defined(OS_WIN)
void OpenKeywordEditor();
void OpenPasswordManager();
#endif
diff --git a/chrome/browser/gtk/options/options_window_gtk.cc b/chrome/browser/gtk/options/options_window_gtk.cc
new file mode 100644
index 0000000..4319335
--- /dev/null
+++ b/chrome/browser/gtk/options/options_window_gtk.cc
@@ -0,0 +1,192 @@
+// Copyright (c) 2006-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 <gtk/gtk.h>
+
+#include "chrome/browser/options_window.h"
+
+#include "app/l10n_util.h"
+#include "base/message_loop.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/profile.h"
+#include "chrome/common/pref_member.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
+#ifdef CHROME_PERSONALIZATION
+#include "chrome/personalization/personalization.h"
+#endif
+#include "grit/chromium_strings.h"
+#include "grit/generated_resources.h"
+
+///////////////////////////////////////////////////////////////////////////////
+// OptionsWindowGtk
+//
+// The contents of the Options dialog window.
+
+class OptionsWindowGtk {
+ public:
+ explicit OptionsWindowGtk(Profile* profile);
+ ~OptionsWindowGtk();
+
+ // Shows the Tab corresponding to the specified OptionsPage.
+ void ShowOptionsPage(OptionsPage page, OptionsGroup highlight_group);
+
+ private:
+ static void OnSwitchPage(GtkNotebook* notebook, GtkNotebookPage* page,
+ guint page_num, OptionsWindowGtk* options_window);
+
+ static void OnWindowDestroy(GtkWidget* widget, OptionsWindowGtk* window);
+
+ // The options dialog
+ GtkWidget *dialog_;
+
+ // The container of the option pages
+ GtkWidget *notebook_;
+
+ // The Profile associated with these options.
+ Profile* profile_;
+
+ // The last page the user was on when they opened the Options window.
+ IntegerPrefMember last_selected_page_;
+
+ DISALLOW_COPY_AND_ASSIGN(OptionsWindowGtk);
+};
+
+static OptionsWindowGtk* instance_ = NULL;
+
+///////////////////////////////////////////////////////////////////////////////
+// OptionsWindowGtk, public:
+
+OptionsWindowGtk::OptionsWindowGtk(Profile* profile)
+ // Always show preferences for the original profile. Most state when off
+ // the record comes from the original profile, but we explicitly use
+ // the original profile to avoid potential problems.
+ : profile_(profile->GetOriginalProfile()) {
+ // The download manager needs to be initialized before the contents of the
+ // Options Window are created.
+ profile_->GetDownloadManager();
+ // We don't need to observe changes in this value.
+ last_selected_page_.Init(prefs::kOptionsWindowLastTabIndex,
+ g_browser_process->local_state(), NULL);
+
+ dialog_ = gtk_dialog_new_with_buttons(
+ l10n_util::GetStringFUTF8(IDS_OPTIONS_DIALOG_TITLE,
+ WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))).c_str(),
+ // Prefs window is shared between all browser windows.
+ NULL,
+ // Non-modal.
+ GTK_DIALOG_NO_SEPARATOR,
+ GTK_STOCK_CLOSE,
+ GTK_RESPONSE_CLOSE,
+ NULL);
+
+ notebook_ = gtk_notebook_new();
+
+ gtk_notebook_append_page(
+ GTK_NOTEBOOK(notebook_),
+ gtk_label_new("TODO general"),
+ gtk_label_new(
+ l10n_util::GetStringUTF8(IDS_OPTIONS_GENERAL_TAB_LABEL).c_str()));
+
+ gtk_notebook_append_page(
+ GTK_NOTEBOOK(notebook_),
+ gtk_label_new("TODO content"),
+ gtk_label_new(
+ l10n_util::GetStringUTF8(IDS_OPTIONS_CONTENT_TAB_LABEL).c_str()));
+
+#ifdef CHROME_PERSONALIZATION
+ if (!Personalization::IsP13NDisabled()) {
+ gtk_notebook_append_page(
+ GTK_NOTEBOOK(notebook_),
+ gtk_label_new("TODO personalization"),
+ gtk_label_new(
+ l10n_util::GetStringUTF8(IDS_OPTIONS_USER_DATA_TAB_LABEL).c_str()));
+ }
+#endif
+
+ gtk_notebook_append_page(
+ GTK_NOTEBOOK(notebook_),
+ gtk_label_new("TODO advanced"),
+ gtk_label_new(
+ l10n_util::GetStringUTF8(IDS_OPTIONS_ADVANCED_TAB_LABEL).c_str()));
+
+ gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), notebook_);
+
+ DCHECK(
+ gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_)) == OPTIONS_PAGE_COUNT);
+
+ // Need to show the notebook before connecting switch-page signal, otherwise
+ // we'll immediately get a signal switching to page 0 and overwrite our
+ // last_selected_page_ value.
+ gtk_widget_show_all(dialog_);
+
+ g_signal_connect(notebook_, "switch-page", G_CALLBACK(OnSwitchPage), this);
+
+ // We only have one button and don't do any special handling, so just hook it
+ // directly to gtk_widget_destroy.
+ g_signal_connect_swapped(dialog_, "response", G_CALLBACK(gtk_widget_destroy),
+ dialog_);
+
+ g_signal_connect(dialog_, "destroy", G_CALLBACK(OnWindowDestroy), this);
+}
+
+OptionsWindowGtk::~OptionsWindowGtk() {
+}
+
+void OptionsWindowGtk::ShowOptionsPage(OptionsPage page,
+ OptionsGroup highlight_group) {
+ // Bring options window to front if it already existed and isn't already
+ // in front
+ // TODO(mattm): docs say it's preferable to use gtk_window_present_with_time
+ gtk_window_present(GTK_WINDOW(dialog_));
+
+ if (page == OPTIONS_PAGE_DEFAULT) {
+ // Remember the last visited page from local state.
+ page = static_cast<OptionsPage>(last_selected_page_.GetValue());
+ if (page == OPTIONS_PAGE_DEFAULT)
+ page = OPTIONS_PAGE_GENERAL;
+ }
+ // If the page number is out of bounds, reset to the first tab.
+ if (page < 0 || page >= gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook_)))
+ page = OPTIONS_PAGE_GENERAL;
+
+ gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook_), page);
+
+ // TODO(mattm): set highlight_group
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// OptionsWindowGtk, private:
+
+// static
+void OptionsWindowGtk::OnSwitchPage(GtkNotebook* notebook,
+ GtkNotebookPage* page,
+ guint page_num,
+ OptionsWindowGtk* options_window) {
+ int index = page_num;
+ DCHECK(index > OPTIONS_PAGE_DEFAULT && index < OPTIONS_PAGE_COUNT);
+ options_window->last_selected_page_.SetValue(index);
+}
+
+// static
+void OptionsWindowGtk::OnWindowDestroy(GtkWidget* widget,
+ OptionsWindowGtk* options_window) {
+ instance_ = NULL;
+ MessageLoop::current()->DeleteSoon(FROM_HERE, options_window);
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// Factory/finder method:
+
+void ShowOptionsWindow(OptionsPage page,
+ OptionsGroup highlight_group,
+ Profile* profile) {
+ DCHECK(profile);
+ // If there's already an existing options window, activate it and switch to
+ // the specified page.
+ if (!instance_) {
+ instance_ = new OptionsWindowGtk(profile);
+ }
+ instance_->ShowOptionsPage(page, highlight_group);
+}
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index e407946..7d81bce 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -112,8 +112,6 @@ std::string MetricsLog::CreateHash(const std::string& value) {
DCHECK(arraysize(digest.a) >= arraysize(reverse));
for (size_t i = 0; i < arraysize(reverse); ++i)
reverse[i] = digest.a[arraysize(reverse) - i - 1];
- LOG(INFO) << "Metrics: Hash numeric [" << value << "]=["
- << *reinterpret_cast<const uint64*>(&reverse[0]) << "]";
return std::string(reinterpret_cast<char*>(digest.a), arraysize(digest.a));
}
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 7634269..a023b9c 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -967,6 +967,7 @@
'browser/gtk/menu_gtk.h',
'browser/gtk/nine_box.cc',
'browser/gtk/nine_box.h',
+ 'browser/gtk/options/options_window_gtk.cc',
'browser/gtk/sad_tab_gtk.cc',
'browser/gtk/sad_tab_gtk.h',
'browser/gtk/slide_animator_gtk.cc',
diff --git a/chrome/common/temp_scaffolding_stubs.cc b/chrome/common/temp_scaffolding_stubs.cc
index 4ac32cc..8f3e3bd 100644
--- a/chrome/common/temp_scaffolding_stubs.cc
+++ b/chrome/common/temp_scaffolding_stubs.cc
@@ -15,6 +15,7 @@
#include "chrome/browser/first_run.h"
#include "chrome/browser/hung_renderer_dialog.h"
#include "chrome/browser/memory_details.h"
+#include "chrome/browser/options_window.h"
#include "chrome/browser/rlz/rlz.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/task_manager.h"
@@ -314,3 +315,13 @@ void BrowserList::AllBrowsersClosed() {
// TODO(port): Close any dependent windows if necessary when the last browser
// window is closed.
}
+
+//--------------------------------------------------------------------------
+
+#if defined(OS_MACOSX)
+void ShowOptionsWindow(OptionsPage page,
+ OptionsGroup highlight_group,
+ Profile* profile) {
+ NOTIMPLEMENTED();
+}
+#endif