Home | History | Annotate | Download | only in integration
      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
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_SYNC_TEST_INTEGRATION_EXTENSIONS_HELPER_H_
      6 #define CHROME_BROWSER_SYNC_TEST_INTEGRATION_EXTENSIONS_HELPER_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "base/basictypes.h"
     12 #include "base/compiler_specific.h"
     13 #include "chrome/browser/sync/test/integration/sync_test.h"
     14 
     15 class Profile;
     16 
     17 namespace extensions_helper {
     18 
     19 // Returns true iff the profile with index |index| has the same extensions
     20 // as the verifier.
     21 bool HasSameExtensionsAsVerifier(int index) WARN_UNUSED_RESULT;
     22 
     23 // Returns true iff all existing profiles have the same extensions
     24 // as the verifier.
     25 bool AllProfilesHaveSameExtensionsAsVerifier() WARN_UNUSED_RESULT;
     26 
     27 // Returns true iff all existing profiles have the same extensions.
     28 bool AllProfilesHaveSameExtensions() WARN_UNUSED_RESULT;
     29 
     30 // Installs the extension for the given index to |profile|, and returns the
     31 // extension ID of the new extension.
     32 std::string InstallExtension(Profile* profile, int index);
     33 
     34 // Installs the extension for the given index to all profiles (including the
     35 // verifier), and returns the extension ID of the new extension.
     36 std::string InstallExtensionForAllProfiles(int index);
     37 
     38 // Uninstalls the extension for the given index from |profile|. Assumes that
     39 // it was previously installed.
     40 void UninstallExtension(Profile* profile, int index);
     41 
     42 // Returns a vector containing the indices of all currently installed
     43 // test extensions on |profile|.
     44 std::vector<int> GetInstalledExtensions(Profile* profile);
     45 
     46 // Installs all pending synced extensions for |profile|.
     47 void InstallExtensionsPendingForSync(Profile* profile);
     48 
     49 // Enables the extension for the given index on |profile|.
     50 void EnableExtension(Profile* profile, int index);
     51 
     52 // Disables the extension for the given index on |profile|.
     53 void DisableExtension(Profile* profile, int index);
     54 
     55 // Returns true if the extension with index |index| is enabled on |profile|.
     56 bool IsExtensionEnabled(Profile* profile, int index);
     57 
     58 // Enables the extension for the given index in incognito mode on |profile|.
     59 void IncognitoEnableExtension(Profile* profile, int index);
     60 
     61 // Disables the extension for the given index in incognito mode on |profile|.
     62 void IncognitoDisableExtension(Profile* profile, int index);
     63 
     64 // Returns true if the extension with index |index| is enabled in incognito
     65 // mode on |profile|.
     66 bool IsIncognitoEnabled(Profile* profile, int index);
     67 
     68 // Returns a unique extension name based in the integer |index|.
     69 std::string CreateFakeExtensionName(int index);
     70 
     71 // Converts a fake extension name back into the index used to generate it.
     72 // Returns true if successful, false on failure.
     73 bool ExtensionNameToIndex(const std::string& name, int* index);
     74 
     75 // Runs the message loop until AllProfilesHaveSameExtensionsAsVerifier()
     76 // is true.  Returns false on timeout.
     77 bool AwaitAllProfilesHaveSameExtensionsAsVerifier();
     78 
     79 }  // namespace extensions_helper
     80 
     81 #endif  // CHROME_BROWSER_SYNC_TEST_INTEGRATION_EXTENSIONS_HELPER_H_
     82