OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "base/values.h" | 6 #include "base/values.h" |
7 #include "chrome/browser/content_settings/cookie_settings.h" | 7 #include "chrome/browser/content_settings/cookie_settings.h" |
8 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 8 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
9 #include "chrome/test/base/testing_profile.h" | 9 #include "chrome/test/base/testing_profile.h" |
10 #include "components/content_settings/core/common/content_settings.h" | 10 #include "components/content_settings/core/common/content_settings.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 class ExtensionSpecialStoragePolicyTest : public testing::Test { | 29 class ExtensionSpecialStoragePolicyTest : public testing::Test { |
30 protected: | 30 protected: |
31 class PolicyChangeObserver : public SpecialStoragePolicy::Observer { | 31 class PolicyChangeObserver : public SpecialStoragePolicy::Observer { |
32 public: | 32 public: |
33 PolicyChangeObserver() | 33 PolicyChangeObserver() |
34 : expected_type_(NOTIFICATION_TYPE_NONE), | 34 : expected_type_(NOTIFICATION_TYPE_NONE), |
35 expected_change_flags_(0) { | 35 expected_change_flags_(0) { |
36 } | 36 } |
37 | 37 |
38 virtual void OnGranted(const GURL& origin, | 38 virtual void OnGranted(const GURL& origin, |
39 int change_flags) OVERRIDE { | 39 int change_flags) override { |
40 EXPECT_EQ(expected_type_, NOTIFICATION_TYPE_GRANT); | 40 EXPECT_EQ(expected_type_, NOTIFICATION_TYPE_GRANT); |
41 EXPECT_EQ(expected_origin_, origin); | 41 EXPECT_EQ(expected_origin_, origin); |
42 EXPECT_EQ(expected_change_flags_, change_flags); | 42 EXPECT_EQ(expected_change_flags_, change_flags); |
43 expected_type_ = NOTIFICATION_TYPE_NONE; | 43 expected_type_ = NOTIFICATION_TYPE_NONE; |
44 } | 44 } |
45 | 45 |
46 virtual void OnRevoked(const GURL& origin, | 46 virtual void OnRevoked(const GURL& origin, |
47 int change_flags) OVERRIDE { | 47 int change_flags) override { |
48 EXPECT_EQ(expected_type_, NOTIFICATION_TYPE_REVOKE); | 48 EXPECT_EQ(expected_type_, NOTIFICATION_TYPE_REVOKE); |
49 EXPECT_EQ(expected_origin_, origin); | 49 EXPECT_EQ(expected_origin_, origin); |
50 EXPECT_EQ(expected_change_flags_, change_flags); | 50 EXPECT_EQ(expected_change_flags_, change_flags); |
51 expected_type_ = NOTIFICATION_TYPE_NONE; | 51 expected_type_ = NOTIFICATION_TYPE_NONE; |
52 } | 52 } |
53 | 53 |
54 virtual void OnCleared() OVERRIDE { | 54 virtual void OnCleared() override { |
55 EXPECT_EQ(expected_type_, NOTIFICATION_TYPE_CLEAR); | 55 EXPECT_EQ(expected_type_, NOTIFICATION_TYPE_CLEAR); |
56 expected_type_ = NOTIFICATION_TYPE_NONE; | 56 expected_type_ = NOTIFICATION_TYPE_NONE; |
57 } | 57 } |
58 | 58 |
59 void ExpectGrant(const std::string& extension_id, | 59 void ExpectGrant(const std::string& extension_id, |
60 int change_flags) { | 60 int change_flags) { |
61 expected_type_ = NOTIFICATION_TYPE_GRANT; | 61 expected_type_ = NOTIFICATION_TYPE_GRANT; |
62 expected_origin_ = Extension::GetBaseURLFromExtensionId(extension_id); | 62 expected_origin_ = Extension::GetBaseURLFromExtensionId(extension_id); |
63 expected_change_flags_ = change_flags; | 63 expected_change_flags_ = change_flags; |
64 } | 64 } |
(...skipping 20 matching lines...) Expand all Loading... |
85 NOTIFICATION_TYPE_REVOKE, | 85 NOTIFICATION_TYPE_REVOKE, |
86 NOTIFICATION_TYPE_CLEAR, | 86 NOTIFICATION_TYPE_CLEAR, |
87 } expected_type_; | 87 } expected_type_; |
88 | 88 |
89 GURL expected_origin_; | 89 GURL expected_origin_; |
90 int expected_change_flags_; | 90 int expected_change_flags_; |
91 | 91 |
92 DISALLOW_COPY_AND_ASSIGN(PolicyChangeObserver); | 92 DISALLOW_COPY_AND_ASSIGN(PolicyChangeObserver); |
93 }; | 93 }; |
94 | 94 |
95 virtual void SetUp() OVERRIDE { | 95 virtual void SetUp() override { |
96 policy_ = new ExtensionSpecialStoragePolicy(NULL); | 96 policy_ = new ExtensionSpecialStoragePolicy(NULL); |
97 } | 97 } |
98 | 98 |
99 scoped_refptr<Extension> CreateProtectedApp() { | 99 scoped_refptr<Extension> CreateProtectedApp() { |
100 #if defined(OS_WIN) | 100 #if defined(OS_WIN) |
101 base::FilePath path(FILE_PATH_LITERAL("c:\\foo")); | 101 base::FilePath path(FILE_PATH_LITERAL("c:\\foo")); |
102 #elif defined(OS_POSIX) | 102 #elif defined(OS_POSIX) |
103 base::FilePath path(FILE_PATH_LITERAL("/foo")); | 103 base::FilePath path(FILE_PATH_LITERAL("/foo")); |
104 #endif | 104 #endif |
105 base::DictionaryValue manifest; | 105 base::DictionaryValue manifest; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 EXPECT_TRUE(observer.IsCompleted()); | 398 EXPECT_TRUE(observer.IsCompleted()); |
399 } | 399 } |
400 | 400 |
401 observer.ExpectClear(); | 401 observer.ExpectClear(); |
402 policy_->RevokeRightsForAllExtensions(); | 402 policy_->RevokeRightsForAllExtensions(); |
403 message_loop.RunUntilIdle(); | 403 message_loop.RunUntilIdle(); |
404 EXPECT_TRUE(observer.IsCompleted()); | 404 EXPECT_TRUE(observer.IsCompleted()); |
405 | 405 |
406 policy_->RemoveObserver(&observer); | 406 policy_->RemoveObserver(&observer); |
407 } | 407 } |
OLD | NEW |