| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/extensions/extension_system.h" | 14 #include "chrome/browser/extensions/extension_system.h" |
| 15 #include "chrome/browser/extensions/extension_util.h" |
| 15 #include "chrome/browser/extensions/user_script_master.h" | 16 #include "chrome/browser/extensions/user_script_master.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 19 #include "chrome/common/chrome_paths.h" | 20 #include "chrome/common/chrome_paths.h" |
| 20 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/common/extensions/feature_switch.h" | 22 #include "chrome/common/extensions/feature_switch.h" |
| 22 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
| 23 #include "chrome/test/base/testing_profile.h" | 24 #include "chrome/test/base/testing_profile.h" |
| 24 #include "chrome/test/base/ui_test_utils.h" | 25 #include "chrome/test/base/ui_test_utils.h" |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 // Keep a separate list of extensions for which to disable file access, since | 182 // Keep a separate list of extensions for which to disable file access, since |
| 182 // doing so reloads them. | 183 // doing so reloads them. |
| 183 std::vector<const extensions::Extension*> extension_list; | 184 std::vector<const extensions::Extension*> extension_list; |
| 184 | 185 |
| 185 ExtensionService* service = extensions::ExtensionSystem::Get( | 186 ExtensionService* service = extensions::ExtensionSystem::Get( |
| 186 browser()->profile())->extension_service(); | 187 browser()->profile())->extension_service(); |
| 187 for (ExtensionSet::const_iterator it = service->extensions()->begin(); | 188 for (ExtensionSet::const_iterator it = service->extensions()->begin(); |
| 188 it != service->extensions()->end(); ++it) { | 189 it != service->extensions()->end(); ++it) { |
| 189 if ((*it)->location() == extensions::Manifest::COMPONENT) | 190 if ((*it)->location() == extensions::Manifest::COMPONENT) |
| 190 continue; | 191 continue; |
| 191 if (service->AllowFileAccess(it->get())) | 192 if (extension_util::AllowFileAccess(it->get(), service)) |
| 192 extension_list.push_back(it->get()); | 193 extension_list.push_back(it->get()); |
| 193 } | 194 } |
| 194 | 195 |
| 195 for (size_t i = 0; i < extension_list.size(); ++i) { | 196 for (size_t i = 0; i < extension_list.size(); ++i) { |
| 196 content::WindowedNotificationObserver user_scripts_observer( | 197 content::WindowedNotificationObserver user_scripts_observer( |
| 197 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, | 198 chrome::NOTIFICATION_USER_SCRIPTS_UPDATED, |
| 198 content::NotificationService::AllSources()); | 199 content::NotificationService::AllSources()); |
| 199 service->SetAllowFileAccess(extension_list[i], false); | 200 extension_util::SetAllowFileAccess(extension_list[i], service, false); |
| 200 user_scripts_observer.Wait(); | 201 user_scripts_observer.Wait(); |
| 201 } | 202 } |
| 202 | 203 |
| 203 TestInjection(false, false); | 204 TestInjection(false, false); |
| 204 } | 205 } |
| 205 | 206 |
| 206 // ExtensionsLoadTest | 207 // ExtensionsLoadTest |
| 207 // Ensures that we can startup the browser with --load-extension and see them | 208 // Ensures that we can startup the browser with --load-extension and see them |
| 208 // run. | 209 // run. |
| 209 | 210 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 .AppendASCII("extensions") | 269 .AppendASCII("extensions") |
| 269 .AppendASCII("app2"); | 270 .AppendASCII("app2"); |
| 270 load_extensions_.push_back(fourth_extension_path.value()); | 271 load_extensions_.push_back(fourth_extension_path.value()); |
| 271 } | 272 } |
| 272 }; | 273 }; |
| 273 | 274 |
| 274 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { | 275 IN_PROC_BROWSER_TEST_F(ExtensionsLoadMultipleTest, Test) { |
| 275 WaitForServicesToStart(4, true); | 276 WaitForServicesToStart(4, true); |
| 276 TestInjection(true, true); | 277 TestInjection(true, true); |
| 277 } | 278 } |
| OLD | NEW |