| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_install_checker.h" | 5 #include "chrome/browser/extensions/extension_install_checker.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/blacklist.h" | 8 #include "chrome/browser/extensions/blacklist.h" |
| 9 #include "chrome/browser/extensions/requirements_checker.h" | 9 #include "chrome/browser/extensions/requirements_checker.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "extensions/browser/extension_system.h" | 12 #include "extensions/browser/extension_system.h" |
| 13 #include "extensions/browser/install_flag.h" |
| 13 #include "extensions/browser/management_policy.h" | 14 #include "extensions/browser/management_policy.h" |
| 14 | 15 |
| 15 namespace extensions { | 16 namespace extensions { |
| 16 | 17 |
| 17 ExtensionInstallChecker::ExtensionInstallChecker(Profile* profile) | 18 ExtensionInstallChecker::ExtensionInstallChecker(Profile* profile) |
| 18 : profile_(profile), | 19 : profile_(profile), |
| 20 install_flags_(kInstallFlagNone), |
| 19 blacklist_state_(NOT_BLACKLISTED), | 21 blacklist_state_(NOT_BLACKLISTED), |
| 20 policy_allows_load_(true), | 22 policy_allows_load_(true), |
| 21 current_sequence_number_(0), | 23 current_sequence_number_(0), |
| 22 running_checks_(0), | 24 running_checks_(0), |
| 23 fail_fast_(false), | 25 fail_fast_(false), |
| 24 weak_ptr_factory_(this) { | 26 weak_ptr_factory_(this) { |
| 25 } | 27 } |
| 26 | 28 |
| 27 ExtensionInstallChecker::~ExtensionInstallChecker() { | 29 ExtensionInstallChecker::~ExtensionInstallChecker() { |
| 28 } | 30 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 | 66 |
| 65 if (enabled_checks & CHECK_BLACKLIST) | 67 if (enabled_checks & CHECK_BLACKLIST) |
| 66 CheckBlacklistState(); | 68 CheckBlacklistState(); |
| 67 } | 69 } |
| 68 | 70 |
| 69 void ExtensionInstallChecker::CheckManagementPolicy() { | 71 void ExtensionInstallChecker::CheckManagementPolicy() { |
| 70 DCHECK(extension_.get()); | 72 DCHECK(extension_.get()); |
| 71 | 73 |
| 72 base::string16 error; | 74 base::string16 error; |
| 73 bool allow = ExtensionSystem::Get(profile_)->management_policy()->UserMayLoad( | 75 bool allow = ExtensionSystem::Get(profile_)->management_policy()->UserMayLoad( |
| 74 extension_.get(), &error); | 76 extension_.get(), install_flags_, &error); |
| 75 OnManagementPolicyCheckDone(allow, base::UTF16ToUTF8(error)); | 77 OnManagementPolicyCheckDone(allow, base::UTF16ToUTF8(error)); |
| 76 } | 78 } |
| 77 | 79 |
| 78 void ExtensionInstallChecker::OnManagementPolicyCheckDone( | 80 void ExtensionInstallChecker::OnManagementPolicyCheckDone( |
| 79 bool allows_load, | 81 bool allows_load, |
| 80 const std::string& error) { | 82 const std::string& error) { |
| 81 policy_allows_load_ = allows_load; | 83 policy_allows_load_ = allows_load; |
| 82 policy_error_ = error; | 84 policy_error_ = error; |
| 83 DCHECK(policy_allows_load_ || !policy_error_.empty()); | 85 DCHECK(policy_allows_load_ || !policy_error_.empty()); |
| 84 | 86 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 Callback callback_copy = callback_; | 168 Callback callback_copy = callback_; |
| 167 callback_.Reset(); | 169 callback_.Reset(); |
| 168 | 170 |
| 169 // This instance may be owned by the callback recipient and deleted here, | 171 // This instance may be owned by the callback recipient and deleted here, |
| 170 // so reset |callback_| first and invoke a copy of the callback. | 172 // so reset |callback_| first and invoke a copy of the callback. |
| 171 callback_copy.Run(failed_mask); | 173 callback_copy.Run(failed_mask); |
| 172 } | 174 } |
| 173 } | 175 } |
| 174 | 176 |
| 175 } // namespace extensions | 177 } // namespace extensions |
| OLD | NEW |