| 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 "chrome/browser/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/scoped_temp_dir.h" | 12 #include "base/files/scoped_temp_dir.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
| 17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 18 #include "chrome/browser/extensions/browsertest_util.h" | 18 #include "chrome/browser/extensions/browsertest_util.h" |
| 19 #include "chrome/browser/extensions/component_loader.h" | 19 #include "chrome/browser/extensions/component_loader.h" |
| 20 #include "chrome/browser/extensions/crx_installer.h" | 20 #include "chrome/browser/extensions/crx_installer.h" |
| 21 #include "chrome/browser/extensions/extension_creator.h" | 21 #include "chrome/browser/extensions/extension_creator.h" |
| 22 #include "chrome/browser/extensions/extension_error_reporter.h" | 22 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 23 #include "chrome/browser/extensions/extension_host.h" | 23 #include "chrome/browser/extensions/extension_host.h" |
| 24 #include "chrome/browser/extensions/extension_install_prompt.h" | 24 #include "chrome/browser/extensions/extension_install_prompt.h" |
| 25 #include "chrome/browser/extensions/extension_service.h" | 25 #include "chrome/browser/extensions/extension_service.h" |
| 26 #include "chrome/browser/extensions/extension_system.h" | 26 #include "chrome/browser/extensions/extension_system.h" |
| 27 #include "chrome/browser/extensions/extension_util.h" |
| 27 #include "chrome/browser/extensions/unpacked_installer.h" | 28 #include "chrome/browser/extensions/unpacked_installer.h" |
| 28 #include "chrome/browser/profiles/profile.h" | 29 #include "chrome/browser/profiles/profile.h" |
| 29 #include "chrome/browser/profiles/profile_manager.h" | 30 #include "chrome/browser/profiles/profile_manager.h" |
| 30 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
| 31 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
| 32 #include "chrome/browser/ui/omnibox/location_bar.h" | 33 #include "chrome/browser/ui/omnibox/location_bar.h" |
| 33 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 34 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 34 #include "chrome/common/chrome_paths.h" | 35 #include "chrome/common/chrome_paths.h" |
| 35 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/chrome_version_info.h" | 37 #include "chrome/common/chrome_version_info.h" |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 syncer::StringOrdinal::CreateInitialOrdinal()); | 186 syncer::StringOrdinal::CreateInitialOrdinal()); |
| 186 | 187 |
| 187 // Toggling incognito or file access will reload the extension, so wait for | 188 // Toggling incognito or file access will reload the extension, so wait for |
| 188 // the reload and grab the new extension instance. The default state is | 189 // the reload and grab the new extension instance. The default state is |
| 189 // incognito disabled and file access enabled, so we don't wait in those | 190 // incognito disabled and file access enabled, so we don't wait in those |
| 190 // cases. | 191 // cases. |
| 191 { | 192 { |
| 192 content::WindowedNotificationObserver load_signal( | 193 content::WindowedNotificationObserver load_signal( |
| 193 chrome::NOTIFICATION_EXTENSION_LOADED, | 194 chrome::NOTIFICATION_EXTENSION_LOADED, |
| 194 content::Source<Profile>(profile())); | 195 content::Source<Profile>(profile())); |
| 195 CHECK(!service->IsIncognitoEnabled(extension_id) || | 196 CHECK(!extension_util::IsIncognitoEnabled(extension_id, service) || |
| 196 extension->force_incognito_enabled()); | 197 extension->force_incognito_enabled()); |
| 197 | 198 |
| 198 if (flags & kFlagEnableIncognito) { | 199 if (flags & kFlagEnableIncognito) { |
| 199 service->SetIsIncognitoEnabled(extension_id, true); | 200 extension_util::SetIsIncognitoEnabled(extension_id, service, true); |
| 200 load_signal.Wait(); | 201 load_signal.Wait(); |
| 201 extension = service->GetExtensionById(extension_id, false); | 202 extension = service->GetExtensionById(extension_id, false); |
| 202 CHECK(extension) << extension_id << " not found after reloading."; | 203 CHECK(extension) << extension_id << " not found after reloading."; |
| 203 } | 204 } |
| 204 } | 205 } |
| 205 | 206 |
| 206 { | 207 { |
| 207 content::WindowedNotificationObserver load_signal( | 208 content::WindowedNotificationObserver load_signal( |
| 208 chrome::NOTIFICATION_EXTENSION_LOADED, | 209 chrome::NOTIFICATION_EXTENSION_LOADED, |
| 209 content::Source<Profile>(profile())); | 210 content::Source<Profile>(profile())); |
| 210 CHECK(service->AllowFileAccess(extension)); | 211 CHECK(extension_util::AllowFileAccess(extension, service)); |
| 211 if (!(flags & kFlagEnableFileAccess)) { | 212 if (!(flags & kFlagEnableFileAccess)) { |
| 212 service->SetAllowFileAccess(extension, false); | 213 extension_util::SetAllowFileAccess(extension, service, false); |
| 213 load_signal.Wait(); | 214 load_signal.Wait(); |
| 214 extension = service->GetExtensionById(extension_id, false); | 215 extension = service->GetExtensionById(extension_id, false); |
| 215 CHECK(extension) << extension_id << " not found after reloading."; | 216 CHECK(extension) << extension_id << " not found after reloading."; |
| 216 } | 217 } |
| 217 } | 218 } |
| 218 | 219 |
| 219 if (!WaitForExtensionViewsToLoad()) | 220 if (!WaitForExtensionViewsToLoad()) |
| 220 return NULL; | 221 return NULL; |
| 221 | 222 |
| 222 return extension; | 223 return extension; |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: | 754 case chrome::NOTIFICATION_EXTENSION_LOAD_ERROR: |
| 754 VLOG(1) << "Got EXTENSION_LOAD_ERROR notification."; | 755 VLOG(1) << "Got EXTENSION_LOAD_ERROR notification."; |
| 755 ++extension_load_errors_observed_; | 756 ++extension_load_errors_observed_; |
| 756 break; | 757 break; |
| 757 | 758 |
| 758 default: | 759 default: |
| 759 NOTREACHED(); | 760 NOTREACHED(); |
| 760 break; | 761 break; |
| 761 } | 762 } |
| 762 } | 763 } |
| OLD | NEW |