| 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" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 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 const UserScript* script, | 34 const UserScript* script, |
| 35 int process_id, | 35 int process_id, |
| 36 std::string* error) { | 36 std::string* error) { |
| 37 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 37 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 38 | 38 |
| 39 #if !defined(OS_CHROMEOS) | 39 #if !defined(OS_CHROMEOS) |
| 40 // NULL in unit tests. | 40 // NULL in unit tests. |
| 41 if (!g_browser_process->profile_manager()) | 41 if (!g_browser_process->profile_manager()) |
| 42 return true; | 42 return true; |
| 43 | 43 |
| 44 // We don't have a Profile in this context. That's OK - for our purposes, | 44 // We don't have a Profile in this context. That's OK - for our purposes, |
| 45 // we can just check every Profile for its signin process. If any of them | 45 // we can just check every Profile for its signin process. If any of them |
| 46 // match, block script access. | 46 // match, block script access. |
| 47 std::vector<Profile*> profiles = | 47 std::vector<Profile*> profiles = |
| 48 g_browser_process->profile_manager()->GetLoadedProfiles(); | 48 g_browser_process->profile_manager()->GetLoadedProfiles(); |
| 49 for (std::vector<Profile*>::iterator profile = profiles.begin(); | 49 for (std::vector<Profile*>::iterator profile = profiles.begin(); |
| 50 profile != profiles.end(); ++profile) { | 50 profile != profiles.end(); ++profile) { |
| 51 SigninManager* signin_manager = | 51 SigninManager* signin_manager = |
| 52 SigninManagerFactory::GetForProfile(*profile); | 52 SigninManagerFactory::GetForProfile(*profile); |
| 53 if (signin_manager && signin_manager->IsSigninProcess(process_id)) { | 53 if (signin_manager && signin_manager->IsSigninProcess(process_id)) { |
| 54 if (error) | 54 if (error) |
| 55 *error = errors::kCannotScriptSigninPage; | 55 *error = errors::kCannotScriptSigninPage; |
| 56 return false; | 56 return false; |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 return true; | 61 return true; |
| 62 } | 62 } |
| 63 | 63 |
| 64 } // namespace extensions | 64 } // namespace extensions |
| OLD | NEW |