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

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: font utils 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 "base/values.h"
Lei Zhang 2017/06/09 04:22:54 Not needed?
Dan Beam 2017/06/09 06:32:55 Done.
15 #include "chrome/common/pref_names.h"
16 #include "components/prefs/pref_service.h"
17
18 namespace {
19
20 void ValidateFontFamily(PrefService* prefs, const char* family_pref_name) {
21 // The native font settings dialog saved fonts by the font name, rather
22 // than the family name. This worked for the old dialog since
23 // -[NSFont fontWithName:size] accepted a font or family name, but the
24 // behavior was technically wrong. Since we really need the family name for
25 // the webui settings window, we will fix the saved preference if necessary.
26 NSString* family_name =
27 base::SysUTF8ToNSString(prefs->GetString(family_pref_name));
28 NSFont* font = [NSFont fontWithName:family_name size:[NSFont systemFontSize]];
29 if (font &&
30 [[font familyName] caseInsensitiveCompare:family_name] != NSOrderedSame) {
31 std::string new_family_name = base::SysNSStringToUTF8([font familyName]);
32 prefs->SetString(family_pref_name, new_family_name);
33 }
34 }
35
36 }
12 37
13 namespace settings_utils { 38 namespace settings_utils {
14 39
15 void ShowNetworkProxySettings(content::WebContents* web_contents) { 40 void ShowNetworkProxySettings(content::WebContents* web_contents) {
16 NSArray* itemsToOpen = [NSArray arrayWithObject:[NSURL fileURLWithPath: 41 NSArray* itemsToOpen = [NSArray arrayWithObject:[NSURL fileURLWithPath:
17 @"/System/Library/PreferencePanes/Network.prefPane"]]; 42 @"/System/Library/PreferencePanes/Network.prefPane"]];
18 43
19 const char* proxyPrefCommand = "Proxies"; 44 const char* proxyPrefCommand = "Proxies";
20 base::mac::ScopedAEDesc<> openParams; 45 base::mac::ScopedAEDesc<> openParams;
21 OSStatus status = AECreateDesc('ptru', 46 OSStatus status = AECreateDesc('ptru',
(...skipping 12 matching lines...) Expand all
34 59
35 void ShowManageSSLCertificates(content::WebContents* web_contents) { 60 void ShowManageSSLCertificates(content::WebContents* web_contents) {
36 NSString* const kKeychainBundleId = @"com.apple.keychainaccess"; 61 NSString* const kKeychainBundleId = @"com.apple.keychainaccess";
37 [[NSWorkspace sharedWorkspace] 62 [[NSWorkspace sharedWorkspace]
38 launchAppWithBundleIdentifier:kKeychainBundleId 63 launchAppWithBundleIdentifier:kKeychainBundleId
39 options:0L 64 options:0L
40 additionalEventParamDescriptor:nil 65 additionalEventParamDescriptor:nil
41 launchIdentifier:nil]; 66 launchIdentifier:nil];
42 } 67 }
43 68
69 void ValidateSavedFonts(PrefService* prefs) {
70 ValidateFontFamily(prefs, prefs::kWebKitSerifFontFamily);
71 ValidateFontFamily(prefs, prefs::kWebKitSansSerifFontFamily);
72 ValidateFontFamily(prefs, prefs::kWebKitFixedFontFamily);
73 }
74
44 } // namespace settings_utils 75 } // namespace settings_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698