Commit 06bfeb15 authored by thestig@chromium.org's avatar thestig@chromium.org

Cleanup: Make namespace shell_integration_linux follow the style guide.

Review URL: https://codereview.chromium.org/300463002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272966 0039d316-1c4b-4281-b951-d872f2087c98
parent 313fcf63
......@@ -323,17 +323,13 @@ const char kAppListDesktopName[] = "chrome-app-list";
const char kAppListDesktopName[] = "chromium-app-list";
#endif
} // namespace
namespace {
// Utility function to get the path to the version of a script shipped with
// Chrome. |script| gives the name of the script. |chrome_version| returns the
// path to the Chrome version of the script, and the return value of the
// function is true if the function is successful and the Chrome version is
// not the script found on the PATH.
bool GetChromeVersionOfScript(const std::string& script,
std::string* chrome_version) {
std::string* chrome_version) {
// Get the path to the Chrome version.
base::FilePath chrome_dir;
if (!PathService::Get(base::DIR_EXE, &chrome_dir))
......@@ -386,7 +382,7 @@ bool SetDefaultWebClient(const std::string& protocol) {
argv.push_back(kXdgSettingsDefaultSchemeHandler);
argv.push_back(protocol);
}
argv.push_back(ShellIntegrationLinux::GetDesktopName(env.get()));
argv.push_back(shell_integration_linux::GetDesktopName(env.get()));
int exit_code;
bool ran_ok = LaunchXdgUtility(argv, &exit_code);
......@@ -421,7 +417,7 @@ ShellIntegration::DefaultWebClientState GetIsDefaultWebClient(
argv.push_back(kXdgSettingsDefaultSchemeHandler);
argv.push_back(protocol);
}
argv.push_back(ShellIntegrationLinux::GetDesktopName(env.get()));
argv.push_back(shell_integration_linux::GetDesktopName(env.get()));
std::string reply;
int success_code;
......@@ -499,11 +495,11 @@ base::FilePath GetChromeExePath() {
return chrome_exe_path;
}
} // namespace
} // namespace
// static
ShellIntegration::DefaultWebClientSetPermission
ShellIntegration::CanSetAsDefaultBrowser() {
ShellIntegration::CanSetAsDefaultBrowser() {
return SET_DEFAULT_UNATTENDED;
}
......@@ -513,12 +509,14 @@ bool ShellIntegration::SetAsDefaultBrowser() {
}
// static
bool ShellIntegration::SetAsDefaultProtocolClient(const std::string& protocol) {
bool ShellIntegration::SetAsDefaultProtocolClient(
const std::string& protocol) {
return SetDefaultWebClient(protocol);
}
// static
ShellIntegration::DefaultWebClientState ShellIntegration::GetDefaultBrowser() {
ShellIntegration::DefaultWebClientState
ShellIntegration::GetDefaultBrowser() {
return GetIsDefaultWebClient(std::string());
}
......@@ -547,7 +545,7 @@ bool ShellIntegration::IsFirefoxDefaultBrowser() {
return browser.find("irefox") != std::string::npos;
}
namespace ShellIntegrationLinux {
namespace shell_integration_linux {
bool GetDataWriteLocation(base::Environment* env, base::FilePath* search_path) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
......@@ -856,7 +854,7 @@ std::string GetDesktopFileContentsForCommand(
return output_buffer;
#else
NOTIMPLEMENTED();
return std::string("");
return std::string();
#endif
}
......@@ -896,7 +894,7 @@ std::string GetDirectoryFileContents(const base::string16& title,
return output_buffer;
#else
NOTIMPLEMENTED();
return std::string("");
return std::string();
#endif
}
......@@ -940,7 +938,7 @@ bool CreateDesktopShortcut(
}
if (creation_locations.on_desktop) {
std::string contents = ShellIntegrationLinux::GetDesktopFileContents(
std::string contents = GetDesktopFileContents(
chrome_exe_path,
app_name,
shortcut_info.url,
......@@ -964,7 +962,7 @@ bool CreateDesktopShortcut(
break;
case web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS:
directory_filename = base::FilePath(kDirectoryFilename);
directory_contents = ShellIntegrationLinux::GetDirectoryFileContents(
directory_contents = GetDirectoryFileContents(
ShellIntegration::GetAppShortcutsSubdirName(), "");
break;
default:
......@@ -973,7 +971,7 @@ bool CreateDesktopShortcut(
}
// Set NoDisplay=true if hidden but not in the applications menu. This will
// hide the application from user-facing menus.
std::string contents = ShellIntegrationLinux::GetDesktopFileContents(
std::string contents = GetDesktopFileContents(
chrome_exe_path,
app_name,
shortcut_info.url,
......@@ -1081,4 +1079,4 @@ void DeleteAllDesktopShortcuts(const base::FilePath& profile_path) {
}
}
} // namespace ShellIntegrationLinux
} // namespace shell_integration_linux
......@@ -17,7 +17,7 @@ class CommandLine;
class Environment;
}
namespace ShellIntegrationLinux {
namespace shell_integration_linux {
// Get the path to write user-specific application data files to, as specified
// in the XDG Base Directory Specification:
......@@ -136,6 +136,6 @@ void DeleteDesktopShortcuts(const base::FilePath& profile_path,
// for the profile in |profile_path|.
void DeleteAllDesktopShortcuts(const base::FilePath& profile_path);
} // namespace ShellIntegrationLinux
} // namespace shell_integration_linux
#endif // CHROME_BROWSER_SHELL_INTEGRATION_LINUX_H_
......@@ -30,6 +30,8 @@
using content::BrowserThread;
using ::testing::ElementsAre;
namespace shell_integration_linux {
namespace {
// Provides mock environment variables values based on a stored map.
......@@ -79,7 +81,7 @@ TEST(ShellIntegrationTest, GetDataWriteLocation) {
env.Set("HOME", "/home/user");
env.Set("XDG_DATA_HOME", "/user/path");
base::FilePath path;
ASSERT_TRUE(ShellIntegrationLinux::GetDataWriteLocation(&env, &path));
ASSERT_TRUE(GetDataWriteLocation(&env, &path));
EXPECT_EQ(base::FilePath("/user/path"), path);
}
......@@ -88,7 +90,7 @@ TEST(ShellIntegrationTest, GetDataWriteLocation) {
MockEnvironment env;
env.Set("HOME", "/home/user");
base::FilePath path;
ASSERT_TRUE(ShellIntegrationLinux::GetDataWriteLocation(&env, &path));
ASSERT_TRUE(GetDataWriteLocation(&env, &path));
EXPECT_EQ(base::FilePath("/home/user/.local/share"), path);
}
......@@ -96,7 +98,7 @@ TEST(ShellIntegrationTest, GetDataWriteLocation) {
{
MockEnvironment env;
base::FilePath path;
ASSERT_FALSE(ShellIntegrationLinux::GetDataWriteLocation(&env, &path));
ASSERT_FALSE(GetDataWriteLocation(&env, &path));
}
}
......@@ -111,7 +113,7 @@ TEST(ShellIntegrationTest, GetDataSearchLocations) {
env.Set("XDG_DATA_HOME", "/user/path");
env.Set("XDG_DATA_DIRS", "/system/path/1:/system/path/2");
EXPECT_THAT(
ShellIntegrationLinux::GetDataSearchLocations(&env),
GetDataSearchLocations(&env),
ElementsAre(base::FilePath("/user/path"),
base::FilePath("/system/path/1"),
base::FilePath("/system/path/2")));
......@@ -123,7 +125,7 @@ TEST(ShellIntegrationTest, GetDataSearchLocations) {
env.Set("HOME", "/home/user");
env.Set("XDG_DATA_DIRS", "/system/path/1:/system/path/2");
EXPECT_THAT(
ShellIntegrationLinux::GetDataSearchLocations(&env),
GetDataSearchLocations(&env),
ElementsAre(base::FilePath("/home/user/.local/share"),
base::FilePath("/system/path/1"),
base::FilePath("/system/path/2")));
......@@ -135,7 +137,7 @@ TEST(ShellIntegrationTest, GetDataSearchLocations) {
MockEnvironment env;
env.Set("XDG_DATA_DIRS", "/system/path/1:/system/path/2");
EXPECT_THAT(
ShellIntegrationLinux::GetDataSearchLocations(&env),
GetDataSearchLocations(&env),
ElementsAre(base::FilePath("/system/path/1"),
base::FilePath("/system/path/2")));
}
......@@ -146,7 +148,7 @@ TEST(ShellIntegrationTest, GetDataSearchLocations) {
env.Set("HOME", "/home/user");
env.Set("XDG_DATA_HOME", "/user/path");
EXPECT_THAT(
ShellIntegrationLinux::GetDataSearchLocations(&env),
GetDataSearchLocations(&env),
ElementsAre(base::FilePath("/user/path"),
base::FilePath("/usr/local/share"),
base::FilePath("/usr/share")));
......@@ -167,8 +169,7 @@ TEST(ShellIntegrationTest, GetExistingShortcutLocations) {
{
MockEnvironment env;
web_app::ShortcutLocations result =
ShellIntegrationLinux::GetExistingShortcutLocations(
&env, kProfilePath, kExtensionId);
GetExistingShortcutLocations(&env, kProfilePath, kExtensionId);
EXPECT_FALSE(result.on_desktop);
EXPECT_EQ(web_app::APP_MENU_LOCATION_NONE,
result.applications_menu_location);
......@@ -188,9 +189,8 @@ TEST(ShellIntegrationTest, GetExistingShortcutLocations) {
ASSERT_FALSE(base::WriteFile(
desktop_path.AppendASCII(kTemplateFilename),
"", 0));
web_app::ShortcutLocations result =
ShellIntegrationLinux::GetExistingShortcutLocations(
&env, kProfilePath, kExtensionId, desktop_path);
web_app::ShortcutLocations result = GetExistingShortcutLocations(
&env, kProfilePath, kExtensionId, desktop_path);
EXPECT_TRUE(result.on_desktop);
EXPECT_EQ(web_app::APP_MENU_LOCATION_NONE,
result.applications_menu_location);
......@@ -212,8 +212,7 @@ TEST(ShellIntegrationTest, GetExistingShortcutLocations) {
apps_path.AppendASCII(kTemplateFilename),
"", 0));
web_app::ShortcutLocations result =
ShellIntegrationLinux::GetExistingShortcutLocations(
&env, kProfilePath, kExtensionId);
GetExistingShortcutLocations(&env, kProfilePath, kExtensionId);
EXPECT_FALSE(result.on_desktop);
EXPECT_EQ(web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS,
result.applications_menu_location);
......@@ -235,8 +234,7 @@ TEST(ShellIntegrationTest, GetExistingShortcutLocations) {
apps_path.AppendASCII(kTemplateFilename),
kNoDisplayDesktopFile, strlen(kNoDisplayDesktopFile)));
web_app::ShortcutLocations result =
ShellIntegrationLinux::GetExistingShortcutLocations(
&env, kProfilePath, kExtensionId);
GetExistingShortcutLocations(&env, kProfilePath, kExtensionId);
// Doesn't count as being in applications menu.
EXPECT_FALSE(result.on_desktop);
EXPECT_EQ(web_app::APP_MENU_LOCATION_NONE,
......@@ -265,9 +263,8 @@ TEST(ShellIntegrationTest, GetExistingShortcutLocations) {
ASSERT_FALSE(base::WriteFile(
apps_path.AppendASCII(kTemplateFilename),
"", 0));
web_app::ShortcutLocations result =
ShellIntegrationLinux::GetExistingShortcutLocations(
&env, kProfilePath, kExtensionId, desktop_path);
web_app::ShortcutLocations result = GetExistingShortcutLocations(
&env, kProfilePath, kExtensionId, desktop_path);
EXPECT_TRUE(result.on_desktop);
EXPECT_EQ(web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS,
result.applications_menu_location);
......@@ -304,8 +301,7 @@ TEST(ShellIntegrationTest, GetExistingShortcutContents) {
kTestData1, strlen(kTestData1)));
std::string contents;
ASSERT_TRUE(
ShellIntegrationLinux::GetExistingShortcutContents(
&env, kTemplateFilepath, &contents));
GetExistingShortcutContents(&env, kTemplateFilepath, &contents));
EXPECT_EQ(kTestData1, contents);
}
......@@ -324,8 +320,7 @@ TEST(ShellIntegrationTest, GetExistingShortcutContents) {
kTestData1, strlen(kTestData1)));
std::string contents;
ASSERT_TRUE(
ShellIntegrationLinux::GetExistingShortcutContents(
&env, kTemplateFilepath, &contents));
GetExistingShortcutContents(&env, kTemplateFilepath, &contents));
EXPECT_EQ(kTestData1, contents);
}
......@@ -344,8 +339,7 @@ TEST(ShellIntegrationTest, GetExistingShortcutContents) {
kTestData2, strlen(kTestData2)));
std::string contents;
ASSERT_TRUE(
ShellIntegrationLinux::GetExistingShortcutContents(
&env, kTemplateFilepath, &contents));
GetExistingShortcutContents(&env, kTemplateFilepath, &contents));
EXPECT_EQ(kTestData2, contents);
}
......@@ -372,8 +366,7 @@ TEST(ShellIntegrationTest, GetExistingShortcutContents) {
kTestData2, strlen(kTestData2)));
std::string contents;
ASSERT_TRUE(
ShellIntegrationLinux::GetExistingShortcutContents(
&env, kTemplateFilepath, &contents));
GetExistingShortcutContents(&env, kTemplateFilepath, &contents));
EXPECT_EQ(kTestData2, contents);
}
}
......@@ -382,8 +375,7 @@ TEST(ShellIntegrationTest, GetExtensionShortcutFilename) {
base::FilePath kProfilePath("a/b/c/Profile Name?");
const char kExtensionId[] = "extensionid";
EXPECT_EQ(base::FilePath("chrome-extensionid-Profile_Name_.desktop"),
ShellIntegrationLinux::GetExtensionShortcutFilename(
kProfilePath, kExtensionId));
GetExtensionShortcutFilename(kProfilePath, kExtensionId));
}
TEST(ShellIntegrationTest, GetExistingProfileShortcutFilenames) {
......@@ -408,8 +400,7 @@ TEST(ShellIntegrationTest, GetExistingProfileShortcutFilenames) {
base::WriteFile(
temp_dir.path().AppendASCII(kUnrelatedAppFilename), "", 0));
std::vector<base::FilePath> paths =
ShellIntegrationLinux::GetExistingProfileShortcutFilenames(
kProfilePath, temp_dir.path());
GetExistingProfileShortcutFilenames(kProfilePath, temp_dir.path());
// Path order is arbitrary. Sort the output for consistency.
std::sort(paths.begin(), paths.end());
EXPECT_THAT(paths,
......@@ -434,8 +425,7 @@ TEST(ShellIntegrationTest, GetWebShortcutFilename) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) {
EXPECT_EQ(std::string(chrome::kBrowserProcessExecutableName) + "-" +
test_cases[i].path,
ShellIntegrationLinux::GetWebShortcutFilename(
GURL(test_cases[i].url)).value()) <<
GetWebShortcutFilename(GURL(test_cases[i].url)).value()) <<
" while testing " << test_cases[i].url;
}
}
......@@ -575,7 +565,7 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) {
SCOPED_TRACE(i);
EXPECT_EQ(
test_cases[i].expected_output,
ShellIntegrationLinux::GetDesktopFileContents(
GetDesktopFileContents(
kChromeExePath,
web_app::GenerateApplicationNameFromURL(GURL(test_cases[i].url)),
GURL(test_cases[i].url),
......@@ -590,7 +580,7 @@ TEST(ShellIntegrationTest, GetDesktopFileContents) {
TEST(ShellIntegrationTest, GetDesktopFileContentsAppList) {
const base::FilePath kChromeExePath("/opt/google/chrome/google-chrome");
CommandLine command_line(kChromeExePath);
base::CommandLine command_line(kChromeExePath);
command_line.AppendSwitch("--show-app-list");
EXPECT_EQ(
"#!/usr/bin/env xdg-open\n"
......@@ -603,7 +593,7 @@ TEST(ShellIntegrationTest, GetDesktopFileContentsAppList) {
"Icon=chrome_app_list\n"
"Categories=Network;WebBrowser;\n"
"StartupWMClass=chrome-app-list\n",
ShellIntegrationLinux::GetDesktopFileContentsForCommand(
GetDesktopFileContentsForCommand(
command_line,
"chrome-app-list",
GURL(),
......@@ -648,10 +638,10 @@ TEST(ShellIntegrationTest, GetDirectoryFileContents) {
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(test_cases); i++) {
SCOPED_TRACE(i);
EXPECT_EQ(
test_cases[i].expected_output,
ShellIntegrationLinux::GetDirectoryFileContents(
base::ASCIIToUTF16(test_cases[i].title),
test_cases[i].icon_name));
EXPECT_EQ(test_cases[i].expected_output,
GetDirectoryFileContents(base::ASCIIToUTF16(test_cases[i].title),
test_cases[i].icon_name));
}
}
} // namespace shell_integration_linux
......@@ -28,7 +28,7 @@ void CreateShortcuts() {
std::string app_list_title =
l10n_util::GetStringUTF8(IDS_APP_LIST_SHORTCUT_NAME);
if (!ShellIntegrationLinux::CreateAppListDesktopShortcut(
if (!shell_integration_linux::CreateAppListDesktopShortcut(
app_list::kAppListWMClass,
app_list_title)) {
LOG(WARNING) << "Unable to create App Launcher shortcut.";
......
......@@ -136,7 +136,7 @@ class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate,
window_state_->AddObserver(this);
window_state_->window()->AddObserver(this);
}
virtual ~NativeAppWindowStateDelegate(){
virtual ~NativeAppWindowStateDelegate() {
if (window_state_) {
window_state_->RemoveObserver(this);
window_state_->window()->RemoveObserver(this);
......@@ -220,7 +220,7 @@ void ChromeNativeAppWindowViews::InitializeDefaultWindow(
// Set up a custom WM_CLASS for app windows. This allows task switchers in
// X11 environments to distinguish them from main browser windows.
init_params.wm_class_name = web_app::GetWMClassFromAppName(app_name);
init_params.wm_class_class = ShellIntegrationLinux::GetProgramClassName();
init_params.wm_class_class = shell_integration_linux::GetProgramClassName();
const char kX11WindowRoleApp[] = "app";
init_params.wm_role_name = std::string(kX11WindowRoleApp);
#endif
......
......@@ -108,8 +108,8 @@ void BrowserFrame::InitBrowserFrame() {
chrome::HOST_DESKTOP_TYPE_ASH || chrome::ShouldOpenAshOnStartup()) {
params.context = ash::Shell::GetPrimaryRootWindow();
#if defined(OS_WIN)
// If this window is under ASH on Windows, we need it to be translucent.
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
// If this window is under ASH on Windows, we need it to be translucent.
params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW;
#endif
}
#endif
......@@ -120,7 +120,7 @@ void BrowserFrame::InitBrowserFrame() {
// windows and e.g app windows.
const CommandLine& command_line = *CommandLine::ForCurrentProcess();
const Browser& browser = *browser_view_->browser();
params.wm_class_class = ShellIntegrationLinux::GetProgramClassName();
params.wm_class_class = shell_integration_linux::GetProgramClassName();
params.wm_class_name = params.wm_class_class;
if (browser.is_app() && !browser.is_devtools()) {
// This window is a hosted app or v1 packaged app.
......
......@@ -21,7 +21,7 @@ bool CreatePlatformShortcuts(
ShortcutCreationReason /*creation_reason*/) {
#if !defined(OS_CHROMEOS)
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
return ShellIntegrationLinux::CreateDesktopShortcut(
return shell_integration_linux::CreateDesktopShortcut(
shortcut_info, creation_locations);
#else
return false;
......@@ -31,7 +31,7 @@ bool CreatePlatformShortcuts(
void DeletePlatformShortcuts(const base::FilePath& web_app_path,
const ShortcutInfo& shortcut_info) {
#if !defined(OS_CHROMEOS)
ShellIntegrationLinux::DeleteDesktopShortcuts(shortcut_info.profile_path,
shell_integration_linux::DeleteDesktopShortcuts(shortcut_info.profile_path,
shortcut_info.extension_id);
#endif
}
......@@ -47,7 +47,7 @@ void UpdatePlatformShortcuts(
// Find out whether shortcuts are already installed.
ShortcutLocations creation_locations =
ShellIntegrationLinux::GetExistingShortcutLocations(
shell_integration_linux::GetExistingShortcutLocations(
env.get(), shortcut_info.profile_path, shortcut_info.extension_id);
// Always create a hidden shortcut in applications if a visible one is not
// being created. This allows the operating system to identify the app, but
......@@ -63,7 +63,7 @@ void UpdatePlatformShortcuts(
void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) {
#if !defined(OS_CHROMEOS)
ShellIntegrationLinux::DeleteAllDesktopShortcuts(profile_path);
shell_integration_linux::DeleteAllDesktopShortcuts(profile_path);
#endif
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment