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

Side by Side Diff: chrome/browser/ui/webui/settings_utils_mac.mm

Issue 2927273002: Move code for old, deprecated Options UI to only ChromeOS (Closed)
Patch Set: thestig@ and tests Created 3 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "chrome/browser/ui/webui/settings_utils.h" 7 #include "chrome/browser/ui/webui/settings_utils.h"
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/mac/mac_logging.h" 10 #include "base/mac/mac_logging.h"
11 #include "base/mac/scoped_aedesc.h" 11 #include "base/mac/scoped_aedesc.h"
12 #include "base/mac/scoped_nsautorelease_pool.h"
13 #include "base/strings/sys_string_conversions.h"
14 #include "chrome/common/pref_names.h"
15 #include "components/prefs/pref_service.h"
16
17 namespace {
18 void ValidateFontFamily(PrefService* prefs, const char* family_pref_name) {
19 // The native font settings dialog saved fonts by the font name, rather
20 // than the family name. This worked for the old dialog since
21 // -[NSFont fontWithName:size] accepted a font or family name, but the
22 // behavior was technically wrong. Since we really need the family name for
23 // the webui settings window, we will fix the saved preference if necessary.
24 NSString* family_name =
25 base::SysUTF8ToNSString(prefs->GetString(family_pref_name));
26 NSFont* font = [NSFont fontWithName:family_name size:[NSFont systemFontSize]];
27 if (font &&
28 [[font familyName] caseInsensitiveCompare:family_name] != NSOrderedSame) {
29 std::string new_family_name = base::SysNSStringToUTF8([font familyName]);
30 prefs->SetString(family_pref_name, new_family_name);
31 }
32 }
33 }
Lei Zhang 2017/06/09 06:47:01 } // namespace
Dan Beam 2017/06/09 06:49:21 Done.
12 34
13 namespace settings_utils { 35 namespace settings_utils {
14 36
15 void ShowNetworkProxySettings(content::WebContents* web_contents) { 37 void ShowNetworkProxySettings(content::WebContents* web_contents) {
16 NSArray* itemsToOpen = [NSArray arrayWithObject:[NSURL fileURLWithPath: 38 NSArray* itemsToOpen = [NSArray arrayWithObject:[NSURL fileURLWithPath:
17 @"/System/Library/PreferencePanes/Network.prefPane"]]; 39 @"/System/Library/PreferencePanes/Network.prefPane"]];
18 40
19 const char* proxyPrefCommand = "Proxies"; 41 const char* proxyPrefCommand = "Proxies";
20 base::mac::ScopedAEDesc<> openParams; 42 base::mac::ScopedAEDesc<> openParams;
21 OSStatus status = AECreateDesc('ptru', 43 OSStatus status = AECreateDesc('ptru',
(...skipping 12 matching lines...) Expand all
34 56
35 void ShowManageSSLCertificates(content::WebContents* web_contents) { 57 void ShowManageSSLCertificates(content::WebContents* web_contents) {
36 NSString* const kKeychainBundleId = @"com.apple.keychainaccess"; 58 NSString* const kKeychainBundleId = @"com.apple.keychainaccess";
37 [[NSWorkspace sharedWorkspace] 59 [[NSWorkspace sharedWorkspace]
38 launchAppWithBundleIdentifier:kKeychainBundleId 60 launchAppWithBundleIdentifier:kKeychainBundleId
39 options:0L 61 options:0L
40 additionalEventParamDescriptor:nil 62 additionalEventParamDescriptor:nil
41 launchIdentifier:nil]; 63 launchIdentifier:nil];
42 } 64 }
43 65
66 void ValidateSavedFonts(PrefService* prefs) {
67 ValidateFontFamily(prefs, prefs::kWebKitSerifFontFamily);
68 ValidateFontFamily(prefs, prefs::kWebKitSansSerifFontFamily);
69 ValidateFontFamily(prefs, prefs::kWebKitFixedFontFamily);
70 }
71
44 } // namespace settings_utils 72 } // namespace settings_utils
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/settings_utils.cc ('k') | chrome/browser/ui/webui/settings_utils_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698