diff options
author | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-04 22:52:06 +0000 |
---|---|---|
committer | munjal@chromium.org <munjal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-04 22:52:06 +0000 |
commit | 91bc14fb0dc012ae0e55359ce8f518e0d22fa88e (patch) | |
tree | 31131bf102a7d72db1cb9a7a25cdc27eada68039 | |
parent | bc6095e0836185ca5fdb3ecf5686ac9b44bff190 (diff) | |
download | chromium_src-91bc14fb0dc012ae0e55359ce8f518e0d22fa88e.zip chromium_src-91bc14fb0dc012ae0e55359ce8f518e0d22fa88e.tar.gz chromium_src-91bc14fb0dc012ae0e55359ce8f518e0d22fa88e.tar.bz2 |
always read and write link url and link text independently without enforcing any semantics on them.
If we load link url only if link text is not empty (and vice versa) when writing notifications JSON file
then we get out of sync with sync database for a given notification. This can fail the model association
when browser starts up next time and halt syncing of notifications in retail builds and crash in debug builds.
Review URL: http://codereview.chromium.org/8474008
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108730 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/extensions/app_notification.cc | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/chrome/browser/extensions/app_notification.cc b/chrome/browser/extensions/app_notification.cc index 2689321..7121c36 100644 --- a/chrome/browser/extensions/app_notification.cc +++ b/chrome/browser/extensions/app_notification.cc @@ -53,10 +53,10 @@ void AppNotification::ToDictionaryValue(DictionaryValue* result) { result->SetString(kTitleKey, title_); if (!body_.empty()) result->SetString(kBodyKey, body_); - if (!link_url_.is_empty()) { + if (!link_url_.is_empty()) result->SetString(kLinkUrlKey, link_url_.possibly_invalid_spec()); + if (!link_text_.empty()) result->SetString(kLinkTextKey, link_text_); - } } // static @@ -78,17 +78,18 @@ AppNotification* AppNotification::FromDictionaryValue( if (value.HasKey(kBodyKey) && !value.GetString(kBodyKey, &result->body_)) return NULL; if (value.HasKey(kLinkUrlKey)) { - if (!value.HasKey(kLinkTextKey)) - return NULL; std::string url; - if (!value.GetString(kLinkUrlKey, &url) || - !value.GetString(kLinkTextKey, &result->link_text_)) + if (!value.GetString(kLinkUrlKey, &url)) return NULL; GURL gurl(url); if (!gurl.is_valid()) return NULL; result->set_link_url(gurl); } + if (value.HasKey(kLinkTextKey) && + !value.GetString(kLinkTextKey, &result->link_text_)) { + return NULL; + } return result.release(); } |