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

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

Issue 214011: Remove the theme popup menu and just have a reset button to match the other p... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/cocoa/preferences_window_controller.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #import "chrome/browser/cocoa/preferences_window_controller.h" 5 #import "chrome/browser/cocoa/preferences_window_controller.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/mac_util.h" 8 #include "base/mac_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 634
635 // Called to clear user's browsing data. This puts up an application-modal 635 // Called to clear user's browsing data. This puts up an application-modal
636 // dialog to guide the user through clearing the data. 636 // dialog to guide the user through clearing the data.
637 - (IBAction)clearData:(id)sender { 637 - (IBAction)clearData:(id)sender {
638 scoped_nsobject<ClearBrowsingDataController> controller( 638 scoped_nsobject<ClearBrowsingDataController> controller(
639 [[ClearBrowsingDataController alloc] 639 [[ClearBrowsingDataController alloc]
640 initWithProfile:profile_]); 640 initWithProfile:profile_]);
641 [controller runModalDialog]; 641 [controller runModalDialog];
642 } 642 }
643 643
644 - (NSArray*)availableThemes { 644 - (IBAction)resetThemeToDefault:(id)sender {
645 const ExtensionList* extensions = 645 [self recordUserAction:L"Options_ThemesReset"];
646 profile_->GetExtensionsService()->extensions(); 646 profile_->ClearTheme();
647
648 NSMutableArray* themes = [NSMutableArray array];
649
650 for (size_t i = 0; i < extensions->size(); ++i) {
651 Extension* extension = extensions->at(i);
652 if (!extension->IsTheme())
653 continue;
654
655 NSDictionary* theme =
656 [NSDictionary dictionaryWithObjectsAndKeys:
657 [NSString stringWithUTF8String:extension->name().c_str()], @"name",
658 [NSString stringWithUTF8String:extension->id().c_str()], @"id",
659 nil];
660 [themes addObject:theme];
661 }
662
663 NSSortDescriptor* sortDescriptor =
664 [[[NSSortDescriptor alloc] initWithKey:@"name"
665 ascending:YES
666 selector:@selector(localizedCompare:)]
667 autorelease];
668
669 [themes sortUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
670
671 NSMutableArray* themeNames = [NSMutableArray array];
672 NSMutableArray* themeIds = [NSMutableArray array];
673
674 for (NSDictionary* themeDict in themes) {
675 [themeNames addObject:[themeDict objectForKey:@"name"]];
676 [themeIds addObject:[themeDict objectForKey:@"id"]];
677 }
678
679 themeMenuOffset_ = 0;
680 if ([themeNames count] > 0) {
681 [themeNames insertObject:@"-" atIndex:0];
682 ++themeMenuOffset_;
683 }
684 NSString* defaultLabel =
685 [NSString stringWithUTF8String:
686 l10n_util::GetStringUTF8(IDS_THEMES_DEFAULT_THEME_LABEL).c_str()];
687 [themeNames insertObject:defaultLabel atIndex:0];
688 ++themeMenuOffset_;
689
690 themeIds_.reset([themeIds retain]);
691 return themeNames;
692 }
693
694 - (int)currentTheme {
695 const Extension* theme = profile_->GetTheme();
696
697 if (theme) {
698 NSString* themeId = [NSString stringWithUTF8String:theme->id().c_str()];
699 return [themeIds_.get() indexOfObject:themeId] + themeMenuOffset_;
700 }
701
702 return 0;
703 }
704
705 - (void)setCurrentTheme:(int)newTheme {
706 newTheme -= themeMenuOffset_;
707
708 if (newTheme < 0) {
709 [self recordUserAction:L"Options_ThemesReset"];
710 profile_->ClearTheme();
711 } else {
712 NSString* themeId = [themeIds_.get() objectAtIndex:newTheme];
713 Extension* extension =
714 profile_->GetExtensionsService()->
715 GetExtensionById([themeId UTF8String]);
716 profile_->SetTheme(extension);
717 }
718 } 647 }
719 648
720 - (IBAction)themesGallery:(id)sender { 649 - (IBAction)themesGallery:(id)sender {
721 [self recordUserAction:L"Options_ThemesGallery"]; 650 [self recordUserAction:L"Options_ThemesGallery"];
722 Browser* browser = 651 Browser* browser =
723 BrowserList::FindBrowserWithType(profile_, Browser::TYPE_NORMAL); 652 BrowserList::FindBrowserWithType(profile_, Browser::TYPE_NORMAL);
724 653
725 if (!browser || !browser->GetSelectedTabContents()) { 654 if (!browser || !browser->GetSelectedTabContents()) {
726 browser = Browser::Create(profile_); 655 browser = Browser::Create(profile_);
727 browser->OpenURL( 656 browser->OpenURL(
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 [[NSNotificationCenter defaultCenter] 879 [[NSNotificationCenter defaultCenter]
951 postNotificationName:kUserDoneEditingPrefsNotification 880 postNotificationName:kUserDoneEditingPrefsNotification
952 object:self]; 881 object:self];
953 } 882 }
954 883
955 - (void)controlTextDidEndEditing:(NSNotification*)notification { 884 - (void)controlTextDidEndEditing:(NSNotification*)notification {
956 [customPagesSource_ validateURLs]; 885 [customPagesSource_ validateURLs];
957 } 886 }
958 887
959 @end 888 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/preferences_window_controller.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698