| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/shell_integration.h" | 5 #include "chrome/browser/shell_integration.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 | 8 |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 "[Desktop Entry]\n" | 178 "[Desktop Entry]\n" |
| 179 "Version=1.0\n" | 179 "Version=1.0\n" |
| 180 "Encoding=UTF-8\n" | 180 "Encoding=UTF-8\n" |
| 181 "Name=Google Chrome\n" | 181 "Name=Google Chrome\n" |
| 182 "Comment=The web browser from Google\n" | 182 "Comment=The web browser from Google\n" |
| 183 "Exec=/opt/google/chrome/google-chrome %U\n" | 183 "Exec=/opt/google/chrome/google-chrome %U\n" |
| 184 "Terminal=false\n" | 184 "Terminal=false\n" |
| 185 "Icon=/opt/google/chrome/product_logo_48.png\n" | 185 "Icon=/opt/google/chrome/product_logo_48.png\n" |
| 186 "Type=Application\n" | 186 "Type=Application\n" |
| 187 "Categories=Application;Network;WebBrowser;\n" | 187 "Categories=Application;Network;WebBrowser;\n" |
| 188 "MimeType=text/html;text/xml;application/xhtml_xml;\n", | 188 "MimeType=text/html;text/xml;application/xhtml_xml;\n" |
| 189 "X-Ayatana-Desktop-Shortcuts=NewWindow;\n" |
| 190 "\n" |
| 191 "[NewWindow Shortcut Group]\n" |
| 192 "Name=Open New Window\n" |
| 193 "Exec=/opt/google/chrome/google-chrome\n" |
| 194 "TargetEnvironment=Unity\n", |
| 189 | 195 |
| 190 "#!/usr/bin/env xdg-open\n" | 196 "#!/usr/bin/env xdg-open\n" |
| 191 "[Desktop Entry]\n" | 197 "[Desktop Entry]\n" |
| 192 "Version=1.0\n" | 198 "Version=1.0\n" |
| 193 "Encoding=UTF-8\n" | 199 "Encoding=UTF-8\n" |
| 194 "Name=GMail\n" | 200 "Name=GMail\n" |
| 195 "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" | 201 "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" |
| 196 "Terminal=false\n" | 202 "Terminal=false\n" |
| 197 "Icon=chrome-http__gmail.com\n" | 203 "Icon=chrome-http__gmail.com\n" |
| 198 "Type=Application\n" | 204 "Type=Application\n" |
| 199 "Categories=Application;Network;WebBrowser;\n" | 205 "Categories=Application;Network;WebBrowser;\n" |
| 200 "StartupWMClass=gmail.com\n" | 206 "StartupWMClass=gmail.com\n" |
| 201 }, | 207 }, |
| 202 | 208 |
| 203 // Make sure we don't insert duplicate shebangs. | 209 // Make sure we don't insert duplicate shebangs. |
| 204 { "http://gmail.com", | 210 { "http://gmail.com", |
| 205 "GMail", | 211 "GMail", |
| 206 "chrome-http__gmail.com", | 212 "chrome-http__gmail.com", |
| 207 | 213 |
| 208 "#!/some/shebang\n" | 214 "#!/some/shebang\n" |
| 215 "[Desktop Entry]\n" |
| 209 "Name=Google Chrome\n" | 216 "Name=Google Chrome\n" |
| 210 "Exec=/opt/google/chrome/google-chrome %U\n", | 217 "Exec=/opt/google/chrome/google-chrome %U\n", |
| 211 | 218 |
| 212 "#!/usr/bin/env xdg-open\n" | 219 "#!/usr/bin/env xdg-open\n" |
| 220 "[Desktop Entry]\n" |
| 213 "Name=GMail\n" | 221 "Name=GMail\n" |
| 214 "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" | 222 "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" |
| 223 "Icon=chrome-http__gmail.com\n" |
| 215 "StartupWMClass=gmail.com\n" | 224 "StartupWMClass=gmail.com\n" |
| 216 }, | 225 }, |
| 217 | 226 |
| 218 // Make sure i18n-ed comments are removed. | 227 // Make sure i18n-ed comments are removed. |
| 219 { "http://gmail.com", | 228 { "http://gmail.com", |
| 220 "GMail", | 229 "GMail", |
| 221 "chrome-http__gmail.com", | 230 "chrome-http__gmail.com", |
| 222 | 231 |
| 232 "[Desktop Entry]\n" |
| 223 "Name=Google Chrome\n" | 233 "Name=Google Chrome\n" |
| 224 "Exec=/opt/google/chrome/google-chrome %U\n" | 234 "Exec=/opt/google/chrome/google-chrome %U\n" |
| 225 "Comment[pl]=Jakis komentarz.\n", | 235 "Comment[pl]=Jakis komentarz.\n", |
| 226 | 236 |
| 227 "#!/usr/bin/env xdg-open\n" | 237 "#!/usr/bin/env xdg-open\n" |
| 238 "[Desktop Entry]\n" |
| 228 "Name=GMail\n" | 239 "Name=GMail\n" |
| 229 "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" | 240 "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" |
| 241 "Icon=chrome-http__gmail.com\n" |
| 230 "StartupWMClass=gmail.com\n" | 242 "StartupWMClass=gmail.com\n" |
| 231 }, | 243 }, |
| 232 | 244 |
| 233 // Make sure that empty icons are replaced by the chrome icon. | 245 // Make sure that empty icons are replaced by the chrome icon. |
| 234 { "http://gmail.com", | 246 { "http://gmail.com", |
| 235 "GMail", | 247 "GMail", |
| 236 "", | 248 "", |
| 237 | 249 |
| 250 "[Desktop Entry]\n" |
| 238 "Name=Google Chrome\n" | 251 "Name=Google Chrome\n" |
| 239 "Exec=/opt/google/chrome/google-chrome %U\n" | 252 "Exec=/opt/google/chrome/google-chrome %U\n" |
| 240 "Comment[pl]=Jakis komentarz.\n" | 253 "Comment[pl]=Jakis komentarz.\n" |
| 241 "Icon=/opt/google/chrome/product_logo_48.png\n", | 254 "Icon=/opt/google/chrome/product_logo_48.png\n", |
| 242 | 255 |
| 243 "#!/usr/bin/env xdg-open\n" | 256 "#!/usr/bin/env xdg-open\n" |
| 257 "[Desktop Entry]\n" |
| 244 "Name=GMail\n" | 258 "Name=GMail\n" |
| 245 "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" | 259 "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" |
| 246 "Icon=/opt/google/chrome/product_logo_48.png\n" | 260 "Icon=/opt/google/chrome/product_logo_48.png\n" |
| 247 "StartupWMClass=gmail.com\n" | 261 "StartupWMClass=gmail.com\n" |
| 248 }, | 262 }, |
| 249 | 263 |
| 250 // Now we're starting to be more evil... | 264 // Now we're starting to be more evil... |
| 251 { "http://evil.com/evil --join-the-b0tnet", | 265 { "http://evil.com/evil --join-the-b0tnet", |
| 252 "Ownz0red\nExec=rm -rf /", | 266 "Ownz0red\nExec=rm -rf /", |
| 253 "chrome-http__evil.com_evil", | 267 "chrome-http__evil.com_evil", |
| 254 | 268 |
| 269 "[Desktop Entry]\n" |
| 255 "Name=Google Chrome\n" | 270 "Name=Google Chrome\n" |
| 256 "Exec=/opt/google/chrome/google-chrome %U\n", | 271 "Exec=/opt/google/chrome/google-chrome %U\n", |
| 257 | 272 |
| 258 "#!/usr/bin/env xdg-open\n" | 273 "#!/usr/bin/env xdg-open\n" |
| 274 "[Desktop Entry]\n" |
| 259 "Name=http://evil.com/evil%20--join-the-b0tnet\n" | 275 "Name=http://evil.com/evil%20--join-the-b0tnet\n" |
| 260 "Exec=/opt/google/chrome/google-chrome " | 276 "Exec=/opt/google/chrome/google-chrome " |
| 261 "--app=http://evil.com/evil%20--join-the-b0tnet\n" | 277 "--app=http://evil.com/evil%20--join-the-b0tnet\n" |
| 278 "Icon=chrome-http__evil.com_evil\n" |
| 262 "StartupWMClass=evil.com__evil%20--join-the-b0tnet\n" | 279 "StartupWMClass=evil.com__evil%20--join-the-b0tnet\n" |
| 263 }, | 280 }, |
| 264 { "http://evil.com/evil; rm -rf /; \"; rm -rf $HOME >ownz0red", | 281 { "http://evil.com/evil; rm -rf /; \"; rm -rf $HOME >ownz0red", |
| 265 "Innocent Title", | 282 "Innocent Title", |
| 266 "chrome-http__evil.com_evil", | 283 "chrome-http__evil.com_evil", |
| 267 | 284 |
| 285 "[Desktop Entry]\n" |
| 268 "Name=Google Chrome\n" | 286 "Name=Google Chrome\n" |
| 269 "Exec=/opt/google/chrome/google-chrome %U\n", | 287 "Exec=/opt/google/chrome/google-chrome %U\n", |
| 270 | 288 |
| 271 "#!/usr/bin/env xdg-open\n" | 289 "#!/usr/bin/env xdg-open\n" |
| 290 "[Desktop Entry]\n" |
| 272 "Name=Innocent Title\n" | 291 "Name=Innocent Title\n" |
| 273 "Exec=/opt/google/chrome/google-chrome " | 292 "Exec=/opt/google/chrome/google-chrome " |
| 274 "\"--app=http://evil.com/evil;%20rm%20-rf%20/;%20%22;%20rm%20" | 293 "\"--app=http://evil.com/evil;%20rm%20-rf%20/;%20%22;%20rm%20" |
| 275 // Note: $ is escaped as \$ within an arg to Exec, and then | 294 // Note: $ is escaped as \$ within an arg to Exec, and then |
| 276 // the \ is escaped as \\ as all strings in a Desktop file should | 295 // the \ is escaped as \\ as all strings in a Desktop file should |
| 277 // be; finally, \\ becomes \\\\ when represented in a C++ string! | 296 // be; finally, \\ becomes \\\\ when represented in a C++ string! |
| 278 "-rf%20\\\\$HOME%20%3Eownz0red\"\n" | 297 "-rf%20\\\\$HOME%20%3Eownz0red\"\n" |
| 298 "Icon=chrome-http__evil.com_evil\n" |
| 279 "StartupWMClass=evil.com__evil;%20rm%20-rf%20_;%20%22;%20" | 299 "StartupWMClass=evil.com__evil;%20rm%20-rf%20_;%20%22;%20" |
| 280 "rm%20-rf%20$HOME%20%3Eownz0red\n" | 300 "rm%20-rf%20$HOME%20%3Eownz0red\n" |
| 281 }, | 301 }, |
| 282 { "http://evil.com/evil | cat `echo ownz0red` >/dev/null", | 302 { "http://evil.com/evil | cat `echo ownz0red` >/dev/null", |
| 283 "Innocent Title", | 303 "Innocent Title", |
| 284 "chrome-http__evil.com_evil", | 304 "chrome-http__evil.com_evil", |
| 285 | 305 |
| 306 "[Desktop Entry]\n" |
| 286 "Name=Google Chrome\n" | 307 "Name=Google Chrome\n" |
| 287 "Exec=/opt/google/chrome/google-chrome %U\n", | 308 "Exec=/opt/google/chrome/google-chrome %U\n", |
| 288 | 309 |
| 289 "#!/usr/bin/env xdg-open\n" | 310 "#!/usr/bin/env xdg-open\n" |
| 311 "[Desktop Entry]\n" |
| 290 "Name=Innocent Title\n" | 312 "Name=Innocent Title\n" |
| 291 "Exec=/opt/google/chrome/google-chrome " | 313 "Exec=/opt/google/chrome/google-chrome " |
| 292 "--app=http://evil.com/evil%20%7C%20cat%20%60echo%20ownz0red" | 314 "--app=http://evil.com/evil%20%7C%20cat%20%60echo%20ownz0red" |
| 293 "%60%20%3E/dev/null\n" | 315 "%60%20%3E/dev/null\n" |
| 316 "Icon=chrome-http__evil.com_evil\n" |
| 294 "StartupWMClass=evil.com__evil%20%7C%20cat%20%60echo%20ownz0red" | 317 "StartupWMClass=evil.com__evil%20%7C%20cat%20%60echo%20ownz0red" |
| 295 "%60%20%3E_dev_null\n" | 318 "%60%20%3E_dev_null\n" |
| 296 }, | 319 }, |
| 297 }; | 320 }; |
| 298 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { | 321 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { |
| 299 SCOPED_TRACE(i); | 322 SCOPED_TRACE(i); |
| 300 EXPECT_EQ( | 323 EXPECT_EQ( |
| 301 test_cases[i].expected_output, | 324 test_cases[i].expected_output, |
| 302 ShellIntegration::GetDesktopFileContents( | 325 ShellIntegration::GetDesktopFileContents( |
| 303 test_cases[i].template_contents, | 326 test_cases[i].template_contents, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 326 // Non-default profile path should get chrome::kBrowserAppID joined with | 349 // Non-default profile path should get chrome::kBrowserAppID joined with |
| 327 // profile info. | 350 // profile info. |
| 328 FilePath profile_path(FILE_PATH_LITERAL("root")); | 351 FilePath profile_path(FILE_PATH_LITERAL("root")); |
| 329 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd")); | 352 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd")); |
| 330 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test")); | 353 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test")); |
| 331 EXPECT_EQ(BrowserDistribution::GetDistribution()->GetBrowserAppId() + | 354 EXPECT_EQ(BrowserDistribution::GetDistribution()->GetBrowserAppId() + |
| 332 L".udd.UserDataTest", | 355 L".udd.UserDataTest", |
| 333 ShellIntegration::GetChromiumAppId(profile_path)); | 356 ShellIntegration::GetChromiumAppId(profile_path)); |
| 334 } | 357 } |
| 335 #endif | 358 #endif |
| OLD | NEW |