Remove some ScopedNSAutoreleasePool usage.
This touches a lot of ancient code that trips the presubmit, so skip the presubmit. BUG=772489 Change-Id: Ifea8ca3bd1ebb92eaa47421a6000ae70a25fe3e5 No-Presubmit: true Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1783211 Commit-Queue: Avi Drissman <avi@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Reviewed-by: Elly Fong-Jones <ellyjones@chromium.org> Reviewed-by: Yuwei Huang <yuweih@chromium.org> Reviewed-by: Miguel Casas <mcasas@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Cr-Commit-Position: refs/heads/master@{#694364}
This commit is contained in:
base
ios
mac
bind_objc_block_unittest.mmfoundation_util_unittest.mmobjc_release_properties_unittest.mmscoped_nsautorelease_pool.hscoped_nsobject.hscoped_nsobject_unittest.mm
system
test
chrome
app
app_shim
browser
common
test
tools
build
components
content
browser
renderer_host
common
printing
remoting
rlz/mac/lib
services
ui
base
test
views
controls
test
widget
@@ -5,7 +5,6 @@
|
|||||||
#import "base/ios/crb_protocol_observers.h"
|
#import "base/ios/crb_protocol_observers.h"
|
||||||
#include "base/ios/weak_nsobject.h"
|
#include "base/ios/weak_nsobject.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
#include "testing/gtest_mac.h"
|
#include "testing/gtest_mac.h"
|
||||||
@@ -122,11 +121,10 @@ TEST_F(CRBProtocolObserversTest, WeakReference) {
|
|||||||
|
|
||||||
[observers_ addObserver:partial_observer_];
|
[observers_ addObserver:partial_observer_];
|
||||||
|
|
||||||
{
|
|
||||||
// Need an autorelease pool here, because
|
// Need an autorelease pool here, because
|
||||||
// -[CRBProtocolObservers forwardInvocation:] creates a temporary
|
// -[CRBProtocolObservers forwardInvocation:] creates a temporary
|
||||||
// autoreleased array that holds all the observers.
|
// autoreleased array that holds all the observers.
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
[observers_ requiredMethod];
|
[observers_ requiredMethod];
|
||||||
EXPECT_TRUE([partial_observer_ requiredMethodInvoked]);
|
EXPECT_TRUE([partial_observer_ requiredMethodInvoked]);
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include "base/ios/weak_nsobject.h"
|
#include "base/ios/weak_nsobject.h"
|
||||||
|
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -34,9 +33,9 @@ WeakContainer::~WeakContainer() {}
|
|||||||
+ (scoped_refptr<base::WeakContainer>)containerForObject:(id)object {
|
+ (scoped_refptr<base::WeakContainer>)containerForObject:(id)object {
|
||||||
if (object == nil)
|
if (object == nil)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
// The autoreleasePool is needed here as the call to objc_getAssociatedObject
|
// The autoreleasepool is needed here as the call to objc_getAssociatedObject
|
||||||
// returns an autoreleased object which is better released sooner than later.
|
// returns an autoreleased object which is better released sooner than later.
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
CRBWeakNSProtocolSentinel* sentinel =
|
CRBWeakNSProtocolSentinel* sentinel =
|
||||||
objc_getAssociatedObject(object, &sentinelObserverKey_);
|
objc_getAssociatedObject(object, &sentinelObserverKey_);
|
||||||
if (!sentinel) {
|
if (!sentinel) {
|
||||||
@@ -51,6 +50,7 @@ WeakContainer::~WeakContainer() {}
|
|||||||
DCHECK_EQ(2u, [sentinel retainCount]);
|
DCHECK_EQ(2u, [sentinel retainCount]);
|
||||||
}
|
}
|
||||||
return [sentinel container];
|
return [sentinel container];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithContainer:(scoped_refptr<base::WeakContainer>)container {
|
- (id)initWithContainer:(scoped_refptr<base::WeakContainer>)container {
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#include "base/callback_helpers.h"
|
#include "base/callback_helpers.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
#include "testing/gtest_mac.h"
|
#include "testing/gtest_mac.h"
|
||||||
@@ -108,8 +107,7 @@ TEST(BindObjcBlockTest, TestSixArguments) {
|
|||||||
TEST(BindObjcBlockTest, TestBlockMoveable) {
|
TEST(BindObjcBlockTest, TestBlockMoveable) {
|
||||||
base::OnceClosure c;
|
base::OnceClosure c;
|
||||||
__block BOOL invoked_block = NO;
|
__block BOOL invoked_block = NO;
|
||||||
{
|
@autoreleasepool {
|
||||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
|
||||||
c = base::BindOnce(base::RetainBlock(^(std::unique_ptr<BOOL> v) {
|
c = base::BindOnce(base::RetainBlock(^(std::unique_ptr<BOOL> v) {
|
||||||
invoked_block = *v;
|
invoked_block = *v;
|
||||||
}),
|
}),
|
||||||
@@ -139,8 +137,7 @@ TEST(BindObjcBlockTest, TestBlockDeallocation) {
|
|||||||
|
|
||||||
TEST(BindObjcBlockTest, TestBlockReleased) {
|
TEST(BindObjcBlockTest, TestBlockReleased) {
|
||||||
base::WeakNSObject<NSObject> weak_nsobject;
|
base::WeakNSObject<NSObject> weak_nsobject;
|
||||||
{
|
@autoreleasepool {
|
||||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
|
||||||
NSObject* nsobject = [[[NSObject alloc] init] autorelease];
|
NSObject* nsobject = [[[NSObject alloc] init] autorelease];
|
||||||
weak_nsobject.reset(nsobject);
|
weak_nsobject.reset(nsobject);
|
||||||
|
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/format_macros.h"
|
#include "base/format_macros.h"
|
||||||
#include "base/mac/scoped_cftyperef.h"
|
#include "base/mac/scoped_cftyperef.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/stl_util.h"
|
#include "base/stl_util.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
@@ -162,14 +161,13 @@ TEST(FoundationUtilTest, CFCast) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST(FoundationUtilTest, ObjCCast) {
|
TEST(FoundationUtilTest, ObjCCast) {
|
||||||
ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
id test_array = @[];
|
id test_array = @[];
|
||||||
id test_array_mutable = [NSMutableArray array];
|
id test_array_mutable = [NSMutableArray array];
|
||||||
id test_data = [NSData data];
|
id test_data = [NSData data];
|
||||||
id test_data_mutable = [NSMutableData dataWithCapacity:10];
|
id test_data_mutable = [NSMutableData dataWithCapacity:10];
|
||||||
id test_date = [NSDate date];
|
id test_date = [NSDate date];
|
||||||
id test_dict = @{ @"meaning" : @42 };
|
id test_dict = @{@"meaning" : @42};
|
||||||
id test_dict_mutable = [NSMutableDictionary dictionaryWithCapacity:10];
|
id test_dict_mutable = [NSMutableDictionary dictionaryWithCapacity:10];
|
||||||
id test_number = @42;
|
id test_number = @42;
|
||||||
id test_null = [NSNull null];
|
id test_null = [NSNull null];
|
||||||
@@ -239,11 +237,9 @@ TEST(FoundationUtilTest, ObjCCast) {
|
|||||||
|
|
||||||
// ObjCCastStrict: correct cast results in correct pointer being returned.
|
// ObjCCastStrict: correct cast results in correct pointer being returned.
|
||||||
EXPECT_EQ(test_array, ObjCCastStrict<NSArray>(test_array));
|
EXPECT_EQ(test_array, ObjCCastStrict<NSArray>(test_array));
|
||||||
EXPECT_EQ(test_array_mutable,
|
EXPECT_EQ(test_array_mutable, ObjCCastStrict<NSArray>(test_array_mutable));
|
||||||
ObjCCastStrict<NSArray>(test_array_mutable));
|
|
||||||
EXPECT_EQ(test_data, ObjCCastStrict<NSData>(test_data));
|
EXPECT_EQ(test_data, ObjCCastStrict<NSData>(test_data));
|
||||||
EXPECT_EQ(test_data_mutable,
|
EXPECT_EQ(test_data_mutable, ObjCCastStrict<NSData>(test_data_mutable));
|
||||||
ObjCCastStrict<NSData>(test_data_mutable));
|
|
||||||
EXPECT_EQ(test_date, ObjCCastStrict<NSDate>(test_date));
|
EXPECT_EQ(test_date, ObjCCastStrict<NSDate>(test_date));
|
||||||
EXPECT_EQ(test_dict, ObjCCastStrict<NSDictionary>(test_dict));
|
EXPECT_EQ(test_dict, ObjCCastStrict<NSDictionary>(test_dict));
|
||||||
EXPECT_EQ(test_dict_mutable,
|
EXPECT_EQ(test_dict_mutable,
|
||||||
@@ -251,13 +247,10 @@ TEST(FoundationUtilTest, ObjCCast) {
|
|||||||
EXPECT_EQ(test_number, ObjCCastStrict<NSNumber>(test_number));
|
EXPECT_EQ(test_number, ObjCCastStrict<NSNumber>(test_number));
|
||||||
EXPECT_EQ(test_null, ObjCCastStrict<NSNull>(test_null));
|
EXPECT_EQ(test_null, ObjCCastStrict<NSNull>(test_null));
|
||||||
EXPECT_EQ(test_set, ObjCCastStrict<NSSet>(test_set));
|
EXPECT_EQ(test_set, ObjCCastStrict<NSSet>(test_set));
|
||||||
EXPECT_EQ(test_set_mutable,
|
EXPECT_EQ(test_set_mutable, ObjCCastStrict<NSSet>(test_set_mutable));
|
||||||
ObjCCastStrict<NSSet>(test_set_mutable));
|
|
||||||
EXPECT_EQ(test_str, ObjCCastStrict<NSString>(test_str));
|
EXPECT_EQ(test_str, ObjCCastStrict<NSString>(test_str));
|
||||||
EXPECT_EQ(test_str_const,
|
EXPECT_EQ(test_str_const, ObjCCastStrict<NSString>(test_str_const));
|
||||||
ObjCCastStrict<NSString>(test_str_const));
|
EXPECT_EQ(test_str_mutable, ObjCCastStrict<NSString>(test_str_mutable));
|
||||||
EXPECT_EQ(test_str_mutable,
|
|
||||||
ObjCCastStrict<NSString>(test_str_mutable));
|
|
||||||
|
|
||||||
// ObjCCastStrict: Giving a nil provides a nil.
|
// ObjCCastStrict: Giving a nil provides a nil.
|
||||||
EXPECT_FALSE(ObjCCastStrict<NSArray>(nil));
|
EXPECT_FALSE(ObjCCastStrict<NSArray>(nil));
|
||||||
@@ -268,6 +261,7 @@ TEST(FoundationUtilTest, ObjCCast) {
|
|||||||
EXPECT_FALSE(ObjCCastStrict<NSNumber>(nil));
|
EXPECT_FALSE(ObjCCastStrict<NSNumber>(nil));
|
||||||
EXPECT_FALSE(ObjCCastStrict<NSSet>(nil));
|
EXPECT_FALSE(ObjCCastStrict<NSSet>(nil));
|
||||||
EXPECT_FALSE(ObjCCastStrict<NSString>(nil));
|
EXPECT_FALSE(ObjCCastStrict<NSString>(nil));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(FoundationUtilTest, GetValueFromDictionary) {
|
TEST(FoundationUtilTest, GetValueFromDictionary) {
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
#include "base/mac/objc_release_properties.h"
|
#include "base/mac/objc_release_properties.h"
|
||||||
#include "base/stl_util.h"
|
#include "base/stl_util.h"
|
||||||
|
|
||||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
#import <objc/runtime.h>
|
#import <objc/runtime.h>
|
||||||
@@ -268,9 +267,7 @@ TEST(ObjCReleasePropertiesTest, SesameStreet) {
|
|||||||
// Make sure that worked before things get more involved.
|
// Make sure that worked before things get more involved.
|
||||||
EXPECT_EQ(3, ah_ah_ah);
|
EXPECT_EQ(3, ah_ah_ah);
|
||||||
|
|
||||||
{
|
@autoreleasepool {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
|
|
||||||
test_object.baseCvcRetain = [CountVonCount countVonCount];
|
test_object.baseCvcRetain = [CountVonCount countVonCount];
|
||||||
test_object.baseCvcCopy = [CountVonCount countVonCount];
|
test_object.baseCvcCopy = [CountVonCount countVonCount];
|
||||||
test_object.baseCvcAssign = baseAssign;
|
test_object.baseCvcAssign = baseAssign;
|
||||||
@@ -324,9 +321,7 @@ TEST(ObjCReleasePropertiesTest, SesameStreet) {
|
|||||||
// readonly.
|
// readonly.
|
||||||
EXPECT_EQ(6, ah_ah_ah);
|
EXPECT_EQ(6, ah_ah_ah);
|
||||||
|
|
||||||
{
|
@autoreleasepool {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
|
|
||||||
// Put things back to how they were.
|
// Put things back to how they were.
|
||||||
test_object.baseCvcRetain = [CountVonCount countVonCount];
|
test_object.baseCvcRetain = [CountVonCount countVonCount];
|
||||||
test_object.baseCvcCopy = [CountVonCount countVonCount];
|
test_object.baseCvcCopy = [CountVonCount countVonCount];
|
||||||
|
@@ -21,6 +21,8 @@ namespace mac {
|
|||||||
// sends it a -drain message when destroyed. This allows an autorelease pool to
|
// sends it a -drain message when destroyed. This allows an autorelease pool to
|
||||||
// be maintained in ordinary C++ code without bringing in any direct Objective-C
|
// be maintained in ordinary C++ code without bringing in any direct Objective-C
|
||||||
// dependency.
|
// dependency.
|
||||||
|
//
|
||||||
|
// Use only in C++ code; use @autoreleasepool in Obj-C(++) code.
|
||||||
|
|
||||||
class BASE_EXPORT ScopedNSAutoreleasePool {
|
class BASE_EXPORT ScopedNSAutoreleasePool {
|
||||||
public:
|
public:
|
||||||
|
@@ -36,11 +36,10 @@ namespace base {
|
|||||||
// scoped_nsprotocol<> has the same behavior as scoped_nsobject, but can be used
|
// scoped_nsprotocol<> has the same behavior as scoped_nsobject, but can be used
|
||||||
// with protocols.
|
// with protocols.
|
||||||
//
|
//
|
||||||
// scoped_nsobject<> is not to be used for NSAutoreleasePools. For
|
// scoped_nsobject<> is not to be used for NSAutoreleasePools. For C++ code use
|
||||||
// NSAutoreleasePools use ScopedNSAutoreleasePool from
|
// NSAutoreleasePool; for Objective-C(++) code use @autoreleasepool instead. We
|
||||||
// scoped_nsautorelease_pool.h instead.
|
// check for bad uses of scoped_nsobject and NSAutoreleasePool at compile time
|
||||||
// We check for bad uses of scoped_nsobject and NSAutoreleasePool at compile
|
// with a template specialization (see below).
|
||||||
// time with a template specialization (see below).
|
|
||||||
//
|
//
|
||||||
// If Automatic Reference Counting (aka ARC) is enabled then the ownership
|
// If Automatic Reference Counting (aka ARC) is enabled then the ownership
|
||||||
// policy is not controllable by the user as ARC make it really difficult to
|
// policy is not controllable by the user as ARC make it really difficult to
|
||||||
@@ -187,7 +186,7 @@ class scoped_nsobject : public scoped_nsprotocol<NST*> {
|
|||||||
|
|
||||||
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
#if !defined(__has_feature) || !__has_feature(objc_arc)
|
||||||
static_assert(std::is_same<NST, NSAutoreleasePool>::value == false,
|
static_assert(std::is_same<NST, NSAutoreleasePool>::value == false,
|
||||||
"Use ScopedNSAutoreleasePool instead");
|
"Use @autoreleasepool instead");
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
@@ -24,8 +23,7 @@ TEST(ScopedNSObjectTest, ScopedNSObject) {
|
|||||||
base::scoped_nsobject<NSObject> p3 = p1;
|
base::scoped_nsobject<NSObject> p3 = p1;
|
||||||
ASSERT_EQ(p1.get(), p3.get());
|
ASSERT_EQ(p1.get(), p3.get());
|
||||||
ASSERT_EQ(2u, [p1 retainCount]);
|
ASSERT_EQ(2u, [p1 retainCount]);
|
||||||
{
|
@autoreleasepool {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
p3 = p1;
|
p3 = p1;
|
||||||
}
|
}
|
||||||
ASSERT_EQ(p1.get(), p3.get());
|
ASSERT_EQ(p1.get(), p3.get());
|
||||||
@@ -46,8 +44,7 @@ TEST(ScopedNSObjectTest, ScopedNSObject) {
|
|||||||
|
|
||||||
base::scoped_nsobject<NSObject> p6 = p1;
|
base::scoped_nsobject<NSObject> p6 = p1;
|
||||||
ASSERT_EQ(3u, [p6 retainCount]);
|
ASSERT_EQ(3u, [p6 retainCount]);
|
||||||
{
|
@autoreleasepool {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
p6.autorelease();
|
p6.autorelease();
|
||||||
ASSERT_EQ(nil, p6.get());
|
ASSERT_EQ(nil, p6.get());
|
||||||
ASSERT_EQ(3u, [p1 retainCount]);
|
ASSERT_EQ(3u, [p1 retainCount]);
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/mac/scoped_mach_port.h"
|
#include "base/mac/scoped_mach_port.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/process/process_metrics.h"
|
#include "base/process/process_metrics.h"
|
||||||
#include "base/stl_util.h"
|
#include "base/stl_util.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
@@ -43,9 +42,10 @@ std::string SysInfo::OperatingSystemName() {
|
|||||||
static dispatch_once_t get_system_name_once;
|
static dispatch_once_t get_system_name_once;
|
||||||
static std::string* system_name;
|
static std::string* system_name;
|
||||||
dispatch_once(&get_system_name_once, ^{
|
dispatch_once(&get_system_name_once, ^{
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
system_name = new std::string(
|
system_name = new std::string(
|
||||||
SysNSStringToUTF8([[UIDevice currentDevice] systemName]));
|
SysNSStringToUTF8([[UIDevice currentDevice] systemName]));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
// Examples of returned value: 'iPhone OS' on iPad 5.1.1
|
// Examples of returned value: 'iPhone OS' on iPad 5.1.1
|
||||||
// and iPhone 5.1.1.
|
// and iPhone 5.1.1.
|
||||||
@@ -57,9 +57,10 @@ std::string SysInfo::OperatingSystemVersion() {
|
|||||||
static dispatch_once_t get_system_version_once;
|
static dispatch_once_t get_system_version_once;
|
||||||
static std::string* system_version;
|
static std::string* system_version;
|
||||||
dispatch_once(&get_system_version_once, ^{
|
dispatch_once(&get_system_version_once, ^{
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
system_version = new std::string(
|
system_version = new std::string(
|
||||||
SysNSStringToUTF8([[UIDevice currentDevice] systemVersion]));
|
SysNSStringToUTF8([[UIDevice currentDevice] systemVersion]));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
return *system_version;
|
return *system_version;
|
||||||
}
|
}
|
||||||
@@ -68,7 +69,7 @@ std::string SysInfo::OperatingSystemVersion() {
|
|||||||
void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version,
|
void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version,
|
||||||
int32_t* minor_version,
|
int32_t* minor_version,
|
||||||
int32_t* bugfix_version) {
|
int32_t* bugfix_version) {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
std::string system_version = OperatingSystemVersion();
|
std::string system_version = OperatingSystemVersion();
|
||||||
if (!system_version.empty()) {
|
if (!system_version.empty()) {
|
||||||
// Try to parse out the version numbers from the string.
|
// Try to parse out the version numbers from the string.
|
||||||
@@ -81,6 +82,7 @@ void SysInfo::OperatingSystemVersionNumbers(int32_t* major_version,
|
|||||||
if (num_read < 3)
|
if (num_read < 3)
|
||||||
*bugfix_version = 0;
|
*bugfix_version = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "testing/gtest/include/gtest/gtest.h"
|
#include "testing/gtest/include/gtest/gtest.h"
|
||||||
|
|
||||||
// The iOS watchdog timer will kill an app that doesn't spin the main event
|
// The iOS watchdog timer will kill an app that doesn't spin the main event
|
||||||
@@ -22,11 +21,11 @@ class IOSRunLoopListener : public testing::EmptyTestEventListener {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void IOSRunLoopListener::OnTestEnd(const testing::TestInfo& test_info) {
|
void IOSRunLoopListener::OnTestEnd(const testing::TestInfo& test_info) {
|
||||||
base::mac::ScopedNSAutoreleasePool scoped_pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
// At the end of the test, spin the default loop for a moment.
|
// At the end of the test, spin the default loop for a moment.
|
||||||
NSDate* stop_date = [NSDate dateWithTimeIntervalSinceNow:0.001];
|
NSDate* stop_date = [NSDate dateWithTimeIntervalSinceNow:0.001];
|
||||||
[[NSRunLoop currentRunLoop] runUntilDate:stop_date];
|
[[NSRunLoop currentRunLoop] runUntilDate:stop_date];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#include "base/debug/debugger.h"
|
#include "base/debug/debugger.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "base/message_loop/message_pump.h"
|
#include "base/message_loop/message_pump.h"
|
||||||
#include "base/message_loop/message_pump_default.h"
|
#include "base/message_loop/message_pump_default.h"
|
||||||
@@ -209,11 +208,12 @@ void RunTestsFromIOSApp() {
|
|||||||
static bool ran_hook = false;
|
static bool ran_hook = false;
|
||||||
if (!ran_hook) {
|
if (!ran_hook) {
|
||||||
ran_hook = true;
|
ran_hook = true;
|
||||||
mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
int exit_status = UIApplicationMain(g_argc, g_argv, nil,
|
int exit_status =
|
||||||
@"ChromeUnitTestDelegate");
|
UIApplicationMain(g_argc, g_argv, nil, @"ChromeUnitTestDelegate");
|
||||||
exit(exit_status);
|
exit(exit_status);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace base
|
} // namespace base
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#import "base/mac/bundle_locations.h"
|
#import "base/mac/bundle_locations.h"
|
||||||
#import "base/mac/foundation_util.h"
|
#import "base/mac/foundation_util.h"
|
||||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
#include "chrome/common/chrome_constants.h"
|
#include "chrome/common/chrome_constants.h"
|
||||||
@@ -20,19 +19,18 @@
|
|||||||
#include "content/public/common/content_paths.h"
|
#include "content/public/common/content_paths.h"
|
||||||
|
|
||||||
void SetUpBundleOverrides() {
|
void SetUpBundleOverrides() {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
base::mac::SetOverrideFrameworkBundlePath(chrome::GetFrameworkBundlePath());
|
base::mac::SetOverrideFrameworkBundlePath(chrome::GetFrameworkBundlePath());
|
||||||
|
|
||||||
NSBundle* base_bundle = chrome::OuterAppBundle();
|
NSBundle* base_bundle = chrome::OuterAppBundle();
|
||||||
base::mac::SetBaseBundleID([[base_bundle bundleIdentifier] UTF8String]);
|
base::mac::SetBaseBundleID([[base_bundle bundleIdentifier] UTF8String]);
|
||||||
|
|
||||||
base::FilePath child_exe_path =
|
base::FilePath child_exe_path =
|
||||||
chrome::GetFrameworkBundlePath()
|
chrome::GetFrameworkBundlePath().Append("Helpers").Append(
|
||||||
.Append("Helpers")
|
chrome::kHelperProcessExecutablePath);
|
||||||
.Append(chrome::kHelperProcessExecutablePath);
|
|
||||||
|
|
||||||
// On the Mac, the child executable lives at a predefined location within
|
// On the Mac, the child executable lives at a predefined location within
|
||||||
// the app bundle's versioned directory.
|
// the app bundle's versioned directory.
|
||||||
base::PathService::Override(content::CHILD_PROCESS_EXE, child_exe_path);
|
base::PathService::Override(content::CHILD_PROCESS_EXE, child_exe_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,7 +18,6 @@
|
|||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/mac/foundation_util.h"
|
#include "base/mac/foundation_util.h"
|
||||||
#import "base/mac/launch_services_util.h"
|
#import "base/mac/launch_services_util.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/process/launch.h"
|
#include "base/process/launch.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
@@ -38,8 +37,7 @@ int LoadFrameworkAndStart(int argc, char** argv) {
|
|||||||
using base::mac::CFCastStrict;
|
using base::mac::CFCastStrict;
|
||||||
using base::mac::NSToCFCast;
|
using base::mac::NSToCFCast;
|
||||||
|
|
||||||
base::mac::ScopedNSAutoreleasePool scoped_pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
// Get the current main bundle, i.e., that of the app loader that's running.
|
// Get the current main bundle, i.e., that of the app loader that's running.
|
||||||
NSBundle* app_bundle = [NSBundle mainBundle];
|
NSBundle* app_bundle = [NSBundle mainBundle];
|
||||||
CHECK(app_bundle) << "couldn't get loader bundle";
|
CHECK(app_bundle) << "couldn't get loader bundle";
|
||||||
@@ -172,8 +170,8 @@ int LoadFrameworkAndStart(int argc, char** argv) {
|
|||||||
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||||
app_mode::kLaunchedByChromeProcessId)) {
|
app_mode::kLaunchedByChromeProcessId)) {
|
||||||
// Pass --app-shim-error to have Chrome rebuild this shim.
|
// Pass --app-shim-error to have Chrome rebuild this shim.
|
||||||
// If Chrome has rebuilt this shim once already, then rebuilding doesn't fix
|
// If Chrome has rebuilt this shim once already, then rebuilding doesn't
|
||||||
// the problem, so don't try again.
|
// fix the problem, so don't try again.
|
||||||
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||||
app_mode::kLaunchedAfterRebuild)) {
|
app_mode::kLaunchedAfterRebuild)) {
|
||||||
command_line.AppendSwitchPath(app_mode::kAppShimError,
|
command_line.AppendSwitchPath(app_mode::kAppShimError,
|
||||||
@@ -182,14 +180,15 @@ int LoadFrameworkAndStart(int argc, char** argv) {
|
|||||||
} else {
|
} else {
|
||||||
// If the shim was launched directly (instead of by Chrome), first ask
|
// If the shim was launched directly (instead of by Chrome), first ask
|
||||||
// Chrome to launch the app. Chrome will launch the shim again, the same
|
// Chrome to launch the app. Chrome will launch the shim again, the same
|
||||||
// error will occur and be handled above. This approach allows the app to be
|
// error will occur and be handled above. This approach allows the app to
|
||||||
// started without blocking on fixing the shim and guarantees that the
|
// be started without blocking on fixing the shim and guarantees that the
|
||||||
// profile is loaded when Chrome receives --app-shim-error.
|
// profile is loaded when Chrome receives --app-shim-error.
|
||||||
command_line.AppendSwitchPath(switches::kProfileDirectory, profile_dir);
|
command_line.AppendSwitchPath(switches::kProfileDirectory, profile_dir);
|
||||||
command_line.AppendSwitchASCII(switches::kAppId, app_mode_id);
|
command_line.AppendSwitchASCII(switches::kAppId, app_mode_id);
|
||||||
}
|
}
|
||||||
// Launch the executable directly since base::mac::OpenApplicationWithPath
|
// Launch the executable directly since base::mac::OpenApplicationWithPath
|
||||||
// doesn't pass command line arguments if the application is already running.
|
// doesn't pass command line arguments if the application is already
|
||||||
|
// running.
|
||||||
if (!base::LaunchProcess(command_line, base::LaunchOptions()).IsValid()) {
|
if (!base::LaunchProcess(command_line, base::LaunchOptions()).IsValid()) {
|
||||||
LOG(ERROR) << "Could not launch Chrome: "
|
LOG(ERROR) << "Could not launch Chrome: "
|
||||||
<< command_line.GetCommandLineString();
|
<< command_line.GetCommandLineString();
|
||||||
@@ -197,6 +196,7 @@ int LoadFrameworkAndStart(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@@ -18,7 +18,6 @@
|
|||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/mac/bundle_locations.h"
|
#include "base/mac/bundle_locations.h"
|
||||||
#include "base/mac/mac_logging.h"
|
#include "base/mac/mac_logging.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/message_loop/message_pump_type.h"
|
#include "base/message_loop/message_pump_type.h"
|
||||||
#include "base/run_loop.h"
|
#include "base/run_loop.h"
|
||||||
@@ -73,7 +72,7 @@ void PostRepeatingDelayedTask() {
|
|||||||
int APP_SHIM_ENTRY_POINT_NAME(const app_mode::ChromeAppModeInfo* info) {
|
int APP_SHIM_ENTRY_POINT_NAME(const app_mode::ChromeAppModeInfo* info) {
|
||||||
base::CommandLine::Init(info->argc, info->argv);
|
base::CommandLine::Init(info->argc, info->argv);
|
||||||
|
|
||||||
base::mac::ScopedNSAutoreleasePool scoped_pool;
|
@autoreleasepool {
|
||||||
base::AtExitManager exit_manager;
|
base::AtExitManager exit_manager;
|
||||||
chrome::RegisterPathProvider();
|
chrome::RegisterPathProvider();
|
||||||
|
|
||||||
@@ -86,11 +85,11 @@ int APP_SHIM_ENTRY_POINT_NAME(const app_mode::ChromeAppModeInfo* info) {
|
|||||||
ChromeCrashReporterClient::Create();
|
ChromeCrashReporterClient::Create();
|
||||||
crash_reporter::InitializeCrashpad(true, "app_shim");
|
crash_reporter::InitializeCrashpad(true, "app_shim");
|
||||||
|
|
||||||
// Calculate the preferred locale used by Chrome.
|
// Calculate the preferred locale used by Chrome. We can't use
|
||||||
// We can't use l10n_util::OverrideLocaleWithCocoaLocale() because it calls
|
// l10n_util::OverrideLocaleWithCocoaLocale() because it calls
|
||||||
// [base::mac::OuterBundle() preferredLocalizations] which gets localizations
|
// [base::mac::OuterBundle() preferredLocalizations] which gets
|
||||||
// from the bundle of the running app (i.e. it is equivalent to
|
// localizations from the bundle of the running app (i.e. it is equivalent
|
||||||
// [[NSBundle mainBundle] preferredLocalizations]) instead of the target
|
// to [[NSBundle mainBundle] preferredLocalizations]) instead of the target
|
||||||
// bundle.
|
// bundle.
|
||||||
NSArray* preferred_languages = [NSLocale preferredLanguages];
|
NSArray* preferred_languages = [NSLocale preferredLanguages];
|
||||||
NSArray* supported_languages = [base::mac::OuterBundle() localizations];
|
NSArray* supported_languages = [base::mac::OuterBundle() localizations];
|
||||||
@@ -125,7 +124,7 @@ int APP_SHIM_ENTRY_POINT_NAME(const app_mode::ChromeAppModeInfo* info) {
|
|||||||
// Launch the IO thread.
|
// Launch the IO thread.
|
||||||
base::Thread::Options io_thread_options;
|
base::Thread::Options io_thread_options;
|
||||||
io_thread_options.message_pump_type = base::MessagePumpType::IO;
|
io_thread_options.message_pump_type = base::MessagePumpType::IO;
|
||||||
base::Thread *io_thread = new base::Thread("CrAppShimIO");
|
base::Thread* io_thread = new base::Thread("CrAppShimIO");
|
||||||
io_thread->StartWithOptions(io_thread_options);
|
io_thread->StartWithOptions(io_thread_options);
|
||||||
|
|
||||||
mojo::core::Init();
|
mojo::core::Init();
|
||||||
@@ -138,7 +137,8 @@ int APP_SHIM_ENTRY_POINT_NAME(const app_mode::ChromeAppModeInfo* info) {
|
|||||||
[AppShimApplication sharedApplication];
|
[AppShimApplication sharedApplication];
|
||||||
CHECK([NSApp isKindOfClass:[AppShimApplication class]]);
|
CHECK([NSApp isKindOfClass:[AppShimApplication class]]);
|
||||||
|
|
||||||
base::SingleThreadTaskExecutor main_task_executor(base::MessagePumpType::UI);
|
base::SingleThreadTaskExecutor main_task_executor(
|
||||||
|
base::MessagePumpType::UI);
|
||||||
ui::WindowResizeHelperMac::Get()->Init(main_task_executor.task_runner());
|
ui::WindowResizeHelperMac::Get()->Init(main_task_executor.task_runner());
|
||||||
base::PlatformThread::SetName("CrAppShimMain");
|
base::PlatformThread::SetName("CrAppShimMain");
|
||||||
|
|
||||||
@@ -163,4 +163,5 @@ int APP_SHIM_ENTRY_POINT_NAME(const app_mode::ChromeAppModeInfo* info) {
|
|||||||
AppShimController controller(controller_params);
|
AppShimController controller(controller_params);
|
||||||
base::RunLoop().Run();
|
base::RunLoop().Run();
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,6 @@
|
|||||||
#include "base/mac/scoped_authorizationref.h"
|
#include "base/mac/scoped_authorizationref.h"
|
||||||
#include "base/mac/scoped_cftyperef.h"
|
#include "base/mac/scoped_cftyperef.h"
|
||||||
#include "base/mac/scoped_ioobject.h"
|
#include "base/mac/scoped_ioobject.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/sdk_forward_declarations.h"
|
#include "base/mac/sdk_forward_declarations.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/stl_util.h"
|
#include "base/stl_util.h"
|
||||||
@@ -407,18 +406,15 @@ DiskImageStatus IsAppRunningFromReadOnlyDiskImage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool MaybeInstallFromDiskImage() {
|
bool MaybeInstallFromDiskImage() {
|
||||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
std::string dmg_bsd_device_name;
|
std::string dmg_bsd_device_name;
|
||||||
if (IsAppRunningFromReadOnlyDiskImage(&dmg_bsd_device_name) !=
|
if (IsAppRunningFromReadOnlyDiskImage(&dmg_bsd_device_name) !=
|
||||||
DiskImageStatusTrue) {
|
DiskImageStatusTrue) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSArray* application_directories =
|
NSArray* application_directories = NSSearchPathForDirectoriesInDomains(
|
||||||
NSSearchPathForDirectoriesInDomains(NSApplicationDirectory,
|
NSApplicationDirectory, NSLocalDomainMask, YES);
|
||||||
NSLocalDomainMask,
|
|
||||||
YES);
|
|
||||||
if ([application_directories count] == 0) {
|
if ([application_directories count] == 0) {
|
||||||
LOG(ERROR) << "NSSearchPathForDirectoriesInDomains: "
|
LOG(ERROR) << "NSSearchPathForDirectoriesInDomains: "
|
||||||
<< "no local application directories";
|
<< "no local application directories";
|
||||||
@@ -464,10 +460,8 @@ bool MaybeInstallFromDiskImage() {
|
|||||||
// authentication fails. In either case, try to install without privilege
|
// authentication fails. In either case, try to install without privilege
|
||||||
// escalation.
|
// escalation.
|
||||||
|
|
||||||
if (!InstallFromDiskImage(authorization.release(),
|
if (!InstallFromDiskImage(authorization.release(), installer_path,
|
||||||
installer_path,
|
source_path, target_path)) {
|
||||||
source_path,
|
|
||||||
target_path)) {
|
|
||||||
ShowErrorDialog();
|
ShowErrorDialog();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -485,6 +479,7 @@ bool MaybeInstallFromDiskImage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@@ -18,7 +18,6 @@
|
|||||||
#include "base/mac/bundle_locations.h"
|
#include "base/mac/bundle_locations.h"
|
||||||
#include "base/mac/foundation_util.h"
|
#include "base/mac/foundation_util.h"
|
||||||
#include "base/mac/mac_logging.h"
|
#include "base/mac/mac_logging.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/memory/ref_counted.h"
|
#include "base/memory/ref_counted.h"
|
||||||
#include "base/strings/string_number_conversions.h"
|
#include "base/strings/string_number_conversions.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
@@ -111,9 +110,10 @@ class PerformBridge : public base::RefCountedThreadSafe<PerformBridge> {
|
|||||||
|
|
||||||
// Happens on a WorkerPool thread.
|
// Happens on a WorkerPool thread.
|
||||||
void Run() {
|
void Run() {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
[target_ performSelector:sel_ withObject:arg_];
|
[target_ performSelector:sel_ withObject:arg_];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
base::scoped_nsobject<id> target_;
|
base::scoped_nsobject<id> target_;
|
||||||
SEL sel_;
|
SEL sel_;
|
||||||
|
@@ -23,7 +23,6 @@
|
|||||||
#include "base/files/scoped_file.h"
|
#include "base/files/scoped_file.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/mac/mac_logging.h"
|
#include "base/mac/mac_logging.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "base/posix/eintr_wrapper.h"
|
#include "base/posix/eintr_wrapper.h"
|
||||||
@@ -266,8 +265,7 @@ void RelauncherSynchronizeWithParent() {
|
|||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
// CommandLine rearranges the order of the arguments returned by
|
// CommandLine rearranges the order of the arguments returned by
|
||||||
// main_parameters.argv(), rendering it impossible to determine which
|
// main_parameters.argv(), rendering it impossible to determine which
|
||||||
// arguments originally came before kRelauncherArgSeparator and which came
|
// arguments originally came before kRelauncherArgSeparator and which came
|
||||||
@@ -346,7 +344,6 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
|||||||
relaunch_executable.assign(arg);
|
relaunch_executable.assign(arg);
|
||||||
seen_relaunch_executable = true;
|
seen_relaunch_executable = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
NSString* arg_string = base::SysUTF8ToNSString(arg);
|
NSString* arg_string = base::SysUTF8ToNSString(arg);
|
||||||
if (!arg_string) {
|
if (!arg_string) {
|
||||||
LOG(ERROR) << "base::SysUTF8ToNSString failed for " << arg;
|
LOG(ERROR) << "base::SysUTF8ToNSString failed for " << arg;
|
||||||
@@ -362,7 +359,8 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If an update is staged but not yet installed, wait for it to be installed.
|
// If an update is staged but not yet installed, wait for it to be
|
||||||
|
// installed.
|
||||||
if (wait_for_staged_update) {
|
if (wait_for_staged_update) {
|
||||||
base::scoped_nsobject<CrStagingKeyWatcher> watcher(
|
base::scoped_nsobject<CrStagingKeyWatcher> watcher(
|
||||||
[[CrStagingKeyWatcher alloc] initWithPollingTime:0.5]);
|
[[CrStagingKeyWatcher alloc] initWithPollingTime:0.5]);
|
||||||
@@ -374,7 +372,7 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
|||||||
NSDictionary* configuration =
|
NSDictionary* configuration =
|
||||||
@{NSWorkspaceLaunchConfigurationArguments : (relaunch_args.get())};
|
@{NSWorkspaceLaunchConfigurationArguments : (relaunch_args.get())};
|
||||||
|
|
||||||
NSRunningApplication *application = [[NSWorkspace sharedWorkspace]
|
NSRunningApplication* application = [[NSWorkspace sharedWorkspace]
|
||||||
launchApplicationAtURL:url
|
launchApplicationAtURL:url
|
||||||
options:NSWorkspaceLaunchDefault |
|
options:NSWorkspaceLaunchDefault |
|
||||||
NSWorkspaceLaunchWithErrorPresentation |
|
NSWorkspaceLaunchWithErrorPresentation |
|
||||||
@@ -397,6 +395,7 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
|
@@ -11,7 +11,6 @@
|
|||||||
#include "base/base_paths.h"
|
#include "base/base_paths.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#import "base/mac/foundation_util.h"
|
#import "base/mac/foundation_util.h"
|
||||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/memory/free_deleter.h"
|
#include "base/memory/free_deleter.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
#include "build/build_config.h"
|
#include "build/build_config.h"
|
||||||
@@ -24,8 +23,7 @@ namespace {
|
|||||||
// implementation of chrome::OuterAppBundle(), which should be the only
|
// implementation of chrome::OuterAppBundle(), which should be the only
|
||||||
// caller.
|
// caller.
|
||||||
NSBundle* OuterAppBundleInternal() {
|
NSBundle* OuterAppBundleInternal() {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
if (!base::mac::AmIBundled()) {
|
if (!base::mac::AmIBundled()) {
|
||||||
// If unbundled (as in a test), there's no app bundle.
|
// If unbundled (as in a test), there's no app bundle.
|
||||||
return nil;
|
return nil;
|
||||||
@@ -42,14 +40,16 @@ NSBundle* OuterAppBundleInternal() {
|
|||||||
base::FilePath outer_app_dir =
|
base::FilePath outer_app_dir =
|
||||||
framework_path.DirName().DirName().DirName().DirName().DirName();
|
framework_path.DirName().DirName().DirName().DirName().DirName();
|
||||||
const char* outer_app_dir_c = outer_app_dir.value().c_str();
|
const char* outer_app_dir_c = outer_app_dir.value().c_str();
|
||||||
NSString* outer_app_dir_ns = [NSString stringWithUTF8String:outer_app_dir_c];
|
NSString* outer_app_dir_ns =
|
||||||
|
[NSString stringWithUTF8String:outer_app_dir_c];
|
||||||
|
|
||||||
return [[NSBundle bundleWithPath:outer_app_dir_ns] retain];
|
return [[NSBundle bundleWithPath:outer_app_dir_ns] retain];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char* ProductDirNameForBundle(NSBundle* chrome_bundle) {
|
char* ProductDirNameForBundle(NSBundle* chrome_bundle) {
|
||||||
|
@autoreleasepool {
|
||||||
const char* product_dir_name = NULL;
|
const char* product_dir_name = NULL;
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
|
|
||||||
NSString* product_dir_name_ns =
|
NSString* product_dir_name_ns =
|
||||||
[chrome_bundle objectForInfoDictionaryKey:@"CrProductDirName"];
|
[chrome_bundle objectForInfoDictionaryKey:@"CrProductDirName"];
|
||||||
@@ -66,6 +66,7 @@ char* ProductDirNameForBundle(NSBundle* chrome_bundle) {
|
|||||||
// Leaked, but the only caller initializes a static with this result, so it
|
// Leaked, but the only caller initializes a static with this result, so it
|
||||||
// only happens once, and that's OK.
|
// only happens once, and that's OK.
|
||||||
return strdup(product_dir_name);
|
return strdup(product_dir_name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProductDirName returns the name of the directory inside
|
// ProductDirName returns the name of the directory inside
|
||||||
|
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#include "base/mac/foundation_util.h"
|
#include "base/mac/foundation_util.h"
|
||||||
#include "base/mac/scoped_cftyperef.h"
|
#include "base/mac/scoped_cftyperef.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/process/launch.h"
|
#include "base/process/launch.h"
|
||||||
#include "base/strings/stringprintf.h"
|
#include "base/strings/stringprintf.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
@@ -100,7 +99,7 @@ bool Launchd::RestartJob(Domain domain,
|
|||||||
Type type,
|
Type type,
|
||||||
CFStringRef name,
|
CFStringRef name,
|
||||||
CFStringRef cf_session_type) {
|
CFStringRef cf_session_type) {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
NSURL* url = GetPlistURL(domain, type, name);
|
NSURL* url = GetPlistURL(domain, type, name);
|
||||||
NSString* ns_path = [url path];
|
NSString* ns_path = [url path];
|
||||||
ns_path = SanitizeShellArgument(ns_path);
|
ns_path = SanitizeShellArgument(ns_path);
|
||||||
@@ -116,8 +115,8 @@ bool Launchd::RestartJob(Domain domain,
|
|||||||
argv.push_back("/bin/bash");
|
argv.push_back("/bin/bash");
|
||||||
argv.push_back("--noprofile");
|
argv.push_back("--noprofile");
|
||||||
argv.push_back("-c");
|
argv.push_back("-c");
|
||||||
std::string command = base::StringPrintf(
|
std::string command =
|
||||||
"/bin/launchctl unload -S %s %s;"
|
base::StringPrintf("/bin/launchctl unload -S %s %s;"
|
||||||
"/bin/launchctl load -S %s %s;",
|
"/bin/launchctl load -S %s %s;",
|
||||||
[ns_session_type UTF8String], file_path,
|
[ns_session_type UTF8String], file_path,
|
||||||
[ns_session_type UTF8String], file_path);
|
[ns_session_type UTF8String], file_path);
|
||||||
@@ -126,29 +125,32 @@ bool Launchd::RestartJob(Domain domain,
|
|||||||
base::LaunchOptions options;
|
base::LaunchOptions options;
|
||||||
options.new_process_group = true;
|
options.new_process_group = true;
|
||||||
return base::LaunchProcess(argv, options).IsValid();
|
return base::LaunchProcess(argv, options).IsValid();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CFMutableDictionaryRef Launchd::CreatePlistFromFile(Domain domain,
|
CFMutableDictionaryRef Launchd::CreatePlistFromFile(Domain domain,
|
||||||
Type type,
|
Type type,
|
||||||
CFStringRef name) {
|
CFStringRef name) {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
NSURL* ns_url = GetPlistURL(domain, type, name);
|
NSURL* ns_url = GetPlistURL(domain, type, name);
|
||||||
NSMutableDictionary* plist =
|
NSMutableDictionary* plist =
|
||||||
[[NSMutableDictionary alloc] initWithContentsOfURL:ns_url];
|
[[NSMutableDictionary alloc] initWithContentsOfURL:ns_url];
|
||||||
return base::mac::NSToCFCast(plist);
|
return base::mac::NSToCFCast(plist);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Launchd::WritePlistToFile(Domain domain,
|
bool Launchd::WritePlistToFile(Domain domain,
|
||||||
Type type,
|
Type type,
|
||||||
CFStringRef name,
|
CFStringRef name,
|
||||||
CFDictionaryRef dict) {
|
CFDictionaryRef dict) {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
NSURL* ns_url = GetPlistURL(domain, type, name);
|
NSURL* ns_url = GetPlistURL(domain, type, name);
|
||||||
return [base::mac::CFToNSCast(dict) writeToURL:ns_url atomically:YES];
|
return [base::mac::CFToNSCast(dict) writeToURL:ns_url atomically:YES];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Launchd::DeletePlist(Domain domain, Type type, CFStringRef name) {
|
bool Launchd::DeletePlist(Domain domain, Type type, CFStringRef name) {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
NSURL* ns_url = GetPlistURL(domain, type, name);
|
NSURL* ns_url = GetPlistURL(domain, type, name);
|
||||||
NSError* err = nil;
|
NSError* err = nil;
|
||||||
if (![[NSFileManager defaultManager] removeItemAtPath:[ns_url path]
|
if (![[NSFileManager defaultManager] removeItemAtPath:[ns_url path]
|
||||||
@@ -159,4 +161,5 @@ bool Launchd::DeletePlist(Domain domain, Type type, CFStringRef name) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,6 @@
|
|||||||
#include "base/mac/bundle_locations.h"
|
#include "base/mac/bundle_locations.h"
|
||||||
#include "base/mac/foundation_util.h"
|
#include "base/mac/foundation_util.h"
|
||||||
#include "base/mac/mac_util.h"
|
#include "base/mac/mac_util.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "base/metrics/histogram_macros.h"
|
#include "base/metrics/histogram_macros.h"
|
||||||
#include "base/path_service.h"
|
#include "base/path_service.h"
|
||||||
@@ -37,10 +36,11 @@ namespace {
|
|||||||
#define kServiceProcessSessionType "Aqua"
|
#define kServiceProcessSessionType "Aqua"
|
||||||
|
|
||||||
CFStringRef CopyServiceProcessLaunchDName() {
|
CFStringRef CopyServiceProcessLaunchDName() {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
NSBundle* bundle = base::mac::FrameworkBundle();
|
NSBundle* bundle = base::mac::FrameworkBundle();
|
||||||
return CFStringCreateCopy(kCFAllocatorDefault,
|
return CFStringCreateCopy(kCFAllocatorDefault,
|
||||||
base::mac::NSToCFCast([bundle bundleIdentifier]));
|
base::mac::NSToCFCast([bundle bundleIdentifier]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString* GetServiceProcessLaunchDLabel() {
|
NSString* GetServiceProcessLaunchDLabel() {
|
||||||
@@ -105,8 +105,9 @@ bool ForceServiceProcessShutdown(const std::string& /* version */,
|
|||||||
|
|
||||||
bool ServiceProcessState::GetServiceProcessData(std::string* version,
|
bool ServiceProcessState::GetServiceProcessData(std::string* version,
|
||||||
base::ProcessId* pid) {
|
base::ProcessId* pid) {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
std::string label = base::SysNSStringToUTF8(GetServiceProcessLaunchDLabel());
|
std::string label =
|
||||||
|
base::SysNSStringToUTF8(GetServiceProcessLaunchDLabel());
|
||||||
mac::services::JobInfo info;
|
mac::services::JobInfo info;
|
||||||
if (!Launchd::GetInstance()->GetJobInfo(label, &info))
|
if (!Launchd::GetInstance()->GetJobInfo(label, &info))
|
||||||
return false;
|
return false;
|
||||||
@@ -143,6 +144,7 @@ bool ServiceProcessState::GetServiceProcessData(std::string* version,
|
|||||||
*pid = info.pid ? *info.pid : -1;
|
*pid = info.pid ? *info.pid : -1;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceProcessState::Initialize() {
|
bool ServiceProcessState::Initialize() {
|
||||||
@@ -211,17 +213,14 @@ mac::services::JobOptions GetServiceProcessJobOptions(
|
|||||||
|
|
||||||
CFDictionaryRef CreateServiceProcessLaunchdPlist(base::CommandLine* cmd_line,
|
CFDictionaryRef CreateServiceProcessLaunchdPlist(base::CommandLine* cmd_line,
|
||||||
bool for_auto_launch) {
|
bool for_auto_launch) {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
NSString* program = base::SysUTF8ToNSString(cmd_line->GetProgram().value());
|
||||||
NSString* program =
|
|
||||||
base::SysUTF8ToNSString(cmd_line->GetProgram().value());
|
|
||||||
|
|
||||||
std::vector<std::string> args = cmd_line->argv();
|
std::vector<std::string> args = cmd_line->argv();
|
||||||
NSMutableArray* ns_args = [NSMutableArray arrayWithCapacity:args.size()];
|
NSMutableArray* ns_args = [NSMutableArray arrayWithCapacity:args.size()];
|
||||||
|
|
||||||
for (std::vector<std::string>::iterator iter = args.begin();
|
for (std::vector<std::string>::iterator iter = args.begin();
|
||||||
iter < args.end();
|
iter < args.end(); ++iter) {
|
||||||
++iter) {
|
|
||||||
[ns_args addObject:base::SysUTF8ToNSString(*iter)];
|
[ns_args addObject:base::SysUTF8ToNSString(*iter)];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +238,7 @@ CFDictionaryRef CreateServiceProcessLaunchdPlist(base::CommandLine* cmd_line,
|
|||||||
// relaunch the service automatically in any other case than exiting
|
// relaunch the service automatically in any other case than exiting
|
||||||
// cleanly with a 0 return code.
|
// cleanly with a 0 return code.
|
||||||
NSDictionary* keep_alive =
|
NSDictionary* keep_alive =
|
||||||
@{ @LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT : @NO };
|
@{@LAUNCH_JOBKEY_KEEPALIVE_SUCCESSFULEXIT : @NO};
|
||||||
NSDictionary* auto_launchd_plist = @{
|
NSDictionary* auto_launchd_plist = @{
|
||||||
@LAUNCH_JOBKEY_RUNATLOAD : @YES,
|
@LAUNCH_JOBKEY_RUNATLOAD : @YES,
|
||||||
@LAUNCH_JOBKEY_KEEPALIVE : keep_alive,
|
@LAUNCH_JOBKEY_KEEPALIVE : keep_alive,
|
||||||
@@ -248,6 +247,7 @@ CFDictionaryRef CreateServiceProcessLaunchdPlist(base::CommandLine* cmd_line,
|
|||||||
[launchd_plist addEntriesFromDictionary:auto_launchd_plist];
|
[launchd_plist addEntriesFromDictionary:auto_launchd_plist];
|
||||||
}
|
}
|
||||||
return reinterpret_cast<CFDictionaryRef>(launchd_plist);
|
return reinterpret_cast<CFDictionaryRef>(launchd_plist);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writes the launchd property list into the user's LaunchAgents directory,
|
// Writes the launchd property list into the user's LaunchAgents directory,
|
||||||
@@ -272,8 +272,7 @@ bool ServiceProcessState::RemoveFromAutoRun() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceProcessState::StateData::WatchExecutable() {
|
bool ServiceProcessState::StateData::WatchExecutable() {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
base::FilePath executable_path = base::FilePath(job_info.program);
|
base::FilePath executable_path = base::FilePath(job_info.program);
|
||||||
std::unique_ptr<ExecFilePathWatcherCallback> callback(
|
std::unique_ptr<ExecFilePathWatcherCallback> callback(
|
||||||
new ExecFilePathWatcherCallback);
|
new ExecFilePathWatcherCallback);
|
||||||
@@ -282,14 +281,14 @@ bool ServiceProcessState::StateData::WatchExecutable() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!executable_watcher.Watch(
|
if (!executable_watcher.Watch(
|
||||||
executable_path,
|
executable_path, false,
|
||||||
false,
|
|
||||||
base::Bind(&ExecFilePathWatcherCallback::NotifyPathChanged,
|
base::Bind(&ExecFilePathWatcherCallback::NotifyPathChanged,
|
||||||
base::Owned(callback.release())))) {
|
base::Owned(callback.release())))) {
|
||||||
DLOG(ERROR) << "executable_watcher.watch " << executable_path.value();
|
DLOG(ERROR) << "executable_watcher.watch " << executable_path.value();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExecFilePathWatcherCallback::Init(const base::FilePath& path) {
|
bool ExecFilePathWatcherCallback::Init(const base::FilePath& path) {
|
||||||
@@ -306,7 +305,7 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
bool needs_shutdown = false;
|
bool needs_shutdown = false;
|
||||||
bool needs_restart = false;
|
bool needs_restart = false;
|
||||||
bool good_bundle = false;
|
bool good_bundle = false;
|
||||||
@@ -315,8 +314,8 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
|
|||||||
NSURL* bundle_url = [[[executable_fsref_ URLByDeletingLastPathComponent]
|
NSURL* bundle_url = [[[executable_fsref_ URLByDeletingLastPathComponent]
|
||||||
URLByDeletingLastPathComponent] URLByDeletingLastPathComponent];
|
URLByDeletingLastPathComponent] URLByDeletingLastPathComponent];
|
||||||
if (bundle_url) {
|
if (bundle_url) {
|
||||||
base::ScopedCFTypeRef<CFBundleRef> bundle(
|
base::ScopedCFTypeRef<CFBundleRef> bundle(CFBundleCreate(
|
||||||
CFBundleCreate(kCFAllocatorDefault, base::mac::NSToCFCast(bundle_url)));
|
kCFAllocatorDefault, base::mac::NSToCFCast(bundle_url)));
|
||||||
good_bundle = CFBundleGetIdentifier(bundle) != NULL;
|
good_bundle = CFBundleGetIdentifier(bundle) != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -355,8 +354,8 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
|
|||||||
base::ScopedCFTypeRef<CFStringRef> name(CopyServiceProcessLaunchDName());
|
base::ScopedCFTypeRef<CFStringRef> name(CopyServiceProcessLaunchDName());
|
||||||
if (needs_restart) {
|
if (needs_restart) {
|
||||||
base::ScopedCFTypeRef<CFMutableDictionaryRef> plist(
|
base::ScopedCFTypeRef<CFMutableDictionaryRef> plist(
|
||||||
Launchd::GetInstance()->CreatePlistFromFile(
|
Launchd::GetInstance()->CreatePlistFromFile(Launchd::User,
|
||||||
Launchd::User, Launchd::Agent, name));
|
Launchd::Agent, name));
|
||||||
if (plist.get()) {
|
if (plist.get()) {
|
||||||
NSMutableDictionary* ns_plist = base::mac::CFToNSCast(plist);
|
NSMutableDictionary* ns_plist = base::mac::CFToNSCast(plist);
|
||||||
NSURL* new_path = [executable_fsref_ filePathURL];
|
NSURL* new_path = [executable_fsref_ filePathURL];
|
||||||
@@ -367,10 +366,8 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
|
|||||||
[ns_plist[@LAUNCH_JOBKEY_PROGRAMARGUMENTS] mutableCopy]);
|
[ns_plist[@LAUNCH_JOBKEY_PROGRAMARGUMENTS] mutableCopy]);
|
||||||
args[0] = ns_new_path;
|
args[0] = ns_new_path;
|
||||||
ns_plist[@LAUNCH_JOBKEY_PROGRAMARGUMENTS] = args;
|
ns_plist[@LAUNCH_JOBKEY_PROGRAMARGUMENTS] = args;
|
||||||
if (!Launchd::GetInstance()->WritePlistToFile(Launchd::User,
|
if (!Launchd::GetInstance()->WritePlistToFile(
|
||||||
Launchd::Agent,
|
Launchd::User, Launchd::Agent, name, plist)) {
|
||||||
name,
|
|
||||||
plist)) {
|
|
||||||
DLOG(ERROR) << "Unable to rewrite plist.";
|
DLOG(ERROR) << "Unable to rewrite plist.";
|
||||||
needs_shutdown = true;
|
needs_shutdown = true;
|
||||||
}
|
}
|
||||||
@@ -388,10 +385,8 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
|
|||||||
// Then deal with the process.
|
// Then deal with the process.
|
||||||
CFStringRef session_type = CFSTR(kServiceProcessSessionType);
|
CFStringRef session_type = CFSTR(kServiceProcessSessionType);
|
||||||
if (needs_restart) {
|
if (needs_restart) {
|
||||||
if (!Launchd::GetInstance()->RestartJob(Launchd::User,
|
if (!Launchd::GetInstance()->RestartJob(Launchd::User, Launchd::Agent,
|
||||||
Launchd::Agent,
|
name, session_type)) {
|
||||||
name,
|
|
||||||
session_type)) {
|
|
||||||
DLOG(ERROR) << "RestartLaunchdJob";
|
DLOG(ERROR) << "RestartLaunchdJob";
|
||||||
needs_shutdown = true;
|
needs_shutdown = true;
|
||||||
}
|
}
|
||||||
@@ -406,4 +401,5 @@ void ExecFilePathWatcherCallback::NotifyPathChanged(const base::FilePath& path,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include "chrome/test/base/in_process_browser_test.h"
|
#include "chrome/test/base/in_process_browser_test.h"
|
||||||
|
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "chrome/browser/devtools/devtools_window.h"
|
#include "chrome/browser/devtools/devtools_window.h"
|
||||||
#include "chrome/browser/profiles/profile.h"
|
#include "chrome/browser/profiles/profile.h"
|
||||||
#include "chrome/browser/ui/browser.h"
|
#include "chrome/browser/ui/browser.h"
|
||||||
@@ -18,19 +17,18 @@ void InProcessBrowserTest::OpenDevToolsWindow(
|
|||||||
content::WebContents* web_contents) {
|
content::WebContents* web_contents) {
|
||||||
// Opening a Devtools Window can cause AppKit to throw objects into the
|
// Opening a Devtools Window can cause AppKit to throw objects into the
|
||||||
// autorelease pool. Flush the pool when this function returns.
|
// autorelease pool. Flush the pool when this function returns.
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
ASSERT_FALSE(content::DevToolsAgentHost::HasFor(web_contents));
|
ASSERT_FALSE(content::DevToolsAgentHost::HasFor(web_contents));
|
||||||
DevToolsWindow::OpenDevToolsWindow(web_contents);
|
DevToolsWindow::OpenDevToolsWindow(web_contents);
|
||||||
ASSERT_TRUE(content::DevToolsAgentHost::HasFor(web_contents));
|
ASSERT_TRUE(content::DevToolsAgentHost::HasFor(web_contents));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile,
|
Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile,
|
||||||
const GURL& url) {
|
const GURL& url) {
|
||||||
// Opening an incognito window can cause AppKit to throw objects into the
|
// Opening an incognito window can cause AppKit to throw objects into the
|
||||||
// autorelease pool. Flush the pool when this function returns.
|
// autorelease pool. Flush the pool when this function returns.
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
chrome::OpenURLOffTheRecord(profile, url);
|
chrome::OpenURLOffTheRecord(profile, url);
|
||||||
Browser* browser =
|
Browser* browser =
|
||||||
chrome::FindTabbedBrowser(profile->GetOffTheRecordProfile(), false);
|
chrome::FindTabbedBrowser(profile->GetOffTheRecordProfile(), false);
|
||||||
@@ -38,6 +36,7 @@ Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile,
|
|||||||
browser->tab_strip_model()->GetActiveWebContents());
|
browser->tab_strip_model()->GetActiveWebContents());
|
||||||
observer.Wait();
|
observer.Wait();
|
||||||
return browser;
|
return browser;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a browser with a single tab (about:blank), waits for the tab to
|
// Creates a browser with a single tab (about:blank), waits for the tab to
|
||||||
@@ -45,18 +44,17 @@ Browser* InProcessBrowserTest::OpenURLOffTheRecord(Profile* profile,
|
|||||||
Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) {
|
Browser* InProcessBrowserTest::CreateBrowser(Profile* profile) {
|
||||||
// Making a browser window can cause AppKit to throw objects into the
|
// Making a browser window can cause AppKit to throw objects into the
|
||||||
// autorelease pool. Flush the pool when this function returns.
|
// autorelease pool. Flush the pool when this function returns.
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
Browser* browser = new Browser(Browser::CreateParams(profile, true));
|
Browser* browser = new Browser(Browser::CreateParams(profile, true));
|
||||||
AddBlankTabAndShow(browser);
|
AddBlankTabAndShow(browser);
|
||||||
return browser;
|
return browser;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Browser* InProcessBrowserTest::CreateIncognitoBrowser(Profile* profile) {
|
Browser* InProcessBrowserTest::CreateIncognitoBrowser(Profile* profile) {
|
||||||
// Making a browser window can cause AppKit to throw objects into the
|
// Making a browser window can cause AppKit to throw objects into the
|
||||||
// autorelease pool. Flush the pool when this function returns.
|
// autorelease pool. Flush the pool when this function returns.
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
// Use active profile if default nullptr was passed.
|
// Use active profile if default nullptr was passed.
|
||||||
if (!profile)
|
if (!profile)
|
||||||
profile = browser()->profile();
|
profile = browser()->profile();
|
||||||
@@ -66,27 +64,28 @@ Browser* InProcessBrowserTest::CreateIncognitoBrowser(Profile* profile) {
|
|||||||
Browser::CreateParams(profile->GetOffTheRecordProfile(), true));
|
Browser::CreateParams(profile->GetOffTheRecordProfile(), true));
|
||||||
AddBlankTabAndShow(incognito);
|
AddBlankTabAndShow(incognito);
|
||||||
return incognito;
|
return incognito;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) {
|
Browser* InProcessBrowserTest::CreateBrowserForPopup(Profile* profile) {
|
||||||
// Making a browser window can cause AppKit to throw objects into the
|
// Making a browser window can cause AppKit to throw objects into the
|
||||||
// autorelease pool. Flush the pool when this function returns.
|
// autorelease pool. Flush the pool when this function returns.
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
Browser* browser =
|
Browser* browser =
|
||||||
new Browser(Browser::CreateParams(Browser::TYPE_POPUP, profile, true));
|
new Browser(Browser::CreateParams(Browser::TYPE_POPUP, profile, true));
|
||||||
AddBlankTabAndShow(browser);
|
AddBlankTabAndShow(browser);
|
||||||
return browser;
|
return browser;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Browser* InProcessBrowserTest::CreateBrowserForApp(const std::string& app_name,
|
Browser* InProcessBrowserTest::CreateBrowserForApp(const std::string& app_name,
|
||||||
Profile* profile) {
|
Profile* profile) {
|
||||||
// Making a browser window can cause AppKit to throw objects into the
|
// Making a browser window can cause AppKit to throw objects into the
|
||||||
// autorelease pool. Flush the pool when this function returns.
|
// autorelease pool. Flush the pool when this function returns.
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
Browser* browser = new Browser(Browser::CreateParams::CreateForApp(
|
Browser* browser = new Browser(Browser::CreateParams::CreateForApp(
|
||||||
app_name, false /* trusted_source */, gfx::Rect(), profile, true));
|
app_name, false /* trusted_source */, gfx::Rect(), profile, true));
|
||||||
AddBlankTabAndShow(browser);
|
AddBlankTabAndShow(browser);
|
||||||
return browser;
|
return browser;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
#include "base/i18n/icu_util.h"
|
#include "base/i18n/icu_util.h"
|
||||||
#include "base/i18n/message_formatter.h"
|
#include "base/i18n/message_formatter.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "base/strings/string_piece.h"
|
#include "base/strings/string_piece.h"
|
||||||
#include "base/strings/string_util.h"
|
#include "base/strings/string_util.h"
|
||||||
@@ -154,8 +153,7 @@ const char kAppType_Helper[] = "helper"; // Helper app
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
int main(int argc, char* const argv[]) {
|
int main(int argc, char* const argv[]) {
|
||||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
const char* version_file_path = NULL;
|
const char* version_file_path = NULL;
|
||||||
const char* grit_output_dir = NULL;
|
const char* grit_output_dir = NULL;
|
||||||
const char* branding_strings_name = NULL;
|
const char* branding_strings_name = NULL;
|
||||||
@@ -338,4 +336,5 @@ int main(int argc, char* const argv[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,24 +7,24 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <UIKit/UIKit.h>
|
#import <UIKit/UIKit.h>
|
||||||
|
|
||||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "components/history/core/test/thumbnail-inl.h"
|
#include "components/history/core/test/thumbnail-inl.h"
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
|
|
||||||
namespace history {
|
namespace history {
|
||||||
|
|
||||||
gfx::Image CreateGoogleThumbnailForTest() {
|
gfx::Image CreateGoogleThumbnailForTest() {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
// -[NSData dataWithBytesNoCopy:length:freeWhenDone:] takes it first parameter
|
// -[NSData dataWithBytesNoCopy:length:freeWhenDone:] takes its first
|
||||||
// as a void* but does not modify it (API is not const clean) so we need to
|
// parameter as a void* but does not modify it (API is not const clean) so
|
||||||
// use const_cast<> here.
|
// we need to use const_cast<> here.
|
||||||
NSData* data =
|
NSData* data = [NSData
|
||||||
[NSData dataWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(
|
dataWithBytesNoCopy:const_cast<void*>(
|
||||||
kGoogleThumbnail))
|
static_cast<const void*>(kGoogleThumbnail))
|
||||||
length:sizeof(kGoogleThumbnail)
|
length:sizeof(kGoogleThumbnail)
|
||||||
freeWhenDone:NO];
|
freeWhenDone:NO];
|
||||||
UIImage* image = [UIImage imageWithData:data scale:1];
|
UIImage* image = [UIImage imageWithData:data scale:1];
|
||||||
return gfx::Image([image retain]);
|
return gfx::Image([image retain]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
#include "base/files/file_path.h"
|
#include "base/files/file_path.h"
|
||||||
#include "base/files/file_util.h"
|
#include "base/files/file_util.h"
|
||||||
#include "base/mac/foundation_util.h"
|
#include "base/mac/foundation_util.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
#include "base/version.h"
|
#include "base/version.h"
|
||||||
@@ -45,29 +44,28 @@ base::Time GetUpdaterSettingsTime(NSString* value_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
base::Version GetVersionFromPlist(const base::FilePath& info_plist) {
|
base::Version GetVersionFromPlist(const base::FilePath& info_plist) {
|
||||||
base::mac::ScopedNSAutoreleasePool scoped_pool;
|
@autoreleasepool {
|
||||||
NSData* data =
|
NSData* data = [NSData
|
||||||
[NSData dataWithContentsOfFile:
|
dataWithContentsOfFile:base::mac::FilePathToNSString(info_plist)];
|
||||||
base::mac::FilePathToNSString(info_plist)];
|
|
||||||
if ([data length] == 0) {
|
if ([data length] == 0) {
|
||||||
return base::Version();
|
return base::Version();
|
||||||
}
|
}
|
||||||
NSDictionary* all_keys = base::mac::ObjCCastStrict<NSDictionary>(
|
NSDictionary* all_keys =
|
||||||
[NSPropertyListSerialization propertyListWithData:data
|
base::mac::ObjCCastStrict<NSDictionary>([NSPropertyListSerialization
|
||||||
|
propertyListWithData:data
|
||||||
options:NSPropertyListImmutable
|
options:NSPropertyListImmutable
|
||||||
format:nil
|
format:nil
|
||||||
error:nil]);
|
error:nil]);
|
||||||
if (all_keys == nil) {
|
if (all_keys == nil) {
|
||||||
return base::Version();
|
return base::Version();
|
||||||
}
|
}
|
||||||
CFStringRef version =
|
CFStringRef version = base::mac::GetValueFromDictionary<CFStringRef>(
|
||||||
base::mac::GetValueFromDictionary<CFStringRef>(
|
base::mac::NSToCFCast(all_keys), kCFBundleVersionKey);
|
||||||
base::mac::NSToCFCast(all_keys),
|
|
||||||
kCFBundleVersionKey);
|
|
||||||
if (version == NULL) {
|
if (version == NULL) {
|
||||||
return base::Version();
|
return base::Version();
|
||||||
}
|
}
|
||||||
return base::Version(base::SysCFStringRefToUTF8(version));
|
return base::Version(base::SysCFStringRefToUTF8(version));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
#include "content/browser/renderer_host/input/synthetic_gesture_target_mac.h"
|
#include "content/browser/renderer_host/input/synthetic_gesture_target_mac.h"
|
||||||
|
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
#include "content/browser/renderer_host/render_widget_host_impl.h"
|
||||||
#include "content/browser/renderer_host/render_widget_host_input_event_router.h"
|
#include "content/browser/renderer_host/render_widget_host_input_event_router.h"
|
||||||
#import "content/app_shim_remote_cocoa/render_widget_host_view_cocoa.h"
|
#import "content/app_shim_remote_cocoa/render_widget_host_view_cocoa.h"
|
||||||
@@ -88,13 +87,12 @@ void SyntheticGestureTargetMac::DispatchWebGestureEventToPlatform(
|
|||||||
const ui::LatencyInfo& latency_info) {
|
const ui::LatencyInfo& latency_info) {
|
||||||
// Create an autorelease pool so that we clean up any synthetic events we
|
// Create an autorelease pool so that we clean up any synthetic events we
|
||||||
// generate.
|
// generate.
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
NSPoint content_local = NSMakePoint(
|
NSPoint content_local = NSMakePoint(
|
||||||
web_gesture.PositionInWidget().x,
|
web_gesture.PositionInWidget().x,
|
||||||
[cocoa_view_ frame].size.height - web_gesture.PositionInWidget().y);
|
[cocoa_view_ frame].size.height - web_gesture.PositionInWidget().y);
|
||||||
NSPoint location_in_window =
|
NSPoint location_in_window = [cocoa_view_ convertPoint:content_local
|
||||||
[cocoa_view_ convertPoint:content_local toView:nil];
|
toView:nil];
|
||||||
|
|
||||||
switch (web_gesture.GetType()) {
|
switch (web_gesture.GetType()) {
|
||||||
case WebInputEvent::kGesturePinchBegin: {
|
case WebInputEvent::kGesturePinchBegin: {
|
||||||
@@ -125,6 +123,7 @@ void SyntheticGestureTargetMac::DispatchWebGestureEventToPlatform(
|
|||||||
default:
|
default:
|
||||||
NOTREACHED();
|
NOTREACHED();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SyntheticGestureTargetMac::DispatchWebTouchEventToPlatform(
|
void SyntheticGestureTargetMac::DispatchWebTouchEventToPlatform(
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
|
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/stl_util.h"
|
#include "base/stl_util.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
|
#include "ppapi/c/dev/ppb_truetype_font_dev.h"
|
||||||
@@ -36,18 +35,19 @@ const NSInteger kPepperFontWeightsLength = base::size(kPepperFontWeights);
|
|||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void GetFontFamilies_SlowBlocking(std::vector<std::string>* font_families) {
|
void GetFontFamilies_SlowBlocking(std::vector<std::string>* font_families) {
|
||||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
@autoreleasepool {
|
||||||
NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease];
|
NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease];
|
||||||
NSArray* fonts = [fontManager availableFontFamilies];
|
NSArray* fonts = [fontManager availableFontFamilies];
|
||||||
font_families->reserve([fonts count]);
|
font_families->reserve([fonts count]);
|
||||||
for (NSString* family_name in fonts)
|
for (NSString* family_name in fonts)
|
||||||
font_families->push_back(base::SysNSStringToUTF8(family_name));
|
font_families->push_back(base::SysNSStringToUTF8(family_name));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetFontsInFamily_SlowBlocking(
|
void GetFontsInFamily_SlowBlocking(
|
||||||
const std::string& family,
|
const std::string& family,
|
||||||
std::vector<ppapi::proxy::SerializedTrueTypeFontDesc>* fonts_in_family) {
|
std::vector<ppapi::proxy::SerializedTrueTypeFontDesc>* fonts_in_family) {
|
||||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
@autoreleasepool {
|
||||||
NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease];
|
NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease];
|
||||||
NSString* ns_family = base::SysUTF8ToNSString(family);
|
NSString* ns_family = base::SysUTF8ToNSString(family);
|
||||||
NSArray* ns_fonts_in_family =
|
NSArray* ns_fonts_in_family =
|
||||||
@@ -78,6 +78,7 @@ void GetFontsInFamily_SlowBlocking(
|
|||||||
|
|
||||||
fonts_in_family->push_back(desc);
|
fonts_in_family->push_back(desc);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace content
|
} // namespace content
|
||||||
|
@@ -140,8 +140,7 @@ TEST_F(RenderWidgetHostViewMacEditCommandHelperWithTaskEnvTest,
|
|||||||
supported_factors.push_back(ui::SCALE_FACTOR_100P);
|
supported_factors.push_back(ui::SCALE_FACTOR_100P);
|
||||||
ui::test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
|
ui::test::ScopedSetSupportedScaleFactors scoped_supported(supported_factors);
|
||||||
|
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
int32_t routing_id = process_host->GetNextRoutingID();
|
int32_t routing_id = process_host->GetNextRoutingID();
|
||||||
mojom::WidgetPtr widget;
|
mojom::WidgetPtr widget;
|
||||||
std::unique_ptr<MockWidgetImpl> widget_impl =
|
std::unique_ptr<MockWidgetImpl> widget_impl =
|
||||||
@@ -153,8 +152,8 @@ TEST_F(RenderWidgetHostViewMacEditCommandHelperWithTaskEnvTest,
|
|||||||
ui::WindowResizeHelperMac::Get()->Init(base::ThreadTaskRunnerHandle::Get());
|
ui::WindowResizeHelperMac::Get()->Init(base::ThreadTaskRunnerHandle::Get());
|
||||||
|
|
||||||
// Owned by its |GetInProcessNSView()|, i.e. |rwhv_cocoa|.
|
// Owned by its |GetInProcessNSView()|, i.e. |rwhv_cocoa|.
|
||||||
RenderWidgetHostViewMac* rwhv_mac = new RenderWidgetHostViewMac(
|
RenderWidgetHostViewMac* rwhv_mac =
|
||||||
render_widget, false);
|
new RenderWidgetHostViewMac(render_widget, false);
|
||||||
base::scoped_nsobject<RenderWidgetHostViewCocoa> rwhv_cocoa(
|
base::scoped_nsobject<RenderWidgetHostViewCocoa> rwhv_cocoa(
|
||||||
[rwhv_mac->GetInProcessNSView() retain]);
|
[rwhv_mac->GetInProcessNSView() retain]);
|
||||||
|
|
||||||
@@ -168,16 +167,17 @@ TEST_F(RenderWidgetHostViewMacEditCommandHelperWithTaskEnvTest,
|
|||||||
|
|
||||||
for (NSString* edit_command_name in edit_command_strings) {
|
for (NSString* edit_command_name in edit_command_strings) {
|
||||||
NSString* sel_str = [edit_command_name stringByAppendingString:@":"];
|
NSString* sel_str = [edit_command_name stringByAppendingString:@":"];
|
||||||
[rwhwvm_owner performSelector:NSSelectorFromString(sel_str) withObject:nil];
|
[rwhwvm_owner performSelector:NSSelectorFromString(sel_str)
|
||||||
|
withObject:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t num_edit_commands = [edit_command_strings count];
|
size_t num_edit_commands = [edit_command_strings count];
|
||||||
EXPECT_EQ(delegate.edit_command_message_count_, num_edit_commands);
|
EXPECT_EQ(delegate.edit_command_message_count_, num_edit_commands);
|
||||||
rwhv_cocoa.reset();
|
rwhv_cocoa.reset();
|
||||||
pool.Recycle();
|
|
||||||
|
|
||||||
// The |render_widget|'s process needs to be deleted within |message_loop|.
|
// The |render_widget|'s process needs to be deleted within |message_loop|.
|
||||||
delete render_widget;
|
delete render_widget;
|
||||||
|
}
|
||||||
|
|
||||||
ui::WindowResizeHelperMac::Get()->ShutdownForTests();
|
ui::WindowResizeHelperMac::Get()->ShutdownForTests();
|
||||||
}
|
}
|
||||||
|
@@ -8,14 +8,13 @@
|
|||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
#include "base/values.h"
|
#include "base/values.h"
|
||||||
|
|
||||||
namespace content {
|
namespace content {
|
||||||
|
|
||||||
std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() {
|
std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() {
|
||||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
@autoreleasepool {
|
||||||
std::unique_ptr<base::ListValue> font_list(new base::ListValue);
|
std::unique_ptr<base::ListValue> font_list(new base::ListValue);
|
||||||
NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease];
|
NSFontManager* fontManager = [[[NSFontManager alloc] init] autorelease];
|
||||||
NSMutableDictionary* fonts_dict = [NSMutableDictionary dictionary];
|
NSMutableDictionary* fonts_dict = [NSMutableDictionary dictionary];
|
||||||
@@ -40,6 +39,7 @@ std::unique_ptr<base::ListValue> GetFontList_SlowBlocking() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return font_list;
|
return font_list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace content
|
} // namespace content
|
||||||
|
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/mac/scoped_cftyperef.h"
|
#include "base/mac/scoped_cftyperef.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/memory/ptr_util.h"
|
#include "base/memory/ptr_util.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
#include "base/strings/utf_string_conversions.h"
|
#include "base/strings/utf_string_conversions.h"
|
||||||
@@ -87,13 +86,12 @@ void PrintingContextMac::AskUserForSettings(int max_pages,
|
|||||||
PrintSettingsCallback callback) {
|
PrintSettingsCallback callback) {
|
||||||
// Exceptions can also happen when the NSPrintPanel is being
|
// Exceptions can also happen when the NSPrintPanel is being
|
||||||
// deallocated, so it must be autoreleased within this scope.
|
// deallocated, so it must be autoreleased within this scope.
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
DCHECK([NSThread isMainThread]);
|
DCHECK([NSThread isMainThread]);
|
||||||
|
|
||||||
// We deliberately don't feed max_pages into the dialog, because setting
|
// We deliberately don't feed max_pages into the dialog, because setting
|
||||||
// NSPrintLastPage makes the print dialog pre-select the option to only print
|
// NSPrintLastPage makes the print dialog pre-select the option to only
|
||||||
// a range.
|
// print a range.
|
||||||
|
|
||||||
// TODO(stuartmorgan): implement 'print selection only' (probably requires
|
// TODO(stuartmorgan): implement 'print selection only' (probably requires
|
||||||
// adding a new custom view to the panel on 10.5; 10.6 has
|
// adding a new custom view to the panel on 10.5; 10.6 has
|
||||||
@@ -124,8 +122,8 @@ void PrintingContextMac::AskUserForSettings(int max_pages,
|
|||||||
|
|
||||||
// This function may be called in the middle of a CATransaction, where
|
// This function may be called in the middle of a CATransaction, where
|
||||||
// running a modal panel is forbidden. That situation isn't ideal, but from
|
// running a modal panel is forbidden. That situation isn't ideal, but from
|
||||||
// this code's POV the right answer is to defer running the panel until after
|
// this code's POV the right answer is to defer running the panel until
|
||||||
// the current transaction. See https://crbug.com/849538.
|
// after the current transaction. See https://crbug.com/849538.
|
||||||
__block auto block_callback = std::move(callback);
|
__block auto block_callback = std::move(callback);
|
||||||
[CATransaction setCompletionBlock:^{
|
[CATransaction setCompletionBlock:^{
|
||||||
NSInteger selection = [panel runModalWithPrintInfo:printInfo];
|
NSInteger selection = [panel runModalWithPrintInfo:printInfo];
|
||||||
@@ -138,6 +136,7 @@ void PrintingContextMac::AskUserForSettings(int max_pages,
|
|||||||
std::move(block_callback).Run(CANCEL);
|
std::move(block_callback).Run(CANCEL);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gfx::Size PrintingContextMac::GetPdfPaperSizeDeviceUnits() {
|
gfx::Size PrintingContextMac::GetPdfPaperSizeDeviceUnits() {
|
||||||
|
@@ -7,22 +7,20 @@
|
|||||||
#include <Foundation/Foundation.h>
|
#include <Foundation/Foundation.h>
|
||||||
|
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#import "third_party/breakpad/breakpad/src/client/mac/Framework/Breakpad.h"
|
#import "third_party/breakpad/breakpad/src/client/mac/Framework/Breakpad.h"
|
||||||
|
|
||||||
namespace remoting {
|
namespace remoting {
|
||||||
|
|
||||||
void InitializeCrashReporting() {
|
void InitializeCrashReporting() {
|
||||||
base::mac::ScopedNSAutoreleasePool autorelease_pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
NSBundle* main_bundle = [NSBundle mainBundle];
|
NSBundle* main_bundle = [NSBundle mainBundle];
|
||||||
|
|
||||||
// Tell Breakpad where crash_inspector and crash_report_sender are.
|
// Tell Breakpad where crash_inspector and crash_report_sender are.
|
||||||
NSString* resource_path = [main_bundle resourcePath];
|
NSString* resource_path = [main_bundle resourcePath];
|
||||||
NSString* inspector_location =
|
NSString* inspector_location =
|
||||||
[resource_path stringByAppendingPathComponent:@"crash_inspector"];
|
[resource_path stringByAppendingPathComponent:@"crash_inspector"];
|
||||||
NSString* reporter_bundle_location =
|
NSString* reporter_bundle_location = [resource_path
|
||||||
[resource_path stringByAppendingPathComponent:@"crash_report_sender.app"];
|
stringByAppendingPathComponent:@"crash_report_sender.app"];
|
||||||
NSString* reporter_location =
|
NSString* reporter_location =
|
||||||
[[NSBundle bundleWithPath:reporter_bundle_location] executablePath];
|
[[NSBundle bundleWithPath:reporter_bundle_location] executablePath];
|
||||||
|
|
||||||
@@ -46,14 +44,12 @@ void InitializeCrashReporting() {
|
|||||||
// service that shouldn't rely on a console user to dismiss any prompt.
|
// service that shouldn't rely on a console user to dismiss any prompt.
|
||||||
// Also, this may be running in the LoginWindow context, where prompting
|
// Also, this may be running in the LoginWindow context, where prompting
|
||||||
// might not be possible.
|
// might not be possible.
|
||||||
[breakpad_config setObject:@"YES"
|
[breakpad_config setObject:@"YES" forKey:@BREAKPAD_SKIP_CONFIRM];
|
||||||
forKey:@BREAKPAD_SKIP_CONFIRM];
|
|
||||||
}
|
}
|
||||||
if (![breakpad_config objectForKey:@BREAKPAD_REPORT_INTERVAL]) {
|
if (![breakpad_config objectForKey:@BREAKPAD_REPORT_INTERVAL]) {
|
||||||
// Set a minimum 6-hour interval between crash-reports, to match the
|
// Set a minimum 6-hour interval between crash-reports, to match the
|
||||||
// throttling used on Windows.
|
// throttling used on Windows.
|
||||||
[breakpad_config setObject:@"21600"
|
[breakpad_config setObject:@"21600" forKey:@BREAKPAD_REPORT_INTERVAL];
|
||||||
forKey:@BREAKPAD_REPORT_INTERVAL];
|
|
||||||
}
|
}
|
||||||
if (![breakpad_config objectForKey:@BREAKPAD_URL]) {
|
if (![breakpad_config objectForKey:@BREAKPAD_URL]) {
|
||||||
[breakpad_config setObject:@"https://clients2.google.com/cr/report"
|
[breakpad_config setObject:@"https://clients2.google.com/cr/report"
|
||||||
@@ -63,6 +59,7 @@ void InitializeCrashReporting() {
|
|||||||
if (!BreakpadCreate(breakpad_config)) {
|
if (!BreakpadCreate(breakpad_config)) {
|
||||||
LOG(ERROR) << "Breakpad initialization failed";
|
LOG(ERROR) << "Breakpad initialization failed";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace remoting
|
} // namespace remoting
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
#include "base/compiler_specific.h"
|
#include "base/compiler_specific.h"
|
||||||
#include "base/logging.h"
|
#include "base/logging.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
@@ -62,17 +61,19 @@ ContinueWindowMac::~ContinueWindowMac() {
|
|||||||
void ContinueWindowMac::ShowUi() {
|
void ContinueWindowMac::ShowUi() {
|
||||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||||
|
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
controller_.reset(
|
controller_.reset(
|
||||||
[[ContinueWindowMacController alloc] initWithWindow:this]);
|
[[ContinueWindowMacController alloc] initWithWindow:this]);
|
||||||
[controller_ show];
|
[controller_ show];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContinueWindowMac::HideUi() {
|
void ContinueWindowMac::HideUi() {
|
||||||
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
||||||
|
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
[controller_ hide];
|
[controller_ hide];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
|
@@ -14,7 +14,6 @@
|
|||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#include "base/i18n/message_formatter.h"
|
#include "base/i18n/message_formatter.h"
|
||||||
#include "base/location.h"
|
#include "base/location.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/strings/sys_string_conversions.h"
|
#include "base/strings/sys_string_conversions.h"
|
||||||
@@ -76,9 +75,10 @@ It2MeConfirmationDialogMac::~It2MeConfirmationDialogMac() {
|
|||||||
dialog_timer_.Stop();
|
dialog_timer_.Stop();
|
||||||
|
|
||||||
if (controller_) {
|
if (controller_) {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
[controller_ hide];
|
[controller_ hide];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void It2MeConfirmationDialogMac::Show(const std::string& remote_user_email,
|
void It2MeConfirmationDialogMac::Show(const std::string& remote_user_email,
|
||||||
@@ -92,21 +92,23 @@ void It2MeConfirmationDialogMac::Show(const std::string& remote_user_email,
|
|||||||
ResultCallback dialog_action_callback = base::Bind(
|
ResultCallback dialog_action_callback = base::Bind(
|
||||||
&It2MeConfirmationDialogMac::OnDialogAction, base::Unretained(this));
|
&It2MeConfirmationDialogMac::OnDialogAction, base::Unretained(this));
|
||||||
|
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
controller_.reset([[It2MeConfirmationDialogMacController alloc]
|
controller_.reset([[It2MeConfirmationDialogMacController alloc]
|
||||||
initWithCallback:dialog_action_callback
|
initWithCallback:dialog_action_callback
|
||||||
username:remote_user_email]);
|
username:remote_user_email]);
|
||||||
[controller_ show];
|
[controller_ show];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void It2MeConfirmationDialogMac::OnDialogAction(Result result) {
|
void It2MeConfirmationDialogMac::OnDialogAction(Result result) {
|
||||||
dialog_timer_.Stop();
|
dialog_timer_.Stop();
|
||||||
|
|
||||||
if (controller_) {
|
if (controller_) {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
[controller_ hide];
|
[controller_ hide];
|
||||||
controller_.reset();
|
controller_.reset();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (result_callback_) {
|
if (result_callback_) {
|
||||||
std::move(result_callback_).Run(result);
|
std::move(result_callback_).Run(result);
|
||||||
|
@@ -353,15 +353,15 @@ RlzValueStore* ScopedRlzValueStoreLock::GetStore() {
|
|||||||
namespace testing {
|
namespace testing {
|
||||||
|
|
||||||
void SetRlzStoreDirectory(const base::FilePath& directory) {
|
void SetRlzStoreDirectory(const base::FilePath& directory) {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
[g_test_folder release];
|
[g_test_folder release];
|
||||||
if (directory.empty()) {
|
if (directory.empty()) {
|
||||||
g_test_folder = nil;
|
g_test_folder = nil;
|
||||||
} else {
|
} else {
|
||||||
// Not Unsafe on OS X.
|
// Not Unsafe on OS X.
|
||||||
g_test_folder =
|
g_test_folder = [[NSString alloc]
|
||||||
[[NSString alloc] initWithUTF8String:directory.AsUTF8Unsafe().c_str()];
|
initWithUTF8String:directory.AsUTF8Unsafe().c_str()];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
|
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#include "base/memory/ptr_util.h"
|
#include "base/memory/ptr_util.h"
|
||||||
@@ -45,10 +44,10 @@ class CoreWlanApi : public WifiDataProviderCommon::WlanApiInterface {
|
|||||||
};
|
};
|
||||||
|
|
||||||
bool CoreWlanApi::GetAccessPointData(WifiData::AccessPointDataSet* data) {
|
bool CoreWlanApi::GetAccessPointData(WifiData::AccessPointDataSet* data) {
|
||||||
base::mac::ScopedNSAutoreleasePool auto_pool;
|
@autoreleasepool { // Initialize the scan parameters with scan key merging
|
||||||
// Initialize the scan parameters with scan key merging disabled, so we get
|
// disabled, so we get
|
||||||
// every AP listed in the scan without any SSID de-duping logic.
|
// every AP listed in the scan without any SSID de-duping logic.
|
||||||
NSDictionary* params = @{ kCWScanKeyMerge : @NO };
|
NSDictionary* params = @{kCWScanKeyMerge : @NO};
|
||||||
|
|
||||||
NSSet* supported_interfaces = [CWInterface interfaceNames];
|
NSSet* supported_interfaces = [CWInterface interfaceNames];
|
||||||
NSUInteger interface_error_count = 0;
|
NSUInteger interface_error_count = 0;
|
||||||
@@ -64,8 +63,8 @@ bool CoreWlanApi::GetAccessPointData(WifiData::AccessPointDataSet* data) {
|
|||||||
const base::TimeTicks start_time = base::TimeTicks::Now();
|
const base::TimeTicks start_time = base::TimeTicks::Now();
|
||||||
|
|
||||||
NSError* err = nil;
|
NSError* err = nil;
|
||||||
NSArray* scan =
|
NSArray* scan = [corewlan_interface scanForNetworksWithParameters:params
|
||||||
[corewlan_interface scanForNetworksWithParameters:params error:&err];
|
error:&err];
|
||||||
const int error_code = [err code];
|
const int error_code = [err code];
|
||||||
const int count = [scan count];
|
const int count = [scan count];
|
||||||
// We could get an error code but count != 0 if the scan was interrupted,
|
// We could get an error code but count != 0 if the scan was interrupted,
|
||||||
@@ -90,13 +89,14 @@ bool CoreWlanApi::GetAccessPointData(WifiData::AccessPointDataSet* data) {
|
|||||||
AccessPointData access_point_data;
|
AccessPointData access_point_data;
|
||||||
// -[CWNetwork bssid] uses colons to separate the components of the MAC
|
// -[CWNetwork bssid] uses colons to separate the components of the MAC
|
||||||
// address, but AccessPointData requires they be separated with a dash.
|
// address, but AccessPointData requires they be separated with a dash.
|
||||||
access_point_data.mac_address = base::SysNSStringToUTF16([[network bssid]
|
access_point_data.mac_address = base::SysNSStringToUTF16(
|
||||||
stringByReplacingOccurrencesOfString:@":"
|
[[network bssid] stringByReplacingOccurrencesOfString:@":"
|
||||||
withString:@"-"]);
|
withString:@"-"]);
|
||||||
access_point_data.radio_signal_strength = [network rssiValue];
|
access_point_data.radio_signal_strength = [network rssiValue];
|
||||||
access_point_data.channel = [[network wlanChannel] channelNumber];
|
access_point_data.channel = [[network wlanChannel] channelNumber];
|
||||||
access_point_data.signal_to_noise =
|
access_point_data.signal_to_noise =
|
||||||
access_point_data.radio_signal_strength - [network noiseMeasurement];
|
access_point_data.radio_signal_strength -
|
||||||
|
[network noiseMeasurement];
|
||||||
access_point_data.ssid = base::SysNSStringToUTF16([network ssid]);
|
access_point_data.ssid = base::SysNSStringToUTF16([network ssid]);
|
||||||
data->insert(access_point_data);
|
data->insert(access_point_data);
|
||||||
}
|
}
|
||||||
@@ -110,6 +110,7 @@ bool CoreWlanApi::GetAccessPointData(WifiData::AccessPointDataSet* data) {
|
|||||||
// one interface did not fail.
|
// one interface did not fail.
|
||||||
return interface_error_count == 0 ||
|
return interface_error_count == 0 ||
|
||||||
[supported_interfaces count] > interface_error_count;
|
[supported_interfaces count] > interface_error_count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The time periods, in milliseconds, between successive polls of the wifi data.
|
// The time periods, in milliseconds, between successive polls of the wifi data.
|
||||||
|
@@ -26,7 +26,6 @@
|
|||||||
#include "base/mac/mac_util.h"
|
#include "base/mac/mac_util.h"
|
||||||
#include "base/mac/mach_port_rendezvous.h"
|
#include "base/mac/mach_port_rendezvous.h"
|
||||||
#include "base/mac/scoped_cftyperef.h"
|
#include "base/mac/scoped_cftyperef.h"
|
||||||
#include "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "base/mac/scoped_nsobject.h"
|
#include "base/mac/scoped_nsobject.h"
|
||||||
#include "base/rand_util.h"
|
#include "base/rand_util.h"
|
||||||
#include "base/stl_util.h"
|
#include "base/stl_util.h"
|
||||||
@@ -83,8 +82,7 @@ const char* SandboxMac::kSandboxBundleVersionPath = "BUNDLE_VERSION_PATH";
|
|||||||
void SandboxMac::Warmup(SandboxType sandbox_type) {
|
void SandboxMac::Warmup(SandboxType sandbox_type) {
|
||||||
DCHECK_EQ(sandbox_type, SANDBOX_TYPE_GPU);
|
DCHECK_EQ(sandbox_type, SANDBOX_TYPE_GPU);
|
||||||
|
|
||||||
base::mac::ScopedNSAutoreleasePool scoped_pool;
|
@autoreleasepool {
|
||||||
|
|
||||||
{ // CGColorSpaceCreateWithName(), CGBitmapContextCreate() - 10.5.6
|
{ // CGColorSpaceCreateWithName(), CGBitmapContextCreate() - 10.5.6
|
||||||
base::ScopedCFTypeRef<CGColorSpaceRef> rgb_colorspace(
|
base::ScopedCFTypeRef<CGColorSpaceRef> rgb_colorspace(
|
||||||
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB));
|
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB));
|
||||||
@@ -109,7 +107,8 @@ void SandboxMac::Warmup(SandboxType sandbox_type) {
|
|||||||
localtime(&tv);
|
localtime(&tv);
|
||||||
}
|
}
|
||||||
|
|
||||||
{ // Gestalt() tries to read /System/Library/CoreServices/SystemVersion.plist
|
{ // Gestalt() tries to read
|
||||||
|
// /System/Library/CoreServices/SystemVersion.plist
|
||||||
// on 10.5.6
|
// on 10.5.6
|
||||||
int32_t tmp;
|
int32_t tmp;
|
||||||
base::SysInfo::OperatingSystemVersionNumbers(&tmp, &tmp, &tmp);
|
base::SysInfo::OperatingSystemVersionNumbers(&tmp, &tmp, &tmp);
|
||||||
@@ -134,6 +133,7 @@ void SandboxMac::Warmup(SandboxType sandbox_type) {
|
|||||||
// Needed by zero-copy texture update framework - crbug.com/323338
|
// Needed by zero-copy texture update framework - crbug.com/323338
|
||||||
base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceLookup(0));
|
base::ScopedCFTypeRef<IOSurfaceRef> io_surface(IOSurfaceLookup(0));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the appropriate template for the given sandbox type.
|
// Load the appropriate template for the given sandbox type.
|
||||||
|
@@ -212,8 +212,7 @@ void CocoaTest::TearDown() {
|
|||||||
([start_date timeIntervalSinceNow] > -kCloseTimeoutSeconds);
|
([start_date timeIntervalSinceNow] > -kCloseTimeoutSeconds);
|
||||||
|
|
||||||
// Autorelease anything thrown up by the event loop.
|
// Autorelease anything thrown up by the event loop.
|
||||||
{
|
@autoreleasepool {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
++spins;
|
++spins;
|
||||||
NSEvent* next_event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
NSEvent* next_event = [NSApp nextEventMatchingMask:NSAnyEventMask
|
||||||
untilDate:nil
|
untilDate:nil
|
||||||
@@ -253,12 +252,13 @@ std::set<NSWindow*> CocoaTest::ApplicationWindows() {
|
|||||||
|
|
||||||
// Must create a pool here because [NSApp windows] has created an array
|
// Must create a pool here because [NSApp windows] has created an array
|
||||||
// with retains on all the windows in it.
|
// with retains on all the windows in it.
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
@autoreleasepool {
|
||||||
NSArray* appWindows = [NSApp windows];
|
NSArray* appWindows = [NSApp windows];
|
||||||
for (NSWindow* window in appWindows) {
|
for (NSWindow* window in appWindows) {
|
||||||
windows.insert(window);
|
windows.insert(window);
|
||||||
}
|
}
|
||||||
return windows;
|
return windows;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<NSWindow*> CocoaTest::WindowsLeft() {
|
std::set<NSWindow*> CocoaTest::WindowsLeft() {
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#import "base/mac/scoped_nsobject.h"
|
#import "base/mac/scoped_nsobject.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
#import "testing/gtest_mac.h"
|
#import "testing/gtest_mac.h"
|
||||||
@@ -220,8 +219,7 @@ TEST_F(NativeViewHostMacTest, NativeViewHidden) {
|
|||||||
// Check that we can destroy cleanly even if the native view has already been
|
// Check that we can destroy cleanly even if the native view has already been
|
||||||
// released.
|
// released.
|
||||||
TEST_F(NativeViewHostMacTest, NativeViewReleased) {
|
TEST_F(NativeViewHostMacTest, NativeViewReleased) {
|
||||||
{
|
@autoreleasepool {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
CreateHost();
|
CreateHost();
|
||||||
// In practice the native view is a WebContentsViewCocoa which is retained
|
// In practice the native view is a WebContentsViewCocoa which is retained
|
||||||
// by its superview (a TabContentsContainerView) and by WebContentsViewMac.
|
// by its superview (a TabContentsContainerView) and by WebContentsViewMac.
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
|
|
||||||
#include "base/bind.h"
|
#include "base/bind.h"
|
||||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#include "ui/base/test/scoped_fake_full_keyboard_access.h"
|
#include "ui/base/test/scoped_fake_full_keyboard_access.h"
|
||||||
#include "ui/base/test/scoped_fake_nswindow_focus.h"
|
#include "ui/base/test/scoped_fake_nswindow_focus.h"
|
||||||
#include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
|
#include "ui/base/test/scoped_fake_nswindow_fullscreen.h"
|
||||||
@@ -63,13 +62,14 @@ void ViewsTestHelperMac::TearDown() {
|
|||||||
// this is handled automatically by views::Widget::CloseAllSecondaryWidgets().
|
// this is handled automatically by views::Widget::CloseAllSecondaryWidgets().
|
||||||
// Unit tests on Aura may create Widgets owned by a RootWindow that gets torn
|
// Unit tests on Aura may create Widgets owned by a RootWindow that gets torn
|
||||||
// down, but on Mac we need to be more explicit.
|
// down, but on Mac we need to be more explicit.
|
||||||
base::mac::ScopedNSAutoreleasePool pool; // Ensure the NSArray is released.
|
@autoreleasepool {
|
||||||
NSArray* native_windows = [NSApp windows];
|
NSArray* native_windows = [NSApp windows];
|
||||||
for (NSWindow* window : native_windows)
|
for (NSWindow* window : native_windows)
|
||||||
DCHECK(!Widget::GetWidgetForNativeWindow(window)) << "Widget not closed.";
|
DCHECK(!Widget::GetWidgetForNativeWindow(window)) << "Widget not closed.";
|
||||||
|
|
||||||
ui::test::EventGeneratorDelegate::SetFactoryFunction(
|
ui::test::EventGeneratorDelegate::SetFactoryFunction(
|
||||||
ui::test::EventGeneratorDelegate::FactoryFunction());
|
ui::test::EventGeneratorDelegate::FactoryFunction());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace views
|
} // namespace views
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
#include "base/callback.h"
|
#include "base/callback.h"
|
||||||
#import "base/mac/foundation_util.h"
|
#import "base/mac/foundation_util.h"
|
||||||
#include "base/mac/mac_util.h"
|
#include "base/mac/mac_util.h"
|
||||||
#import "base/mac/scoped_nsautorelease_pool.h"
|
|
||||||
#import "base/mac/scoped_nsobject.h"
|
#import "base/mac/scoped_nsobject.h"
|
||||||
#import "base/mac/scoped_objc_class_swizzler.h"
|
#import "base/mac/scoped_objc_class_swizzler.h"
|
||||||
#include "base/macros.h"
|
#include "base/macros.h"
|
||||||
@@ -817,10 +816,9 @@ TEST_F(NativeWidgetMacTest, NonWidgetParent) {
|
|||||||
TEST_F(NativeWidgetMacTest, CloseAllSecondaryWidgetsValidState) {
|
TEST_F(NativeWidgetMacTest, CloseAllSecondaryWidgetsValidState) {
|
||||||
NativeWidgetMacTestWindow* last_window = nil;
|
NativeWidgetMacTestWindow* last_window = nil;
|
||||||
bool window_deallocated = false;
|
bool window_deallocated = false;
|
||||||
{
|
@autoreleasepool {
|
||||||
// First verify the behavior of CloseAllSecondaryWidgets in the normal case,
|
// First verify the behavior of CloseAllSecondaryWidgets in the normal case,
|
||||||
// and how [NSApp windows] changes in response to Widget closure.
|
// and how [NSApp windows] changes in response to Widget closure.
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
Widget* widget = CreateWidgetWithTestWindow(
|
Widget* widget = CreateWidgetWithTestWindow(
|
||||||
Widget::InitParams(Widget::InitParams::TYPE_WINDOW), &last_window);
|
Widget::InitParams(Widget::InitParams::TYPE_WINDOW), &last_window);
|
||||||
last_window.deallocFlag = &window_deallocated;
|
last_window.deallocFlag = &window_deallocated;
|
||||||
@@ -833,10 +831,9 @@ TEST_F(NativeWidgetMacTest, CloseAllSecondaryWidgetsValidState) {
|
|||||||
EXPECT_TRUE(window_deallocated);
|
EXPECT_TRUE(window_deallocated);
|
||||||
window_deallocated = false;
|
window_deallocated = false;
|
||||||
|
|
||||||
{
|
@autoreleasepool {
|
||||||
// Repeat, but now retain a reference and close the window before
|
// Repeat, but now retain a reference and close the window before
|
||||||
// CloseAllSecondaryWidgets().
|
// CloseAllSecondaryWidgets().
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
Widget* widget = CreateWidgetWithTestWindow(
|
Widget* widget = CreateWidgetWithTestWindow(
|
||||||
Widget::InitParams(Widget::InitParams::TYPE_WINDOW), &last_window);
|
Widget::InitParams(Widget::InitParams::TYPE_WINDOW), &last_window);
|
||||||
last_window.deallocFlag = &window_deallocated;
|
last_window.deallocFlag = &window_deallocated;
|
||||||
@@ -847,8 +844,7 @@ TEST_F(NativeWidgetMacTest, CloseAllSecondaryWidgetsValidState) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EXPECT_FALSE(window_deallocated);
|
EXPECT_FALSE(window_deallocated);
|
||||||
{
|
@autoreleasepool {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
Widget::CloseAllSecondaryWidgets();
|
Widget::CloseAllSecondaryWidgets();
|
||||||
[last_window release];
|
[last_window release];
|
||||||
}
|
}
|
||||||
@@ -880,8 +876,7 @@ TEST_F(NativeWidgetMacTest, NonWidgetParentLastReference) {
|
|||||||
bool child_dealloced = false;
|
bool child_dealloced = false;
|
||||||
bool native_parent_dealloced = false;
|
bool native_parent_dealloced = false;
|
||||||
NativeWidgetMacTestWindow* native_parent = nil;
|
NativeWidgetMacTestWindow* native_parent = nil;
|
||||||
{
|
@autoreleasepool {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
native_parent = MakeBorderlessNativeParent();
|
native_parent = MakeBorderlessNativeParent();
|
||||||
[native_parent setDeallocFlag:&native_parent_dealloced];
|
[native_parent setDeallocFlag:&native_parent_dealloced];
|
||||||
|
|
||||||
@@ -893,13 +888,12 @@ TEST_F(NativeWidgetMacTest, NonWidgetParentLastReference) {
|
|||||||
CreateWidgetWithTestWindow(std::move(init_params), &window);
|
CreateWidgetWithTestWindow(std::move(init_params), &window);
|
||||||
[window setDeallocFlag:&child_dealloced];
|
[window setDeallocFlag:&child_dealloced];
|
||||||
}
|
}
|
||||||
{
|
@autoreleasepool {
|
||||||
// On 10.11, closing a weak reference on the parent window works, but older
|
// On 10.11, closing a weak reference on the parent window works, but older
|
||||||
// versions of AppKit get upset if things are released inside -[NSWindow
|
// versions of AppKit get upset if things are released inside -[NSWindow
|
||||||
// close]. This test tries to establish a situation where the last reference
|
// close]. This test tries to establish a situation where the last reference
|
||||||
// to the child window is released inside WidgetOwnerNSWindowAdapter::
|
// to the child window is released inside WidgetOwnerNSWindowAdapter::
|
||||||
// OnWindowWillClose().
|
// OnWindowWillClose().
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
[native_parent close];
|
[native_parent close];
|
||||||
EXPECT_TRUE(child_dealloced);
|
EXPECT_TRUE(child_dealloced);
|
||||||
}
|
}
|
||||||
@@ -1511,8 +1505,7 @@ TEST_F(NativeWidgetMacTest, CloseWithWindowModalSheet) {
|
|||||||
|
|
||||||
// Test another hypothetical: What if -sheetDidEnd: was invoked somehow
|
// Test another hypothetical: What if -sheetDidEnd: was invoked somehow
|
||||||
// without going through [NSApp endSheet:] or -[NSWindow endSheet:].
|
// without going through [NSApp endSheet:] or -[NSWindow endSheet:].
|
||||||
{
|
@autoreleasepool {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
Widget* sheet_widget = ShowWindowModalWidget(native_parent);
|
Widget* sheet_widget = ShowWindowModalWidget(native_parent);
|
||||||
NSWindow* sheet_window =
|
NSWindow* sheet_window =
|
||||||
sheet_widget->GetNativeWindow().GetNativeNSWindow();
|
sheet_widget->GetNativeWindow().GetNativeNSWindow();
|
||||||
@@ -1548,8 +1541,7 @@ TEST_F(NativeWidgetMacTest, CloseWithWindowModalSheet) {
|
|||||||
// https://crbug.com/851376.
|
// https://crbug.com/851376.
|
||||||
TEST_F(NativeWidgetMacTest, CloseWindowModalSheetWithoutSheetParent) {
|
TEST_F(NativeWidgetMacTest, CloseWindowModalSheetWithoutSheetParent) {
|
||||||
NSWindow* native_parent = MakeClosableTitledNativeParent();
|
NSWindow* native_parent = MakeClosableTitledNativeParent();
|
||||||
{
|
@autoreleasepool {
|
||||||
base::mac::ScopedNSAutoreleasePool pool;
|
|
||||||
Widget* sheet_widget = ShowWindowModalWidget(native_parent);
|
Widget* sheet_widget = ShowWindowModalWidget(native_parent);
|
||||||
NSWindow* sheet_window =
|
NSWindow* sheet_window =
|
||||||
sheet_widget->GetNativeWindow().GetNativeNSWindow();
|
sheet_widget->GetNativeWindow().GetNativeNSWindow();
|
||||||
|
Reference in New Issue
Block a user