| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 | 4 |
| 5 #include "chrome/browser/options_window.h" | 5 #include "chrome/browser/options_window.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/scoped_ptr.h" |
| 11 #include "chrome/browser/browser_list.h" | 12 #include "chrome/browser/browser_list.h" |
| 12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/browser_window.h" | 14 #include "chrome/browser/browser_window.h" |
| 15 #include "chrome/browser/gtk/accessible_widget_helper_gtk.h" |
| 14 #include "chrome/browser/gtk/options/advanced_page_gtk.h" | 16 #include "chrome/browser/gtk/options/advanced_page_gtk.h" |
| 15 #include "chrome/browser/gtk/options/content_page_gtk.h" | 17 #include "chrome/browser/gtk/options/content_page_gtk.h" |
| 16 #include "chrome/browser/gtk/options/general_page_gtk.h" | 18 #include "chrome/browser/gtk/options/general_page_gtk.h" |
| 17 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
| 18 #include "chrome/browser/window_sizer.h" | 20 #include "chrome/browser/window_sizer.h" |
| 21 #include "chrome/common/accessibility_events.h" |
| 19 #include "chrome/common/gtk_util.h" | 22 #include "chrome/common/gtk_util.h" |
| 23 #include "chrome/common/notification_service.h" |
| 20 #include "chrome/common/pref_member.h" | 24 #include "chrome/common/pref_member.h" |
| 21 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 22 #include "chrome/common/pref_service.h" | 26 #include "chrome/common/pref_service.h" |
| 23 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
| 24 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
| 25 | 29 |
| 26 #if defined(OS_CHROMEOS) | 30 #if defined(OS_CHROMEOS) |
| 27 #include "chrome/browser/chromeos/internet_page_view.h" | 31 #include "chrome/browser/chromeos/internet_page_view.h" |
| 28 #include "chrome/browser/chromeos/system_page_view.h" | 32 #include "chrome/browser/chromeos/system_page_view.h" |
| 29 #endif | 33 #endif |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 65 |
| 62 // The content page. | 66 // The content page. |
| 63 ContentPageGtk content_page_; | 67 ContentPageGtk content_page_; |
| 64 | 68 |
| 65 // The advanced (user data) page. | 69 // The advanced (user data) page. |
| 66 AdvancedPageGtk advanced_page_; | 70 AdvancedPageGtk advanced_page_; |
| 67 | 71 |
| 68 // The last page the user was on when they opened the Options window. | 72 // The last page the user was on when they opened the Options window. |
| 69 IntegerPrefMember last_selected_page_; | 73 IntegerPrefMember last_selected_page_; |
| 70 | 74 |
| 75 scoped_ptr<AccessibleWidgetHelper> accessibility_widget_helper_; |
| 76 |
| 71 DISALLOW_COPY_AND_ASSIGN(OptionsWindowGtk); | 77 DISALLOW_COPY_AND_ASSIGN(OptionsWindowGtk); |
| 72 }; | 78 }; |
| 73 | 79 |
| 74 // The singleton options window object. | 80 // The singleton options window object. |
| 75 static OptionsWindowGtk* options_window = NULL; | 81 static OptionsWindowGtk* options_window = NULL; |
| 76 | 82 |
| 77 /////////////////////////////////////////////////////////////////////////////// | 83 /////////////////////////////////////////////////////////////////////////////// |
| 78 // OptionsWindowGtk, public: | 84 // OptionsWindowGtk, public: |
| 79 | 85 |
| 80 OptionsWindowGtk::OptionsWindowGtk(Profile* profile) | 86 OptionsWindowGtk::OptionsWindowGtk(Profile* profile) |
| 81 // Always show preferences for the original profile. Most state when off | 87 // Always show preferences for the original profile. Most state when off |
| 82 // the record comes from the original profile, but we explicitly use | 88 // the record comes from the original profile, but we explicitly use |
| 83 // the original profile to avoid potential problems. | 89 // the original profile to avoid potential problems. |
| 84 : profile_(profile->GetOriginalProfile()), | 90 : profile_(profile->GetOriginalProfile()), |
| 85 general_page_(profile_), | 91 general_page_(profile_), |
| 86 content_page_(profile_), | 92 content_page_(profile_), |
| 87 advanced_page_(profile_) { | 93 advanced_page_(profile_) { |
| 94 |
| 88 // We don't need to observe changes in this value. | 95 // We don't need to observe changes in this value. |
| 89 last_selected_page_.Init(prefs::kOptionsWindowLastTabIndex, | 96 last_selected_page_.Init(prefs::kOptionsWindowLastTabIndex, |
| 90 g_browser_process->local_state(), NULL); | 97 g_browser_process->local_state(), NULL); |
| 91 | 98 |
| 92 dialog_ = gtk_dialog_new_with_buttons( | 99 dialog_ = gtk_dialog_new_with_buttons( |
| 93 l10n_util::GetStringFUTF8(IDS_OPTIONS_DIALOG_TITLE, | 100 l10n_util::GetStringFUTF8(IDS_OPTIONS_DIALOG_TITLE, |
| 94 WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))).c_str(), | 101 WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))).c_str(), |
| 95 // Prefs window is shared between all browser windows. | 102 // Prefs window is shared between all browser windows. |
| 96 NULL, | 103 NULL, |
| 97 // Non-modal. | 104 // Non-modal. |
| 98 GTK_DIALOG_NO_SEPARATOR, | 105 GTK_DIALOG_NO_SEPARATOR, |
| 99 GTK_STOCK_CLOSE, | 106 GTK_STOCK_CLOSE, |
| 100 GTK_RESPONSE_CLOSE, | 107 GTK_RESPONSE_CLOSE, |
| 101 NULL); | 108 NULL); |
| 102 gtk_window_set_default_size(GTK_WINDOW(dialog_), 500, -1); | 109 gtk_window_set_default_size(GTK_WINDOW(dialog_), 500, -1); |
| 103 // Allow browser windows to go in front of the options dialog in metacity. | 110 // Allow browser windows to go in front of the options dialog in metacity. |
| 104 gtk_window_set_type_hint(GTK_WINDOW(dialog_), GDK_WINDOW_TYPE_HINT_NORMAL); | 111 gtk_window_set_type_hint(GTK_WINDOW(dialog_), GDK_WINDOW_TYPE_HINT_NORMAL); |
| 105 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox), | 112 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox), |
| 106 gtk_util::kContentAreaSpacing); | 113 gtk_util::kContentAreaSpacing); |
| 107 | 114 |
| 115 accessibility_widget_helper_.reset(new AccessibleWidgetHelper( |
| 116 dialog_, profile)); |
| 117 |
| 108 notebook_ = gtk_notebook_new(); | 118 notebook_ = gtk_notebook_new(); |
| 109 | 119 |
| 110 #if defined(OS_CHROMEOS) | 120 #if defined(OS_CHROMEOS) |
| 111 gtk_notebook_append_page( | 121 gtk_notebook_append_page( |
| 112 GTK_NOTEBOOK(notebook_), | 122 GTK_NOTEBOOK(notebook_), |
| 113 (new chromeos::SystemPageView(profile_))->WrapInGtkWidget(), | 123 (new chromeos::SystemPageView(profile_))->WrapInGtkWidget(), |
| 114 gtk_label_new( | 124 gtk_label_new( |
| 115 l10n_util::GetStringUTF8(IDS_OPTIONS_SYSTEM_TAB_LABEL).c_str())); | 125 l10n_util::GetStringUTF8(IDS_OPTIONS_SYSTEM_TAB_LABEL).c_str())); |
| 116 | 126 |
| 117 gtk_notebook_append_page( | 127 gtk_notebook_append_page( |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 MessageLoop::current()->DeleteSoon(FROM_HERE, window); | 251 MessageLoop::current()->DeleteSoon(FROM_HERE, window); |
| 242 } | 252 } |
| 243 | 253 |
| 244 /////////////////////////////////////////////////////////////////////////////// | 254 /////////////////////////////////////////////////////////////////////////////// |
| 245 // Factory/finder method: | 255 // Factory/finder method: |
| 246 | 256 |
| 247 void ShowOptionsWindow(OptionsPage page, | 257 void ShowOptionsWindow(OptionsPage page, |
| 248 OptionsGroup highlight_group, | 258 OptionsGroup highlight_group, |
| 249 Profile* profile) { | 259 Profile* profile) { |
| 250 DCHECK(profile); | 260 DCHECK(profile); |
| 261 |
| 251 // If there's already an existing options window, activate it and switch to | 262 // If there's already an existing options window, activate it and switch to |
| 252 // the specified page. | 263 // the specified page. |
| 253 if (!options_window) { | 264 if (!options_window) { |
| 265 // Creating and initializing a bunch of controls generates a bunch of |
| 266 // spurious events as control values change. Temporarily suppress |
| 267 // accessibility events until the window is created. |
| 268 profile->PauseAccessibilityEvents(); |
| 269 |
| 270 // Create the options window. |
| 254 options_window = new OptionsWindowGtk(profile); | 271 options_window = new OptionsWindowGtk(profile); |
| 272 |
| 273 // Resume accessibility events. |
| 274 profile->ResumeAccessibilityEvents(); |
| 255 } | 275 } |
| 256 options_window->ShowOptionsPage(page, highlight_group); | 276 options_window->ShowOptionsPage(page, highlight_group); |
| 277 |
| 278 std::string name = l10n_util::GetStringFUTF8( |
| 279 IDS_OPTIONS_DIALOG_TITLE, |
| 280 WideToUTF16(l10n_util::GetString(IDS_PRODUCT_NAME))); |
| 281 AccessibilityWindowInfo info(profile, name); |
| 282 |
| 283 NotificationService::current()->Notify( |
| 284 NotificationType::ACCESSIBILITY_WINDOW_OPENED, |
| 285 Source<Profile>(profile), |
| 286 Details<AccessibilityWindowInfo>(&info)); |
| 257 } | 287 } |
| OLD | NEW |