summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-20 18:37:48 +0000
committermpcomplete@google.com <mpcomplete@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-20 18:37:48 +0000
commit8448f1ae7fc731b8c02f66bb36bb4849096d61a6 (patch)
treed909dbdf0db060f3105fe1f29028dbc718e53553 /chrome
parent13a5ac6e21ef46f75c791e791a2fa6d392a574bd (diff)
downloadchromium_src-8448f1ae7fc731b8c02f66bb36bb4849096d61a6.zip
chromium_src-8448f1ae7fc731b8c02f66bb36bb4849096d61a6.tar.gz
chromium_src-8448f1ae7fc731b8c02f66bb36bb4849096d61a6.tar.bz2
Chrome changes to allow non-ASCII characters in shortcut filenames.
BUG=1331408 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1098 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gears_integration.cc23
-rw-r--r--chrome/browser/gears_integration.h2
-rw-r--r--chrome/common/chrome_plugin_api.h2
-rw-r--r--chrome/common/gears_api.h17
4 files changed, 35 insertions, 9 deletions
diff --git a/chrome/browser/gears_integration.cc b/chrome/browser/gears_integration.cc
index e13a7a3..aa97dec 100644
--- a/chrome/browser/gears_integration.cc
+++ b/chrome/browser/gears_integration.cc
@@ -165,12 +165,13 @@ static GURL ConvertSkBitmapToDataURL(const SkBitmap& icon) {
class CreateShortcutCommand : public CPCommandInterface {
public:
CreateShortcutCommand(
- const std::string& name, const std::string& url,
- const std::string& description,
+ const std::string& name, const std::string& orig_name,
+ const std::string& url, const std::string& description,
const std::vector<webkit_glue::WebApplicationInfo::IconInfo> &icons,
const SkBitmap& fallback_icon,
GearsCreateShortcutCallback* callback)
- : name_(name), url_(url), description_(description), callback_(callback),
+ : name_(name), url_(url), description_(description),
+ orig_name_(orig_name), callback_(callback),
calling_loop_(MessageLoop::current()) {
// shortcut_data_ has the same lifetime as our strings, so we just point it
// at their internal data.
@@ -178,6 +179,7 @@ class CreateShortcutCommand : public CPCommandInterface {
shortcut_data_.name = name_.c_str();
shortcut_data_.url = url_.c_str();
shortcut_data_.description = description_.c_str();
+ shortcut_data_.orig_name = orig_name_.c_str();
// Search the icons array for Gears-supported sizes and copy the strings.
bool has_icon = false;
@@ -225,7 +227,15 @@ class CreateShortcutCommand : public CPCommandInterface {
private:
void ReportResults(CPError retval) {
- callback_->Run(shortcut_data_, retval == CPERR_SUCCESS);
+ // Other code only knows about the original GearsShortcutData. Pass our
+ // GearsShortcutData2 off as one of those - but use the unmodified name.
+ // TODO(mpcomplete): this means that Gears will have stored its sanitized
+ // filename, but not expose it to us. We will use the unsanitized version,
+ // so our name will potentially differ. This is relevant because we store
+ // some prefs keyed off the webapp name.
+ shortcut_data_.name = shortcut_data_.orig_name;
+ callback_->Run(*reinterpret_cast<GearsShortcutData*>(&shortcut_data_),
+ retval == CPERR_SUCCESS);
delete this;
}
@@ -241,6 +251,7 @@ class CreateShortcutCommand : public CPCommandInterface {
std::string url_;
std::string description_;
std::string icon_urls_[NUM_GEARS_ICONS];
+ std::string orig_name_;
scoped_ptr<GearsCreateShortcutCallback> callback_;
MessageLoop* calling_loop_;
};
@@ -262,6 +273,7 @@ void GearsCreateShortcut(
GearsCreateShortcutCallback* callback) {
std::wstring name =
!app_info.title.empty() ? app_info.title : fallback_name;
+ std::string orig_name_utf8 = WideToUTF8(name);
EnsureStringValidPathComponent(name);
std::string name_utf8 = WideToUTF8(name);
@@ -270,7 +282,8 @@ void GearsCreateShortcut(
!app_info.app_url.is_empty() ? app_info.app_url : fallback_url;
CreateShortcutCommand* command =
- new CreateShortcutCommand(name_utf8, url.spec(), description_utf8,
+ new CreateShortcutCommand(name_utf8, orig_name_utf8, url.spec(),
+ description_utf8,
app_info.icons, fallback_icon, callback);
CPHandleCommand(GEARSPLUGINCOMMAND_CREATE_SHORTCUT, command, NULL);
}
diff --git a/chrome/browser/gears_integration.h b/chrome/browser/gears_integration.h
index 24bc077..d805a9e 100644
--- a/chrome/browser/gears_integration.h
+++ b/chrome/browser/gears_integration.h
@@ -48,7 +48,7 @@ struct WebApplicationInfo;
// We use this in place of GearsShortcutData so we can keep browser-specific
// data on the structure.
-struct GearsCreateShortcutData : public GearsShortcutData {
+struct GearsCreateShortcutData : public GearsShortcutData2 {
CPCommandInterface* command_interface;
};
diff --git a/chrome/common/chrome_plugin_api.h b/chrome/common/chrome_plugin_api.h
index af21699..00c4da8 100644
--- a/chrome/common/chrome_plugin_api.h
+++ b/chrome/common/chrome_plugin_api.h
@@ -55,7 +55,7 @@ extern "C" {
// The current version of the API, used by the 'version' field of CPPluginFuncs
// and CPBrowserFuncs.
#define CP_MAJOR_VERSION 0
-#define CP_MINOR_VERSION 5
+#define CP_MINOR_VERSION 6
#define CP_VERSION ((CP_MAJOR_VERSION << 8) | (CP_MINOR_VERSION))
#define CP_GET_MAJOR_VERSION(version) ((version & 0xff00) >> 8)
diff --git a/chrome/common/gears_api.h b/chrome/common/gears_api.h
index a30654b..b0bf1cd 100644
--- a/chrome/common/gears_api.h
+++ b/chrome/common/gears_api.h
@@ -86,6 +86,19 @@ typedef struct _GearsShortcutData {
GearsShortcutIcon icons[4]; // list of icons to use for this shortcut
} GearsShortcutData;
+// Command data for GEARSPLUGINCOMMAND_CREATE_SHORTCUT used in 0.6 and later.
+// This struct is backwards compatible with the first version.
+// http://b/viewIssue?id=1331408 - Chrome sanitizes 'name' for compatibility
+// with older versions of Gears that expect this. 'orig_name' is unsanitized,
+// which allows Gears to do its own validation.
+typedef struct _GearsShortcutData2 {
+ const char* name; // unused - for back compat with above struct
+ const char* url; // the URL that the shortcut should launch
+ const char* description; // an optional description
+ GearsShortcutIcon icons[4]; // list of icons to use for this shortcut
+ const char* orig_name; // the shortcut's unmodified filename (added in 0.6)
+} GearsShortcutData2;
+
// Command data for GEARSPLUGINCOMMAND_GET_SHORTCUT_LIST.
typedef struct _GearsShortcutList {
// Note: these are output params, set by Gears. There are no input params.
@@ -97,8 +110,8 @@ typedef struct _GearsShortcutList {
// Command data for GEARSBROWSERCOMMAND_CREATE_SHORTCUT_DONE
typedef struct _GearsCreateShortcutResult {
- GearsShortcutData* shortcut; // pointer to struct passed to
- // GEARSPLUGINCOMMAND_CREATE_SHORTCUT
+ GearsShortcutData2* shortcut; // pointer to struct passed to
+ // GEARSPLUGINCOMMAND_CREATE_SHORTCUT
CPError result; // CPERR_SUCCESS if shortcut was created, or error otherwise
} GearsCreateShortcutResult;