| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/preferences_window_controller.h" | 5 #import "chrome/browser/cocoa/preferences_window_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/l10n_util_mac.h" | 10 #include "app/l10n_util_mac.h" |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 - (void)setPasswordManagerEnabledIndex:(NSInteger)value; | 335 - (void)setPasswordManagerEnabledIndex:(NSInteger)value; |
| 336 - (void)setFormAutofillEnabledIndex:(NSInteger)value; | 336 - (void)setFormAutofillEnabledIndex:(NSInteger)value; |
| 337 - (void)setIsUsingDefaultTheme:(BOOL)value; | 337 - (void)setIsUsingDefaultTheme:(BOOL)value; |
| 338 - (void)setShowAlternateErrorPages:(BOOL)value; | 338 - (void)setShowAlternateErrorPages:(BOOL)value; |
| 339 - (void)setUseSuggest:(BOOL)value; | 339 - (void)setUseSuggest:(BOOL)value; |
| 340 - (void)setDnsPrefetch:(BOOL)value; | 340 - (void)setDnsPrefetch:(BOOL)value; |
| 341 - (void)setSafeBrowsing:(BOOL)value; | 341 - (void)setSafeBrowsing:(BOOL)value; |
| 342 - (void)setMetricsRecording:(BOOL)value; | 342 - (void)setMetricsRecording:(BOOL)value; |
| 343 - (void)setAskForSaveLocation:(BOOL)value; | 343 - (void)setAskForSaveLocation:(BOOL)value; |
| 344 - (void)setTranslateEnabled:(BOOL)value; | 344 - (void)setTranslateEnabled:(BOOL)value; |
| 345 - (void)setTabsToLinks:(BOOL)value; |
| 345 - (void)displayPreferenceViewForPage:(OptionsPage)page | 346 - (void)displayPreferenceViewForPage:(OptionsPage)page |
| 346 animate:(BOOL)animate; | 347 animate:(BOOL)animate; |
| 347 @end | 348 @end |
| 348 | 349 |
| 349 namespace PreferencesWindowControllerInternal { | 350 namespace PreferencesWindowControllerInternal { |
| 350 | 351 |
| 351 // A C++ class registered for changes in preferences. Bridges the | 352 // A C++ class registered for changes in preferences. Bridges the |
| 352 // notification back to the PWC. | 353 // notification back to the PWC. |
| 353 class PrefObserverBridge : public NotificationObserver, | 354 class PrefObserverBridge : public NotificationObserver, |
| 354 public ProfileSyncServiceObserver { | 355 public ProfileSyncServiceObserver { |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 formAutofill_.Init(prefs::kAutoFillEnabled, prefs_, observer_.get()); | 692 formAutofill_.Init(prefs::kAutoFillEnabled, prefs_, observer_.get()); |
| 692 currentTheme_.Init(prefs::kCurrentThemeID, prefs_, observer_.get()); | 693 currentTheme_.Init(prefs::kCurrentThemeID, prefs_, observer_.get()); |
| 693 | 694 |
| 694 // Under the hood panel | 695 // Under the hood panel |
| 695 alternateErrorPages_.Init(prefs::kAlternateErrorPagesEnabled, | 696 alternateErrorPages_.Init(prefs::kAlternateErrorPagesEnabled, |
| 696 prefs_, observer_.get()); | 697 prefs_, observer_.get()); |
| 697 useSuggest_.Init(prefs::kSearchSuggestEnabled, prefs_, observer_.get()); | 698 useSuggest_.Init(prefs::kSearchSuggestEnabled, prefs_, observer_.get()); |
| 698 dnsPrefetch_.Init(prefs::kDnsPrefetchingEnabled, prefs_, observer_.get()); | 699 dnsPrefetch_.Init(prefs::kDnsPrefetchingEnabled, prefs_, observer_.get()); |
| 699 safeBrowsing_.Init(prefs::kSafeBrowsingEnabled, prefs_, observer_.get()); | 700 safeBrowsing_.Init(prefs::kSafeBrowsingEnabled, prefs_, observer_.get()); |
| 700 translateEnabled_.Init(prefs::kEnableTranslate, prefs_, observer_.get()); | 701 translateEnabled_.Init(prefs::kEnableTranslate, prefs_, observer_.get()); |
| 702 tabsToLinks_.Init(prefs::kWebkitTabsToLinks, prefs_, observer_.get()); |
| 701 | 703 |
| 702 // During unit tests, there is no local state object, so we fall back to | 704 // During unit tests, there is no local state object, so we fall back to |
| 703 // the prefs object (where we've explicitly registered this pref so we | 705 // the prefs object (where we've explicitly registered this pref so we |
| 704 // know it's there). | 706 // know it's there). |
| 705 PrefService* local = g_browser_process->local_state(); | 707 PrefService* local = g_browser_process->local_state(); |
| 706 if (!local) | 708 if (!local) |
| 707 local = prefs_; | 709 local = prefs_; |
| 708 metricsRecording_.Init(prefs::kMetricsReportingEnabled, | 710 metricsRecording_.Init(prefs::kMetricsReportingEnabled, |
| 709 local, observer_.get()); | 711 local, observer_.get()); |
| 710 defaultDownloadLocation_.Init(prefs::kDownloadDefaultDirectory, prefs_, | 712 defaultDownloadLocation_.Init(prefs::kDownloadDefaultDirectory, prefs_, |
| (...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 [self setSafeBrowsing:safeBrowsing_.GetValue() ? YES : NO]; | 1312 [self setSafeBrowsing:safeBrowsing_.GetValue() ? YES : NO]; |
| 1311 } | 1313 } |
| 1312 else if (*prefName == prefs::kMetricsReportingEnabled) { | 1314 else if (*prefName == prefs::kMetricsReportingEnabled) { |
| 1313 [self setMetricsRecording:metricsRecording_.GetValue() ? YES : NO]; | 1315 [self setMetricsRecording:metricsRecording_.GetValue() ? YES : NO]; |
| 1314 } | 1316 } |
| 1315 else if (*prefName == prefs::kPromptForDownload) { | 1317 else if (*prefName == prefs::kPromptForDownload) { |
| 1316 [self setAskForSaveLocation:askForSaveLocation_.GetValue() ? YES : NO]; | 1318 [self setAskForSaveLocation:askForSaveLocation_.GetValue() ? YES : NO]; |
| 1317 } | 1319 } |
| 1318 else if (*prefName == prefs::kEnableTranslate) { | 1320 else if (*prefName == prefs::kEnableTranslate) { |
| 1319 [self setTranslateEnabled:translateEnabled_.GetValue() ? YES : NO]; | 1321 [self setTranslateEnabled:translateEnabled_.GetValue() ? YES : NO]; |
| 1322 } else if (*prefName == prefs::kWebkitTabsToLinks) { |
| 1323 [self setTabsToLinks:tabsToLinks_.GetValue() ? YES : NO]; |
| 1320 } | 1324 } |
| 1321 } | 1325 } |
| 1322 | 1326 |
| 1323 // Set the new download path and notify the UI via KVO. | 1327 // Set the new download path and notify the UI via KVO. |
| 1324 - (void)downloadPathPanelDidEnd:(NSOpenPanel*)panel | 1328 - (void)downloadPathPanelDidEnd:(NSOpenPanel*)panel |
| 1325 code:(NSInteger)returnCode | 1329 code:(NSInteger)returnCode |
| 1326 context:(void*)context { | 1330 context:(void*)context { |
| 1327 if (returnCode == NSOKButton) { | 1331 if (returnCode == NSOKButton) { |
| 1328 [self recordUserAction:UserMetricsAction("Options_SetDownloadDirectory")]; | 1332 [self recordUserAction:UserMetricsAction("Options_SetDownloadDirectory")]; |
| 1329 NSURL* path = [[panel URLs] lastObject]; // We only allow 1 item. | 1333 NSURL* path = [[panel URLs] lastObject]; // We only allow 1 item. |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1541 | 1545 |
| 1542 - (void)setTranslateEnabled:(BOOL)value { | 1546 - (void)setTranslateEnabled:(BOOL)value { |
| 1543 if (value) { | 1547 if (value) { |
| 1544 [self recordUserAction:UserMetricsAction("Options_Translate_Enable")]; | 1548 [self recordUserAction:UserMetricsAction("Options_Translate_Enable")]; |
| 1545 } else { | 1549 } else { |
| 1546 [self recordUserAction:UserMetricsAction("Options_Translate_Disable")]; | 1550 [self recordUserAction:UserMetricsAction("Options_Translate_Disable")]; |
| 1547 } | 1551 } |
| 1548 translateEnabled_.SetValue(value); | 1552 translateEnabled_.SetValue(value); |
| 1549 } | 1553 } |
| 1550 | 1554 |
| 1555 - (BOOL)tabsToLinks { |
| 1556 return tabsToLinks_.GetValue(); |
| 1557 } |
| 1558 |
| 1559 - (void)setTabsToLinks:(BOOL)value { |
| 1560 if (value) { |
| 1561 [self recordUserAction:UserMetricsAction("Options_TabsToLinks_Enable")]; |
| 1562 } else { |
| 1563 [self recordUserAction:UserMetricsAction("Options_TabsToLinks_Disable")]; |
| 1564 } |
| 1565 tabsToLinks_.SetValue(value); |
| 1566 } |
| 1567 |
| 1551 - (void)fontAndLanguageEndSheet:(NSWindow*)sheet | 1568 - (void)fontAndLanguageEndSheet:(NSWindow*)sheet |
| 1552 returnCode:(NSInteger)returnCode | 1569 returnCode:(NSInteger)returnCode |
| 1553 contextInfo:(void*)context { | 1570 contextInfo:(void*)context { |
| 1554 [sheet close]; | 1571 [sheet close]; |
| 1555 [sheet orderOut:self]; | 1572 [sheet orderOut:self]; |
| 1556 fontLanguageSettings_ = nil; | 1573 fontLanguageSettings_ = nil; |
| 1557 } | 1574 } |
| 1558 | 1575 |
| 1559 - (IBAction)changeFontAndLanguageSettings:(id)sender { | 1576 - (IBAction)changeFontAndLanguageSettings:(id)sender { |
| 1560 // Intentionally leak the controller as it will clean itself up when the | 1577 // Intentionally leak the controller as it will clean itself up when the |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1865 case OPTIONS_PAGE_ADVANCED: | 1882 case OPTIONS_PAGE_ADVANCED: |
| 1866 return underTheHoodView_; | 1883 return underTheHoodView_; |
| 1867 case OPTIONS_PAGE_DEFAULT: | 1884 case OPTIONS_PAGE_DEFAULT: |
| 1868 case OPTIONS_PAGE_COUNT: | 1885 case OPTIONS_PAGE_COUNT: |
| 1869 LOG(DFATAL) << "Invalid page value " << page; | 1886 LOG(DFATAL) << "Invalid page value " << page; |
| 1870 } | 1887 } |
| 1871 return basicsView_; | 1888 return basicsView_; |
| 1872 } | 1889 } |
| 1873 | 1890 |
| 1874 @end | 1891 @end |
| OLD | NEW |