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

Side by Side Diff: chrome/browser/platform_util_mac.mm

Issue 1745024: Make a new yes/no messagebox wrapper function, use it in the bookmark alert.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
Property Changes:
Name: svn:mergeinfo
+
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 #include "chrome/browser/platform_util.h" 5 #include "chrome/browser/platform_util.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // A reasonable approximation of how you'd expect this to behave. 56 // A reasonable approximation of how you'd expect this to behave.
57 return (view && 57 return (view &&
58 ![view isHiddenOrHasHiddenAncestor] && 58 ![view isHiddenOrHasHiddenAncestor] &&
59 [view window] && 59 [view window] &&
60 [[view window] isVisible]); 60 [[view window] isVisible]);
61 } 61 }
62 62
63 void SimpleErrorBox(gfx::NativeWindow parent, 63 void SimpleErrorBox(gfx::NativeWindow parent,
64 const string16& title, 64 const string16& title,
65 const string16& message) { 65 const string16& message) {
66 // Ignore the title; it's the window title on other platforms and ignorable.
66 NSAlert* alert = [[[NSAlert alloc] init] autorelease]; 67 NSAlert* alert = [[[NSAlert alloc] init] autorelease];
67 [alert addButtonWithTitle:l10n_util::GetNSString(IDS_OK)]; 68 [alert addButtonWithTitle:l10n_util::GetNSString(IDS_OK)];
68 [alert setMessageText:base::SysUTF16ToNSString(title)]; 69 [alert setMessageText:base::SysUTF16ToNSString(message)];
69 [alert setInformativeText:base::SysUTF16ToNSString(message)];
70 [alert setAlertStyle:NSWarningAlertStyle]; 70 [alert setAlertStyle:NSWarningAlertStyle];
71 [alert runModal]; 71 [alert runModal];
72 } 72 }
73 73
74 bool SimpleYesNoBox(gfx::NativeWindow parent,
75 const string16& title,
76 const string16& message) {
77 // Ignore the title; it's the window title on other platforms and ignorable.
78 NSAlert* alert = [[[NSAlert alloc] init] autorelease];
79 [alert setMessageText:base::SysUTF16ToNSString(message)];
80 [alert setAlertStyle:NSWarningAlertStyle];
81
82 [alert addButtonWithTitle:
83 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_YES_BUTTON_LABEL)];
84 [alert addButtonWithTitle:
85 l10n_util::GetNSString(IDS_CONFIRM_MESSAGEBOX_NO_BUTTON_LABEL)];
86
87 NSInteger result = [alert runModal];
88 return result == NSAlertFirstButtonReturn;
89 }
90
74 string16 GetVersionStringModifier() { 91 string16 GetVersionStringModifier() {
75 #if defined(GOOGLE_CHROME_BUILD) 92 #if defined(GOOGLE_CHROME_BUILD)
76 // Use the main application bundle and not the framework bundle. Keystone 93 // Use the main application bundle and not the framework bundle. Keystone
77 // keys don't live in the framework. 94 // keys don't live in the framework.
78 NSBundle* bundle = [NSBundle mainBundle]; 95 NSBundle* bundle = [NSBundle mainBundle];
79 NSString* channel = [bundle objectForInfoDictionaryKey:@"KSChannelID"]; 96 NSString* channel = [bundle objectForInfoDictionaryKey:@"KSChannelID"];
80 97
81 // Only ever return "", "unknown", "beta" or "dev" in a branded build. 98 // Only ever return "", "unknown", "beta" or "dev" in a branded build.
82 if (![bundle objectForInfoDictionaryKey:@"KSProductID"]) { 99 if (![bundle objectForInfoDictionaryKey:@"KSProductID"]) {
83 // This build is not Keystone-enabled, it can't have a channel. 100 // This build is not Keystone-enabled, it can't have a channel.
84 channel = @"unknown"; 101 channel = @"unknown";
85 } else if (!channel) { 102 } else if (!channel) {
86 // For the stable channel, KSChannelID is not set. 103 // For the stable channel, KSChannelID is not set.
87 channel = @""; 104 channel = @"";
88 } else if ([channel isEqual:@"beta"] || [channel isEqual:@"dev"]) { 105 } else if ([channel isEqual:@"beta"] || [channel isEqual:@"dev"]) {
89 // do nothing. 106 // do nothing.
90 } else { 107 } else {
91 channel = @"unknown"; 108 channel = @"unknown";
92 } 109 }
93 110
94 return base::SysNSStringToUTF16(channel); 111 return base::SysNSStringToUTF16(channel);
95 #else 112 #else
96 return string16(); 113 return string16();
97 #endif 114 #endif
98 } 115 }
99 116
100 } // namespace platform_util 117 } // namespace platform_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698