| OLD | NEW | 
|    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/shell_integration.h" |    5 #include "chrome/browser/shell_integration.h" | 
|    6  |    6  | 
|    7 #include <algorithm> |    7 #include <algorithm> | 
|    8 #include <cstdlib> |    8 #include <cstdlib> | 
|    9 #include <map> |    9 #include <map> | 
|   10  |   10  | 
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  453       false, |  453       false, | 
|  454  |  454  | 
|  455       "#!/usr/bin/env xdg-open\n" |  455       "#!/usr/bin/env xdg-open\n" | 
|  456       "[Desktop Entry]\n" |  456       "[Desktop Entry]\n" | 
|  457       "Version=1.0\n" |  457       "Version=1.0\n" | 
|  458       "Terminal=false\n" |  458       "Terminal=false\n" | 
|  459       "Type=Application\n" |  459       "Type=Application\n" | 
|  460       "Name=GMail\n" |  460       "Name=GMail\n" | 
|  461       "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" |  461       "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" | 
|  462       "Icon=chrome-http__gmail.com\n" |  462       "Icon=chrome-http__gmail.com\n" | 
|  463 #if !defined(USE_AURA) |  | 
|  464       // Aura Chrome does not (yet) set WMClass, so we only expect |  | 
|  465       // StartupWMClass on non-Aura builds. |  | 
|  466       "StartupWMClass=gmail.com\n" |  463       "StartupWMClass=gmail.com\n" | 
|  467 #endif |  | 
|  468     }, |  464     }, | 
|  469  |  465  | 
|  470     // Make sure that empty icons are replaced by the chrome icon. |  466     // Make sure that empty icons are replaced by the chrome icon. | 
|  471     { "http://gmail.com", |  467     { "http://gmail.com", | 
|  472       "GMail", |  468       "GMail", | 
|  473       "", |  469       "", | 
|  474       false, |  470       false, | 
|  475  |  471  | 
|  476       "#!/usr/bin/env xdg-open\n" |  472       "#!/usr/bin/env xdg-open\n" | 
|  477       "[Desktop Entry]\n" |  473       "[Desktop Entry]\n" | 
|  478       "Version=1.0\n" |  474       "Version=1.0\n" | 
|  479       "Terminal=false\n" |  475       "Terminal=false\n" | 
|  480       "Type=Application\n" |  476       "Type=Application\n" | 
|  481       "Name=GMail\n" |  477       "Name=GMail\n" | 
|  482       "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" |  478       "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" | 
|  483       "Icon=chromium-browser\n" |  479       "Icon=chromium-browser\n" | 
|  484 #if !defined(USE_AURA) |  | 
|  485       // Aura Chrome does not (yet) set WMClass, so we only expect |  | 
|  486       // StartupWMClass on non-Aura builds. |  | 
|  487       "StartupWMClass=gmail.com\n" |  480       "StartupWMClass=gmail.com\n" | 
|  488 #endif |  | 
|  489     }, |  481     }, | 
|  490  |  482  | 
|  491     // Test adding NoDisplay=true. |  483     // Test adding NoDisplay=true. | 
|  492     { "http://gmail.com", |  484     { "http://gmail.com", | 
|  493       "GMail", |  485       "GMail", | 
|  494       "chrome-http__gmail.com", |  486       "chrome-http__gmail.com", | 
|  495       true, |  487       true, | 
|  496  |  488  | 
|  497       "#!/usr/bin/env xdg-open\n" |  489       "#!/usr/bin/env xdg-open\n" | 
|  498       "[Desktop Entry]\n" |  490       "[Desktop Entry]\n" | 
|  499       "Version=1.0\n" |  491       "Version=1.0\n" | 
|  500       "Terminal=false\n" |  492       "Terminal=false\n" | 
|  501       "Type=Application\n" |  493       "Type=Application\n" | 
|  502       "Name=GMail\n" |  494       "Name=GMail\n" | 
|  503       "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" |  495       "Exec=/opt/google/chrome/google-chrome --app=http://gmail.com/\n" | 
|  504       "Icon=chrome-http__gmail.com\n" |  496       "Icon=chrome-http__gmail.com\n" | 
|  505       "NoDisplay=true\n" |  497       "NoDisplay=true\n" | 
|  506 #if !defined(USE_AURA) |  | 
|  507       // Aura Chrome does not (yet) set WMClass, so we only expect |  | 
|  508       // StartupWMClass on non-Aura builds. |  | 
|  509       "StartupWMClass=gmail.com\n" |  498       "StartupWMClass=gmail.com\n" | 
|  510 #endif |  | 
|  511     }, |  499     }, | 
|  512  |  500  | 
|  513     // Now we're starting to be more evil... |  501     // Now we're starting to be more evil... | 
|  514     { "http://evil.com/evil --join-the-b0tnet", |  502     { "http://evil.com/evil --join-the-b0tnet", | 
|  515       "Ownz0red\nExec=rm -rf /", |  503       "Ownz0red\nExec=rm -rf /", | 
|  516       "chrome-http__evil.com_evil", |  504       "chrome-http__evil.com_evil", | 
|  517       false, |  505       false, | 
|  518  |  506  | 
|  519       "#!/usr/bin/env xdg-open\n" |  507       "#!/usr/bin/env xdg-open\n" | 
|  520       "[Desktop Entry]\n" |  508       "[Desktop Entry]\n" | 
|  521       "Version=1.0\n" |  509       "Version=1.0\n" | 
|  522       "Terminal=false\n" |  510       "Terminal=false\n" | 
|  523       "Type=Application\n" |  511       "Type=Application\n" | 
|  524       "Name=http://evil.com/evil%20--join-the-b0tnet\n" |  512       "Name=http://evil.com/evil%20--join-the-b0tnet\n" | 
|  525       "Exec=/opt/google/chrome/google-chrome " |  513       "Exec=/opt/google/chrome/google-chrome " | 
|  526       "--app=http://evil.com/evil%20--join-the-b0tnet\n" |  514       "--app=http://evil.com/evil%20--join-the-b0tnet\n" | 
|  527       "Icon=chrome-http__evil.com_evil\n" |  515       "Icon=chrome-http__evil.com_evil\n" | 
|  528 #if !defined(USE_AURA) |  | 
|  529       // Aura Chrome does not (yet) set WMClass, so we only expect |  | 
|  530       // StartupWMClass on non-Aura builds. |  | 
|  531       "StartupWMClass=evil.com__evil%20--join-the-b0tnet\n" |  516       "StartupWMClass=evil.com__evil%20--join-the-b0tnet\n" | 
|  532 #endif |  | 
|  533     }, |  517     }, | 
|  534     { "http://evil.com/evil; rm -rf /; \"; rm -rf $HOME >ownz0red", |  518     { "http://evil.com/evil; rm -rf /; \"; rm -rf $HOME >ownz0red", | 
|  535       "Innocent Title", |  519       "Innocent Title", | 
|  536       "chrome-http__evil.com_evil", |  520       "chrome-http__evil.com_evil", | 
|  537       false, |  521       false, | 
|  538  |  522  | 
|  539       "#!/usr/bin/env xdg-open\n" |  523       "#!/usr/bin/env xdg-open\n" | 
|  540       "[Desktop Entry]\n" |  524       "[Desktop Entry]\n" | 
|  541       "Version=1.0\n" |  525       "Version=1.0\n" | 
|  542       "Terminal=false\n" |  526       "Terminal=false\n" | 
|  543       "Type=Application\n" |  527       "Type=Application\n" | 
|  544       "Name=Innocent Title\n" |  528       "Name=Innocent Title\n" | 
|  545       "Exec=/opt/google/chrome/google-chrome " |  529       "Exec=/opt/google/chrome/google-chrome " | 
|  546       "\"--app=http://evil.com/evil;%20rm%20-rf%20/;%20%22;%20rm%20" |  530       "\"--app=http://evil.com/evil;%20rm%20-rf%20/;%20%22;%20rm%20" | 
|  547       // Note: $ is escaped as \$ within an arg to Exec, and then |  531       // Note: $ is escaped as \$ within an arg to Exec, and then | 
|  548       // the \ is escaped as \\ as all strings in a Desktop file should |  532       // the \ is escaped as \\ as all strings in a Desktop file should | 
|  549       // be; finally, \\ becomes \\\\ when represented in a C++ string! |  533       // be; finally, \\ becomes \\\\ when represented in a C++ string! | 
|  550       "-rf%20\\\\$HOME%20%3Eownz0red\"\n" |  534       "-rf%20\\\\$HOME%20%3Eownz0red\"\n" | 
|  551       "Icon=chrome-http__evil.com_evil\n" |  535       "Icon=chrome-http__evil.com_evil\n" | 
|  552 #if !defined(USE_AURA) |  | 
|  553       // Aura Chrome does not (yet) set WMClass, so we only expect |  | 
|  554       // StartupWMClass on non-Aura builds. |  | 
|  555       "StartupWMClass=evil.com__evil;%20rm%20-rf%20_;%20%22;%20" |  536       "StartupWMClass=evil.com__evil;%20rm%20-rf%20_;%20%22;%20" | 
|  556       "rm%20-rf%20$HOME%20%3Eownz0red\n" |  537       "rm%20-rf%20$HOME%20%3Eownz0red\n" | 
|  557 #endif |  | 
|  558     }, |  538     }, | 
|  559     { "http://evil.com/evil | cat `echo ownz0red` >/dev/null", |  539     { "http://evil.com/evil | cat `echo ownz0red` >/dev/null", | 
|  560       "Innocent Title", |  540       "Innocent Title", | 
|  561       "chrome-http__evil.com_evil", |  541       "chrome-http__evil.com_evil", | 
|  562       false, |  542       false, | 
|  563  |  543  | 
|  564       "#!/usr/bin/env xdg-open\n" |  544       "#!/usr/bin/env xdg-open\n" | 
|  565       "[Desktop Entry]\n" |  545       "[Desktop Entry]\n" | 
|  566       "Version=1.0\n" |  546       "Version=1.0\n" | 
|  567       "Terminal=false\n" |  547       "Terminal=false\n" | 
|  568       "Type=Application\n" |  548       "Type=Application\n" | 
|  569       "Name=Innocent Title\n" |  549       "Name=Innocent Title\n" | 
|  570       "Exec=/opt/google/chrome/google-chrome " |  550       "Exec=/opt/google/chrome/google-chrome " | 
|  571       "--app=http://evil.com/evil%20%7C%20cat%20%60echo%20ownz0red" |  551       "--app=http://evil.com/evil%20%7C%20cat%20%60echo%20ownz0red" | 
|  572       "%60%20%3E/dev/null\n" |  552       "%60%20%3E/dev/null\n" | 
|  573       "Icon=chrome-http__evil.com_evil\n" |  553       "Icon=chrome-http__evil.com_evil\n" | 
|  574 #if !defined(USE_AURA) |  | 
|  575       // Aura Chrome does not (yet) set WMClass, so we only expect |  | 
|  576       // StartupWMClass on non-Aura builds. |  | 
|  577       "StartupWMClass=evil.com__evil%20%7C%20cat%20%60echo%20ownz0red" |  554       "StartupWMClass=evil.com__evil%20%7C%20cat%20%60echo%20ownz0red" | 
|  578       "%60%20%3E_dev_null\n" |  555       "%60%20%3E_dev_null\n" | 
|  579 #endif |  | 
|  580     }, |  556     }, | 
|  581   }; |  557   }; | 
|  582  |  558  | 
|  583   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { |  559   for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) { | 
|  584     SCOPED_TRACE(i); |  560     SCOPED_TRACE(i); | 
|  585     EXPECT_EQ( |  561     EXPECT_EQ( | 
|  586         test_cases[i].expected_output, |  562         test_cases[i].expected_output, | 
|  587         ShellIntegrationLinux::GetDesktopFileContents( |  563         ShellIntegrationLinux::GetDesktopFileContents( | 
|  588             kChromeExePath, |  564             kChromeExePath, | 
|  589             web_app::GenerateApplicationNameFromURL(GURL(test_cases[i].url)), |  565             web_app::GenerateApplicationNameFromURL(GURL(test_cases[i].url)), | 
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  630     SCOPED_TRACE(i); |  606     SCOPED_TRACE(i); | 
|  631     EXPECT_EQ( |  607     EXPECT_EQ( | 
|  632         test_cases[i].expected_output, |  608         test_cases[i].expected_output, | 
|  633         ShellIntegrationLinux::GetDirectoryFileContents( |  609         ShellIntegrationLinux::GetDirectoryFileContents( | 
|  634             ASCIIToUTF16(test_cases[i].title), |  610             ASCIIToUTF16(test_cases[i].title), | 
|  635             test_cases[i].icon_name)); |  611             test_cases[i].icon_name)); | 
|  636   } |  612   } | 
|  637 } |  613 } | 
|  638  |  614  | 
|  639 #endif |  615 #endif | 
| OLD | NEW |