diff options
author | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-21 20:55:05 +0000 |
---|---|---|
committer | lambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-03-21 20:55:05 +0000 |
commit | ef12d1e6acb871dbd01f330d0b10ada24d209371 (patch) | |
tree | 1b8976cebc4c141acb3e314406d662a7931a731b | |
parent | a160baecdd408a80a6861635a398011622f04718 (diff) | |
download | chromium_src-ef12d1e6acb871dbd01f330d0b10ada24d209371.zip chromium_src-ef12d1e6acb871dbd01f330d0b10ada24d209371.tar.gz chromium_src-ef12d1e6acb871dbd01f330d0b10ada24d209371.tar.bz2 |
Move authorization_util files into base/mac.
No logical code changes in this CL. This moves some Mac utilities from
chrome/browser/mac to base/mac, so they can be used by the Remoting Host
plugin code in remoting/host/plugin
BUG=None
TEST=Compiles, unit_tests run
Review URL: https://chromiumcodereview.appspot.com/9764013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@128053 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | base/base.gypi | 3 | ||||
-rw-r--r-- | base/mac/authorization_util.h (renamed from chrome/browser/mac/authorization_util.h) | 14 | ||||
-rw-r--r-- | base/mac/authorization_util.mm (renamed from chrome/browser/mac/authorization_util.mm) | 10 | ||||
-rw-r--r-- | base/mac/scoped_authorizationref.h (renamed from chrome/browser/mac/scoped_authorizationref.h) | 14 | ||||
-rw-r--r-- | chrome/browser/mac/install_from_dmg.mm | 12 | ||||
-rw-r--r-- | chrome/browser/mac/keystone_glue.h | 6 | ||||
-rw-r--r-- | chrome/browser/mac/keystone_glue.mm | 12 | ||||
-rwxr-xr-x | chrome/browser/mac/keystone_promote_postflight.sh | 4 | ||||
-rwxr-xr-x | chrome/browser/mac/keystone_promote_preflight.sh | 4 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 3 |
10 files changed, 46 insertions, 36 deletions
diff --git a/base/base.gypi b/base/base.gypi index 0c556f19..00f169e 100644 --- a/base/base.gypi +++ b/base/base.gypi @@ -147,6 +147,8 @@ 'logging.h', 'logging_win.cc', 'logging_win.h', + 'mac/authorization_util.h', + 'mac/authorization_util.mm', 'mac/bundle_locations.h', 'mac/bundle_locations.mm', 'mac/cocoa_protocols.h', @@ -163,6 +165,7 @@ 'mac/os_crash_dumps.cc', 'mac/os_crash_dumps.h', 'mac/scoped_aedesc.h', + 'mac/scoped_authorizationref.h', 'mac/scoped_cftyperef.h', 'mac/scoped_nsautorelease_pool.h', 'mac/scoped_nsautorelease_pool.mm', diff --git a/chrome/browser/mac/authorization_util.h b/base/mac/authorization_util.h index c25f0cb..c6a63c0 100644 --- a/chrome/browser/mac/authorization_util.h +++ b/base/mac/authorization_util.h @@ -1,9 +1,9 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_MAC_AUTHORIZATION_UTIL_H_ -#define CHROME_BROWSER_MAC_AUTHORIZATION_UTIL_H_ +#ifndef BASE_MAC_AUTHORIZATION_UTIL_H_ +#define BASE_MAC_AUTHORIZATION_UTIL_H_ #pragma once // AuthorizationExecuteWithPrivileges fork()s and exec()s the tool, but it @@ -29,7 +29,8 @@ #include <stdio.h> #include <sys/types.h> -namespace authorization_util { +namespace base { +namespace mac { // Obtains an AuthorizationRef that can be used to run commands as root. If // necessary, prompts the user for authentication. If the user is prompted, @@ -62,6 +63,7 @@ OSStatus ExecuteWithPrivilegesAndWait(AuthorizationRef authorization, FILE** pipe, int* exit_status); -} // namespace authorization_util +} // namespace mac +} // namespace base -#endif // CHROME_BROWSER_MAC_AUTHORIZATION_UTIL_H_ +#endif // BASE_MAC_AUTHORIZATION_UTIL_H_ diff --git a/chrome/browser/mac/authorization_util.mm b/base/mac/authorization_util.mm index 734ee7f..a9fac3e 100644 --- a/chrome/browser/mac/authorization_util.mm +++ b/base/mac/authorization_util.mm @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "chrome/browser/mac/authorization_util.h" +#include "base/mac/authorization_util.h" #import <Foundation/Foundation.h> #include <sys/wait.h> @@ -15,11 +15,12 @@ #include "base/mac/bundle_locations.h" #include "base/mac/mac_logging.h" #import "base/mac/mac_util.h" +#include "base/mac/scoped_authorizationref.h" #include "base/string_number_conversions.h" #include "base/string_util.h" -#include "chrome/browser/mac/scoped_authorizationref.h" -namespace authorization_util { +namespace base { +namespace mac { AuthorizationRef AuthorizationCreateToRunAsRoot(CFStringRef prompt) { // Create an empty AuthorizationRef. @@ -182,4 +183,5 @@ OSStatus ExecuteWithPrivilegesAndWait(AuthorizationRef authorization, return status; } -} // namespace authorization_util +} // namespace mac +} // namespace base diff --git a/chrome/browser/mac/scoped_authorizationref.h b/base/mac/scoped_authorizationref.h index fbe0b9d..28ebce9 100644 --- a/chrome/browser/mac/scoped_authorizationref.h +++ b/base/mac/scoped_authorizationref.h @@ -1,9 +1,9 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef CHROME_BROWSER_MAC_SCOPED_AUTHORIZATIONREF_H_ -#define CHROME_BROWSER_MAC_SCOPED_AUTHORIZATIONREF_H_ +#ifndef BASE_MAC_SCOPED_AUTHORIZATIONREF_H_ +#define BASE_MAC_SCOPED_AUTHORIZATIONREF_H_ #pragma once #include <Security/Authorization.h> @@ -14,6 +14,9 @@ // ScopedAuthorizationRef maintains ownership of an AuthorizationRef. It is // patterned after the scoped_ptr interface. +namespace base { +namespace mac { + class ScopedAuthorizationRef { public: explicit ScopedAuthorizationRef(AuthorizationRef authorization = NULL) @@ -77,4 +80,7 @@ class ScopedAuthorizationRef { DISALLOW_COPY_AND_ASSIGN(ScopedAuthorizationRef); }; -#endif // CHROME_BROWSER_MAC_SCOPED_AUTHORIZATIONREF_H_ +} // namespace mac +} // namespace base + +#endif // BASE_MAC_SCOPED_AUTHORIZATIONREF_H_ diff --git a/chrome/browser/mac/install_from_dmg.mm b/chrome/browser/mac/install_from_dmg.mm index 1d11ecd..dc6bca4 100644 --- a/chrome/browser/mac/install_from_dmg.mm +++ b/chrome/browser/mac/install_from_dmg.mm @@ -21,16 +21,16 @@ #include "base/command_line.h" #include "base/file_path.h" #include "base/logging.h" +#include "base/mac/authorization_util.h" #include "base/mac/bundle_locations.h" #include "base/mac/mac_logging.h" #import "base/mac/mac_util.h" +#include "base/mac/scoped_authorizationref.h" #include "base/mac/scoped_cftyperef.h" #include "base/mac/scoped_nsautorelease_pool.h" #include "base/string_util.h" #include "base/sys_string_conversions.h" -#include "chrome/browser/mac/authorization_util.h" #include "chrome/browser/mac/dock.h" -#include "chrome/browser/mac/scoped_authorizationref.h" #include "chrome/browser/mac/scoped_ioobject.h" #import "chrome/browser/mac/keystone_glue.h" #include "chrome/browser/mac/relauncher.h" @@ -279,7 +279,7 @@ AuthorizationRef MaybeShowAuthorizationDialog(NSString* application_directory) { NSString* prompt = l10n_util::GetNSStringFWithFixup( IDS_INSTALL_FROM_DMG_AUTHENTICATION_PROMPT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); - return authorization_util::AuthorizationCreateToRunAsRoot( + return base::mac::AuthorizationCreateToRunAsRoot( base::mac::NSToCFCast(prompt)); } @@ -292,7 +292,7 @@ bool InstallFromDiskImage(AuthorizationRef authorization_arg, NSString* installer_path, NSString* source_path, NSString* target_path) { - ScopedAuthorizationRef authorization(authorization_arg); + base::mac::ScopedAuthorizationRef authorization(authorization_arg); authorization_arg = NULL; int exit_status; if (authorization) { @@ -301,7 +301,7 @@ bool InstallFromDiskImage(AuthorizationRef authorization_arg, const char* target_path_c = [target_path fileSystemRepresentation]; const char* arguments[] = {source_path_c, target_path_c, NULL}; - OSStatus status = authorization_util::ExecuteWithPrivilegesAndWait( + OSStatus status = base::mac::ExecuteWithPrivilegesAndWait( authorization, installer_path_c, kAuthorizationFlagDefaults, @@ -448,7 +448,7 @@ bool MaybeInstallFromDiskImage() { return false; } - ScopedAuthorizationRef authorization( + base::mac::ScopedAuthorizationRef authorization( MaybeShowAuthorizationDialog(application_directory)); // authorization will be NULL if it's deemed unnecessary or if // authentication fails. In either case, try to install without privilege diff --git a/chrome/browser/mac/keystone_glue.h b/chrome/browser/mac/keystone_glue.h index c57219b..755b408d 100644 --- a/chrome/browser/mac/keystone_glue.h +++ b/chrome/browser/mac/keystone_glue.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -12,8 +12,8 @@ #import <Foundation/Foundation.h> +#include "base/mac/scoped_authorizationref.h" #import "base/memory/scoped_nsobject.h" -#include "chrome/browser/mac/scoped_authorizationref.h" // Possible outcomes of various operations. A version may accompany some of // these, but beware: a version is never required. For statuses that can be @@ -94,7 +94,7 @@ enum BrandFileType { // The authorization object, when it needs to persist because it's being // carried across threads. - ScopedAuthorizationRef authorization_; + base::mac::ScopedAuthorizationRef authorization_; // YES if a synchronous promotion operation is in progress (promotion during // installation). diff --git a/chrome/browser/mac/keystone_glue.mm b/chrome/browser/mac/keystone_glue.mm index 35eaca9..8b00373 100644 --- a/chrome/browser/mac/keystone_glue.mm +++ b/chrome/browser/mac/keystone_glue.mm @@ -13,6 +13,7 @@ #include "base/file_util.h" #include "base/location.h" #include "base/logging.h" +#include "base/mac/authorization_util.h" #include "base/mac/bundle_locations.h" #include "base/mac/mac_logging.h" #include "base/mac/mac_util.h" @@ -21,7 +22,6 @@ #include "base/memory/ref_counted.h" #include "base/sys_string_conversions.h" #include "base/threading/worker_pool.h" -#include "chrome/browser/mac/authorization_util.h" #import "chrome/browser/mac/keystone_registration.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_version_info.h" @@ -778,8 +778,8 @@ NSString* const kVersionKey = @"KSVersion"; NSString* prompt = l10n_util::GetNSStringFWithFixup( IDS_PROMOTE_AUTHENTICATION_PROMPT, l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); - ScopedAuthorizationRef authorization( - authorization_util::AuthorizationCreateToRunAsRoot( + base::mac::ScopedAuthorizationRef authorization( + base::mac::AuthorizationCreateToRunAsRoot( base::mac::NSToCFCast(prompt))); if (!authorization.get()) { return; @@ -790,7 +790,7 @@ NSString* const kVersionKey = @"KSVersion"; - (void)promoteTicketWithAuthorization:(AuthorizationRef)authorization_arg synchronous:(BOOL)synchronous { - ScopedAuthorizationRef authorization(authorization_arg); + base::mac::ScopedAuthorizationRef authorization(authorization_arg); authorization_arg = NULL; if ([self asyncOperationPending]) { @@ -846,7 +846,7 @@ NSString* const kVersionKey = @"KSVersion"; const char* arguments[] = {userBrandFile, systemBrandFile, NULL}; int exit_status; - OSStatus status = authorization_util::ExecuteWithPrivilegesAndWait( + OSStatus status = base::mac::ExecuteWithPrivilegesAndWait( authorization, preflightPathC, kAuthorizationFlagDefaults, @@ -934,7 +934,7 @@ NSString* const kVersionKey = @"KSVersion"; const char* arguments[] = {appPathC, NULL}; int exit_status; - OSStatus status = authorization_util::ExecuteWithPrivilegesAndWait( + OSStatus status = base::mac::ExecuteWithPrivilegesAndWait( authorization_, toolPathC, kAuthorizationFlagDefaults, diff --git a/chrome/browser/mac/keystone_promote_postflight.sh b/chrome/browser/mac/keystone_promote_postflight.sh index 6344cd3..9624004 100755 --- a/chrome/browser/mac/keystone_promote_postflight.sh +++ b/chrome/browser/mac/keystone_promote_postflight.sh @@ -1,6 +1,6 @@ #!/bin/bash -p -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -25,7 +25,7 @@ set -e export PATH="/usr/bin:/usr/sbin:/bin:/sbin" # Output the pid to stdout before doing anything else. See -# chrome/browser/mac/authorization_util.h. +# base/mac/authorization_util.h. echo "${$}" if [ ${#} -ne 1 ] ; then diff --git a/chrome/browser/mac/keystone_promote_preflight.sh b/chrome/browser/mac/keystone_promote_preflight.sh index e054ff0..6582e08 100755 --- a/chrome/browser/mac/keystone_promote_preflight.sh +++ b/chrome/browser/mac/keystone_promote_preflight.sh @@ -1,6 +1,6 @@ #!/bin/bash -p -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -26,7 +26,7 @@ set -e export PATH="/usr/bin:/usr/sbin:/bin:/sbin" # Output the pid to stdout before doing anything else. See -# chrome/browser/mac/authorization_util.h. +# base/mac/authorization_util.h. echo "${$}" if [ ${#} -ne 0 ] && [ ${#} -ne 2 ] ; then diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 0a32516..1d137d7 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -1307,8 +1307,6 @@ 'browser/language_usage_metrics.h', 'browser/low_memory_observer.cc', 'browser/low_memory_observer.h', - 'browser/mac/authorization_util.h', - 'browser/mac/authorization_util.mm', 'browser/mac/dock.h', 'browser/mac/dock.mm', 'browser/mac/install_from_dmg.h', @@ -1323,7 +1321,6 @@ 'browser/mac/master_prefs.mm', 'browser/mac/relauncher.cc', 'browser/mac/relauncher.h', - 'browser/mac/scoped_authorizationref.h', 'browser/mac/scoped_ioobject.h', 'browser/mac/scoped_launch_data.h', 'browser/managed_mode.cc', |