| 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 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 const base::FilePath& path, | 145 const base::FilePath& path, |
| 146 int expected_change, | 146 int expected_change, |
| 147 extensions::Manifest::Location install_source) { | 147 extensions::Manifest::Location install_source) { |
| 148 return InstallOrUpdateExtension(std::string(), | 148 return InstallOrUpdateExtension(std::string(), |
| 149 path, | 149 path, |
| 150 INSTALL_UI_TYPE_NONE, | 150 INSTALL_UI_TYPE_NONE, |
| 151 expected_change, | 151 expected_change, |
| 152 install_source); | 152 install_source); |
| 153 } | 153 } |
| 154 | 154 |
| 155 // Installs an extension and grants it the permissions it requests. |
| 156 // TODO(devlin): It seems like this is probably the desired outcome most of |
| 157 // the time - otherwise the extension installs in a disabled state. |
| 158 const extensions::Extension* InstallExtensionWithPermissionsGranted( |
| 159 const base::FilePath& file_path, |
| 160 int expected_change) { |
| 161 return InstallOrUpdateExtension( |
| 162 std::string(), file_path, INSTALL_UI_TYPE_NONE, expected_change, |
| 163 extensions::Manifest::INTERNAL, browser(), |
| 164 extensions::Extension::NO_FLAGS, false, true); |
| 165 } |
| 166 |
| 155 // Installs extension as if it came from the Chrome Webstore. | 167 // Installs extension as if it came from the Chrome Webstore. |
| 156 const extensions::Extension* InstallExtensionFromWebstore( | 168 const extensions::Extension* InstallExtensionFromWebstore( |
| 157 const base::FilePath& path, int expected_change); | 169 const base::FilePath& path, int expected_change); |
| 158 | 170 |
| 159 // Same as above but passes an id to CrxInstaller and does not allow a | 171 // Same as above but passes an id to CrxInstaller and does not allow a |
| 160 // privilege increase. | 172 // privilege increase. |
| 161 const extensions::Extension* UpdateExtension(const std::string& id, | 173 const extensions::Extension* UpdateExtension(const std::string& id, |
| 162 const base::FilePath& path, | 174 const base::FilePath& path, |
| 163 int expected_change) { | 175 int expected_change) { |
| 164 return InstallOrUpdateExtension(id, path, INSTALL_UI_TYPE_NONE, | 176 return InstallOrUpdateExtension(id, path, INSTALL_UI_TYPE_NONE, |
| (...skipping 23 matching lines...) Expand all Loading... |
| 188 expected_change, | 200 expected_change, |
| 189 browser, | 201 browser, |
| 190 extensions::Extension::NO_FLAGS); | 202 extensions::Extension::NO_FLAGS); |
| 191 } | 203 } |
| 192 | 204 |
| 193 const extensions::Extension* InstallExtensionWithSourceAndFlags( | 205 const extensions::Extension* InstallExtensionWithSourceAndFlags( |
| 194 const base::FilePath& path, | 206 const base::FilePath& path, |
| 195 int expected_change, | 207 int expected_change, |
| 196 extensions::Manifest::Location install_source, | 208 extensions::Manifest::Location install_source, |
| 197 extensions::Extension::InitFromValueFlags creation_flags) { | 209 extensions::Extension::InitFromValueFlags creation_flags) { |
| 198 return InstallOrUpdateExtension(std::string(), | 210 return InstallOrUpdateExtension(std::string(), path, INSTALL_UI_TYPE_NONE, |
| 199 path, | 211 expected_change, install_source, browser(), |
| 200 INSTALL_UI_TYPE_NONE, | 212 creation_flags, false, false); |
| 201 expected_change, | |
| 202 install_source, | |
| 203 browser(), | |
| 204 creation_flags, | |
| 205 false); | |
| 206 } | 213 } |
| 207 | 214 |
| 208 // Begins install process but simulates a user cancel. | 215 // Begins install process but simulates a user cancel. |
| 209 const extensions::Extension* StartInstallButCancel( | 216 const extensions::Extension* StartInstallButCancel( |
| 210 const base::FilePath& path) { | 217 const base::FilePath& path) { |
| 211 return InstallOrUpdateExtension( | 218 return InstallOrUpdateExtension( |
| 212 std::string(), path, INSTALL_UI_TYPE_CANCEL, 0); | 219 std::string(), path, INSTALL_UI_TYPE_CANCEL, 0); |
| 213 } | 220 } |
| 214 | 221 |
| 215 void ReloadExtension(const std::string& extension_id); | 222 void ReloadExtension(const std::string& extension_id); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 int expected_change, | 359 int expected_change, |
| 353 extensions::Manifest::Location install_source); | 360 extensions::Manifest::Location install_source); |
| 354 const extensions::Extension* InstallOrUpdateExtension( | 361 const extensions::Extension* InstallOrUpdateExtension( |
| 355 const std::string& id, | 362 const std::string& id, |
| 356 const base::FilePath& path, | 363 const base::FilePath& path, |
| 357 InstallUIType ui_type, | 364 InstallUIType ui_type, |
| 358 int expected_change, | 365 int expected_change, |
| 359 extensions::Manifest::Location install_source, | 366 extensions::Manifest::Location install_source, |
| 360 Browser* browser, | 367 Browser* browser, |
| 361 extensions::Extension::InitFromValueFlags creation_flags, | 368 extensions::Extension::InitFromValueFlags creation_flags, |
| 362 bool wait_for_idle); | 369 bool wait_for_idle, |
| 370 bool grant_permissions); |
| 363 | 371 |
| 364 // Make the current channel "dev" for the duration of the test. | 372 // Make the current channel "dev" for the duration of the test. |
| 365 extensions::ScopedCurrentChannel current_channel_; | 373 extensions::ScopedCurrentChannel current_channel_; |
| 366 | 374 |
| 367 // Disable external install UI. | 375 // Disable external install UI. |
| 368 extensions::FeatureSwitch::ScopedOverride | 376 extensions::FeatureSwitch::ScopedOverride |
| 369 override_prompt_for_external_extensions_; | 377 override_prompt_for_external_extensions_; |
| 370 | 378 |
| 371 #if defined(OS_WIN) | 379 #if defined(OS_WIN) |
| 372 // Use mock shortcut directories to ensure app shortcuts are cleaned up. | 380 // Use mock shortcut directories to ensure app shortcuts are cleaned up. |
| 373 base::ScopedPathOverride user_desktop_override_; | 381 base::ScopedPathOverride user_desktop_override_; |
| 374 base::ScopedPathOverride common_desktop_override_; | 382 base::ScopedPathOverride common_desktop_override_; |
| 375 base::ScopedPathOverride user_quick_launch_override_; | 383 base::ScopedPathOverride user_quick_launch_override_; |
| 376 base::ScopedPathOverride start_menu_override_; | 384 base::ScopedPathOverride start_menu_override_; |
| 377 base::ScopedPathOverride common_start_menu_override_; | 385 base::ScopedPathOverride common_start_menu_override_; |
| 378 #endif | 386 #endif |
| 379 | 387 |
| 380 // The default profile to be used. | 388 // The default profile to be used. |
| 381 Profile* profile_; | 389 Profile* profile_; |
| 382 | 390 |
| 383 // Cache cache implementation. | 391 // Cache cache implementation. |
| 384 std::unique_ptr<extensions::ExtensionCacheFake> test_extension_cache_; | 392 std::unique_ptr<extensions::ExtensionCacheFake> test_extension_cache_; |
| 385 }; | 393 }; |
| 386 | 394 |
| 387 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ | 395 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_BROWSERTEST_H_ |
| OLD | NEW |