Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: chrome/browser/cocoa/preferences_window_controller.mm

Issue 3038013: Disable proxy config button and show banner if proxy prefs are managed. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: fix nits Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 409
410 private: 410 private:
411 PreferencesWindowController* controller_; // weak, owns us 411 PreferencesWindowController* controller_; // weak, owns us
412 OptionsPage page_; // current options page 412 OptionsPage page_; // current options page
413 }; 413 };
414 414
415 } // namespace PreferencesWindowControllerInternal 415 } // namespace PreferencesWindowControllerInternal
416 416
417 @implementation PreferencesWindowController 417 @implementation PreferencesWindowController
418 418
419 @synthesize proxiesConfigureButtonEnabled = proxiesConfigureButtonEnabled_;
420
419 - (id)initWithProfile:(Profile*)profile initialPage:(OptionsPage)initialPage { 421 - (id)initWithProfile:(Profile*)profile initialPage:(OptionsPage)initialPage {
420 DCHECK(profile); 422 DCHECK(profile);
421 // Use initWithWindowNibPath:: instead of initWithWindowNibName: so we 423 // Use initWithWindowNibPath:: instead of initWithWindowNibName: so we
422 // can override it in a unit test. 424 // can override it in a unit test.
423 NSString* nibPath = [mac_util::MainAppBundle() 425 NSString* nibPath = [mac_util::MainAppBundle()
424 pathForResource:@"Preferences" 426 pathForResource:@"Preferences"
425 ofType:@"nib"]; 427 ofType:@"nib"];
426 if ((self = [super initWithWindowNibPath:nibPath owner:self])) { 428 if ((self = [super initWithWindowNibPath:nibPath owner:self])) {
427 profile_ = profile->GetOriginalProfile(); 429 profile_ = profile->GetOriginalProfile();
428 initialPage_ = initialPage; 430 initialPage_ = initialPage;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 [[NSColor colorWithDeviceRed:0xff/255.0 478 [[NSColor colorWithDeviceRed:0xff/255.0
477 green:0x9a/255.0 479 green:0x9a/255.0
478 blue:0x9a/255.0 480 blue:0x9a/255.0
479 alpha:1.0] retain]); 481 alpha:1.0] retain]);
480 482
481 // Disable the |autoFillSettingsButton_| if we have no 483 // Disable the |autoFillSettingsButton_| if we have no
482 // |personalDataManager|. 484 // |personalDataManager|.
483 PersonalDataManager* personalDataManager = 485 PersonalDataManager* personalDataManager =
484 profile_->GetPersonalDataManager(); 486 profile_->GetPersonalDataManager();
485 [autoFillSettingsButton_ setHidden:(personalDataManager == NULL)]; 487 [autoFillSettingsButton_ setHidden:(personalDataManager == NULL)];
488
489 // Initialize the proxy pref set observer.
490 proxyPrefs_.reset(
491 PrefSetObserver::CreateProxyPrefSetObserver(prefs_, observer_.get()));
492 [self setProxiesConfigureButtonEnabled:!proxyPrefs_->IsManaged()];
486 } 493 }
487 return self; 494 return self;
488 } 495 }
489 496
490 - (void)awakeFromNib { 497 - (void)awakeFromNib {
491 498
492 // Validate some assumptions in debug builds. 499 // Validate some assumptions in debug builds.
493 500
494 // "Basics", "Personal Stuff", and "Under the Hood" views should be the same 501 // "Basics", "Personal Stuff", and "Under the Hood" views should be the same
495 // width. They should be the same width so they are laid out to look as good 502 // width. They should be the same width so they are laid out to look as good
(...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 else if (*prefName == prefs::kEnableTranslate) { 1380 else if (*prefName == prefs::kEnableTranslate) {
1374 [self setTranslateEnabled:translateEnabled_.GetValue() ? YES : NO]; 1381 [self setTranslateEnabled:translateEnabled_.GetValue() ? YES : NO];
1375 } 1382 }
1376 else if (*prefName == prefs::kWebkitTabsToLinks) { 1383 else if (*prefName == prefs::kWebkitTabsToLinks) {
1377 [self setTabsToLinks:tabsToLinks_.GetValue() ? YES : NO]; 1384 [self setTabsToLinks:tabsToLinks_.GetValue() ? YES : NO];
1378 } 1385 }
1379 else if (*prefName == prefs::kDownloadExtensionsToOpen) { 1386 else if (*prefName == prefs::kDownloadExtensionsToOpen) {
1380 // Poke KVC. 1387 // Poke KVC.
1381 [self setFileHandlerUIEnabled:[self fileHandlerUIEnabled]]; 1388 [self setFileHandlerUIEnabled:[self fileHandlerUIEnabled]];
1382 } 1389 }
1390 else if (proxyPrefs_->IsObserved(*prefName)) {
1391 [self setProxiesConfigureButtonEnabled:!proxyPrefs_->IsManaged()];
1392 }
1383 } 1393 }
1384 1394
1385 // Set the new download path and notify the UI via KVO. 1395 // Set the new download path and notify the UI via KVO.
1386 - (void)downloadPathPanelDidEnd:(NSOpenPanel*)panel 1396 - (void)downloadPathPanelDidEnd:(NSOpenPanel*)panel
1387 code:(NSInteger)returnCode 1397 code:(NSInteger)returnCode
1388 context:(void*)context { 1398 context:(void*)context {
1389 if (returnCode == NSOKButton) { 1399 if (returnCode == NSOKButton) {
1390 [self recordUserAction:UserMetricsAction("Options_SetDownloadDirectory")]; 1400 [self recordUserAction:UserMetricsAction("Options_SetDownloadDirectory")];
1391 NSURL* path = [[panel URLs] lastObject]; // We only allow 1 item. 1401 NSURL* path = [[panel URLs] lastObject]; // We only allow 1 item.
1392 [self willChangeValueForKey:@"defaultDownloadLocation"]; 1402 [self willChangeValueForKey:@"defaultDownloadLocation"];
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
2056 case OPTIONS_PAGE_ADVANCED: 2066 case OPTIONS_PAGE_ADVANCED:
2057 return underTheHoodView_; 2067 return underTheHoodView_;
2058 case OPTIONS_PAGE_DEFAULT: 2068 case OPTIONS_PAGE_DEFAULT:
2059 case OPTIONS_PAGE_COUNT: 2069 case OPTIONS_PAGE_COUNT:
2060 LOG(DFATAL) << "Invalid page value " << page; 2070 LOG(DFATAL) << "Invalid page value " << page;
2061 } 2071 }
2062 return basicsView_; 2072 return basicsView_;
2063 } 2073 }
2064 2074
2065 @end 2075 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/preferences_window_controller.h ('k') | chrome/browser/gtk/options/advanced_contents_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698