Commit 7fc55d02 authored by deepak.m1's avatar deepak.m1 Committed by Commit bot

Converting file_display_name_ type from base::string16 to base::FilePath.

This is for making type of file_to_install and file_display_name_ consistent.

BUG=486616

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

Cr-Commit-Position: refs/heads/master@{#329581}
parent 10ae51f6
...@@ -79,10 +79,8 @@ void InstallExtensionHandler::HandleStartDragMessage( ...@@ -79,10 +79,8 @@ void InstallExtensionHandler::HandleStartDragMessage(
file_to_install_ = file_info.path; file_to_install_ = file_info.path;
// Use the display name if provided, for checking file names // Use the display name if provided, for checking file names
// (.path is likely a random hash value in that case). // (.path is likely a random hash value in that case).
// TODO(dcheng): It would be nice to make this a FilePath too. file_display_name_ =
file_display_name_ = file_info.display_name.empty() file_info.display_name.empty() ? file_info.path : file_info.display_name;
? file_info.path.AsUTF16Unsafe()
: file_info.display_name.AsUTF16Unsafe();
} }
void InstallExtensionHandler::HandleStopDragMessage( void InstallExtensionHandler::HandleStopDragMessage(
...@@ -101,10 +99,7 @@ void InstallExtensionHandler::HandleInstallMessage( ...@@ -101,10 +99,7 @@ void InstallExtensionHandler::HandleInstallMessage(
Profile* profile = Profile::FromBrowserContext( Profile* profile = Profile::FromBrowserContext(
web_ui()->GetWebContents()->GetBrowserContext()); web_ui()->GetWebContents()->GetBrowserContext());
const bool kCaseSensitive = false; if (file_display_name_.MatchesExtension(FILE_PATH_LITERAL(".zip"))) {
if (EndsWith(
file_display_name_, base::ASCIIToUTF16(".zip"), kCaseSensitive)) {
ZipFileInstaller::Create(ExtensionSystem::Get(profile)->extension_service()) ZipFileInstaller::Create(ExtensionSystem::Get(profile)->extension_service())
->LoadFromZipFile(file_to_install_); ->LoadFromZipFile(file_to_install_);
} else { } else {
...@@ -117,14 +112,10 @@ void InstallExtensionHandler::HandleInstallMessage( ...@@ -117,14 +112,10 @@ void InstallExtensionHandler::HandleInstallMessage(
CrxInstaller::OffStoreInstallAllowedFromSettingsPage); CrxInstaller::OffStoreInstallAllowedFromSettingsPage);
crx_installer->set_install_immediately(true); crx_installer->set_install_immediately(true);
if (EndsWith(file_display_name_, if (file_display_name_.MatchesExtension(FILE_PATH_LITERAL(".user.js"))) {
base::ASCIIToUTF16(".user.js"),
kCaseSensitive)) {
crx_installer->InstallUserScript( crx_installer->InstallUserScript(
file_to_install_, net::FilePathToFileURL(file_to_install_)); file_to_install_, net::FilePathToFileURL(file_to_install_));
} else if (EndsWith(file_display_name_, } else if (file_display_name_.MatchesExtension(FILE_PATH_LITERAL(".crx"))) {
base::ASCIIToUTF16(".crx"),
kCaseSensitive)) {
crx_installer->InstallCrx(file_to_install_); crx_installer->InstallCrx(file_to_install_);
} else { } else {
CHECK(false); CHECK(false);
......
...@@ -52,7 +52,7 @@ class InstallExtensionHandler : public content::WebUIMessageHandler { ...@@ -52,7 +52,7 @@ class InstallExtensionHandler : public content::WebUIMessageHandler {
// The path to the file that will be installed when HandleInstallMessage() is // The path to the file that will be installed when HandleInstallMessage() is
// called. // called.
base::FilePath file_to_install_; base::FilePath file_to_install_;
base::string16 file_display_name_; base::FilePath file_display_name_;
DISALLOW_COPY_AND_ASSIGN(InstallExtensionHandler); DISALLOW_COPY_AND_ASSIGN(InstallExtensionHandler);
}; };
......
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