1 // Copyright 2007, Google Inc.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are met:
6 // 1. Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
8 // 2. Redistributions in binary form must reproduce the above copyright notice,
9 // this list of conditions and the following disclaimer in the documentation
10 // and/or other materials provided with the distribution.
11 // 3. Neither the name of Google Inc. nor the names of its contributors may be
12 // used to endorse or promote products derived from this software without
13 // specific prior written permission.
15 // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
16 // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
17 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
18 // EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
19 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #ifndef GEARS_BASE_COMMON_SHORTCUT_TABLE_H__
27 #define GEARS_BASE_COMMON_SHORTCUT_TABLE_H__
29 #include "gears/base/common/sqlite_wrapper.h"
31 // This class provides an API to manage the shortcuts for origins.
32 // Shortcuts are uniquely identified by their origin url plus their
36 ShortcutTable(SQLDatabase
*db
);
38 // Creates the table if it doesn't already exist.
39 bool MaybeCreateTable();
41 // Upgrade to version 3 schema (this table did not previously
43 bool UpgradeToVersion3();
45 // Upgrade version 3 schema to version 4.
46 bool UpgradeFromVersion3ToVersion4();
48 // Add (or overwrite) a shortcut for origin/name, with app_url,
49 // icon_urls, and msg as data.
50 bool SetShortcut(const char16
*origin
, const char16
*name
,
51 const char16
*app_url
,
52 const std::vector
<std::string16
> &icon_urls
,
55 // Get the set of origins which have shortcuts.
56 bool GetOriginsWithShortcuts(std::vector
<std::string16
> *result
);
58 // Get the set of named shortcuts for a specific origin.
59 bool GetOriginShortcuts(const char16
*origin
,
60 std::vector
<std::string16
> *names
);
62 // Get the data for a specific shortcut.
63 bool GetShortcut(const char16
*origin
, const char16
*name
,
64 std::string16
*app_url
,
65 std::vector
<std::string16
> *icon_urls
,
68 // Delete a specific shortcut.
69 bool DeleteShortcut(const char16
*origin
, const char16
*name
);
71 // Delete all shortcuts for an origin.
72 bool DeleteShortcuts(const char16
*origin
);
75 // A pointer to the SQLDatabase our table lives in.
78 DISALLOW_EVIL_CONSTRUCTORS(ShortcutTable
);
81 #endif // GEARS_BASE_COMMON_SHORTCUT_TABLE_H__