Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: chrome/browser/extensions/convert_web_app.cc

Issue 1066623008: Sync bookmark app icon urls and sizes, and download icons for new apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated sync value conversions Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "chrome/browser/extensions/convert_web_app.h" 5 #include "chrome/browser/extensions/convert_web_app.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 root->SetString(keys::kPublicKey, GenerateKey(web_app.app_url)); 105 root->SetString(keys::kPublicKey, GenerateKey(web_app.app_url));
106 root->SetString(keys::kName, base::UTF16ToUTF8(web_app.title)); 106 root->SetString(keys::kName, base::UTF16ToUTF8(web_app.title));
107 root->SetString(keys::kVersion, ConvertTimeToExtensionVersion(create_time)); 107 root->SetString(keys::kVersion, ConvertTimeToExtensionVersion(create_time));
108 root->SetString(keys::kDescription, base::UTF16ToUTF8(web_app.description)); 108 root->SetString(keys::kDescription, base::UTF16ToUTF8(web_app.description));
109 root->SetString(keys::kLaunchWebURL, web_app.app_url.spec()); 109 root->SetString(keys::kLaunchWebURL, web_app.app_url.spec());
110 if (web_app.generated_icon_color != SK_ColorTRANSPARENT) { 110 if (web_app.generated_icon_color != SK_ColorTRANSPARENT) {
111 root->SetString(keys::kAppIconColor, image_util::GenerateCSSColorString( 111 root->SetString(keys::kAppIconColor, image_util::GenerateCSSColorString(
112 web_app.generated_icon_color)); 112 web_app.generated_icon_color));
113 } 113 }
114 114
115 // Add the icons. 115 // Add the icons and linked icon information.
116 base::DictionaryValue* icons = new base::DictionaryValue(); 116 base::DictionaryValue* icons = new base::DictionaryValue();
117 root->Set(keys::kIcons, icons); 117 root->Set(keys::kIcons, icons);
118 for (size_t i = 0; i < web_app.icons.size(); ++i) { 118 base::ListValue* linked_icons = new base::ListValue();
119 std::string size = base::StringPrintf("%i", web_app.icons[i].width); 119 root->Set(keys::kLinkedAppIcons, linked_icons);
120 for (const auto& icon : web_app.icons) {
121 std::string size = base::StringPrintf("%i", icon.width);
120 std::string icon_path = base::StringPrintf("%s/%s.png", kIconsDirName, 122 std::string icon_path = base::StringPrintf("%s/%s.png", kIconsDirName,
121 size.c_str()); 123 size.c_str());
122 icons->SetString(size, icon_path); 124 icons->SetString(size, icon_path);
125
126 if (icon.url.is_valid()) {
127 base::DictionaryValue* linked_icon = new base::DictionaryValue();
128 linked_icon->SetString(keys::kLinkedAppIconURL, icon.url.spec());
129 linked_icon->SetInteger(keys::kLinkedAppIconSize, icon.width);
130 linked_icons->Append(linked_icon);
131 }
123 } 132 }
124 133
125 // Write the manifest. 134 // Write the manifest.
126 base::FilePath manifest_path = temp_dir.path().Append(kManifestFilename); 135 base::FilePath manifest_path = temp_dir.path().Append(kManifestFilename);
127 JSONFileValueSerializer serializer(manifest_path); 136 JSONFileValueSerializer serializer(manifest_path);
128 if (!serializer.Serialize(*root)) { 137 if (!serializer.Serialize(*root)) {
129 LOG(ERROR) << "Could not serialize manifest."; 138 LOG(ERROR) << "Could not serialize manifest.";
130 return NULL; 139 return NULL;
131 } 140 }
132 141
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 if (!extension.get()) { 179 if (!extension.get()) {
171 LOG(ERROR) << error; 180 LOG(ERROR) << error;
172 return NULL; 181 return NULL;
173 } 182 }
174 183
175 temp_dir.Take(); // The caller takes ownership of the directory. 184 temp_dir.Take(); // The caller takes ownership of the directory.
176 return extension; 185 return extension;
177 } 186 }
178 187
179 } // namespace extensions 188 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/bookmark_app_helper_unittest.cc ('k') | chrome/browser/extensions/extension_sync_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698