Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser_permissions_policy_delegate.h" | 5 #include "chrome/browser/extensions/browser_permissions_policy_delegate.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "extensions/common/manifest_constants.h" | 11 #include "extensions/common/manifest_constants.h" |
| 12 | 12 |
| 13 #if !defined(OS_CHROMEOS) | 13 #if !defined(OS_CHROMEOS) |
| 14 #include "chrome/browser/signin/chrome_signin_client.h" | 14 #include "chrome/browser/signin/chrome_signin_client.h" |
|
Andrew T Wilson (Slow)
2015/03/19 07:05:33
Can we remove these includes now?
Roger Tawa OOO till Jul 10th
2015/03/19 21:19:35
Done.
| |
| 15 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 15 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 namespace extensions { | 18 namespace extensions { |
| 19 | 19 |
| 20 namespace errors = manifest_errors; | 20 namespace errors = manifest_errors; |
| 21 | 21 |
| 22 BrowserPermissionsPolicyDelegate::BrowserPermissionsPolicyDelegate() { | 22 BrowserPermissionsPolicyDelegate::BrowserPermissionsPolicyDelegate() { |
| 23 PermissionsData::SetPolicyDelegate(this); | 23 PermissionsData::SetPolicyDelegate(this); |
| 24 } | 24 } |
| 25 BrowserPermissionsPolicyDelegate::~BrowserPermissionsPolicyDelegate() { | 25 BrowserPermissionsPolicyDelegate::~BrowserPermissionsPolicyDelegate() { |
| 26 PermissionsData::SetPolicyDelegate(NULL); | 26 PermissionsData::SetPolicyDelegate(NULL); |
| 27 } | 27 } |
| 28 | 28 |
| 29 bool BrowserPermissionsPolicyDelegate::CanExecuteScriptOnPage( | 29 bool BrowserPermissionsPolicyDelegate::CanExecuteScriptOnPage( |
| 30 const Extension* extension, | 30 const Extension* extension, |
| 31 const GURL& document_url, | 31 const GURL& document_url, |
| 32 const GURL& top_document_url, | 32 const GURL& top_document_url, |
| 33 int tab_id, | 33 int tab_id, |
| 34 int process_id, | 34 int process_id, |
| 35 std::string* error) { | 35 std::string* error) { |
| 36 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 36 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 37 | |
| 38 #if !defined(OS_CHROMEOS) | |
| 39 // NULL in unit tests. | |
| 40 if (!g_browser_process->profile_manager()) | |
| 41 return true; | |
| 42 | |
| 43 // We don't have a Profile in this context. That's OK - for our purposes, | |
| 44 // we can just check every Profile for its signin process. If any of them | |
| 45 // match, block script access. | |
| 46 std::vector<Profile*> profiles = | |
| 47 g_browser_process->profile_manager()->GetLoadedProfiles(); | |
| 48 for (std::vector<Profile*>::iterator profile = profiles.begin(); | |
| 49 profile != profiles.end(); ++profile) { | |
| 50 SigninClient* signin_client = | |
| 51 ChromeSigninClientFactory::GetForProfile(*profile); | |
| 52 if (signin_client && signin_client->IsSigninProcess(process_id)) { | |
| 53 if (error) | |
| 54 *error = errors::kCannotScriptSigninPage; | |
| 55 return false; | |
| 56 } | |
| 57 } | |
| 58 #endif | |
| 59 | |
| 60 return true; | 37 return true; |
| 61 } | 38 } |
| 62 | 39 |
| 63 } // namespace extensions | 40 } // namespace extensions |
| OLD | NEW |