summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/renderer_host')
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc10
-rw-r--r--chrome/browser/renderer_host/render_view_host.h4
-rw-r--r--chrome/browser/renderer_host/renderer_security_policy.cc11
-rw-r--r--chrome/browser/renderer_host/renderer_security_policy.h5
-rw-r--r--chrome/browser/renderer_host/renderer_security_policy_unittest.cc20
-rw-r--r--chrome/browser/renderer_host/resource_dispatcher_host.cc3
6 files changed, 31 insertions, 22 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 271df03..749f93c 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -402,7 +402,7 @@ void RenderViewHost::DragTargetDragEnter(const WebDropData& drop_data,
iter(drop_data.filenames.begin());
iter != drop_data.filenames.end(); ++iter) {
policy->GrantRequestURL(process()->pid(), net::FilePathToFileURL(*iter));
- policy->GrantUploadFile(process()->pid(), *iter);
+ policy->GrantUploadFile(process()->pid(), FilePath::FromWStringHack(*iter));
}
Send(new ViewMsg_DragTargetDragEnter(routing_id(), drop_data, client_pt,
screen_pt));
@@ -638,17 +638,17 @@ void RenderViewHost::InstallMissingPlugin() {
Send(new ViewMsg_InstallMissingPlugin(routing_id()));
}
-void RenderViewHost::FileSelected(const std::wstring& path) {
+void RenderViewHost::FileSelected(const FilePath& path) {
RendererSecurityPolicy::GetInstance()->GrantUploadFile(process()->pid(),
path);
- std::vector<std::wstring> files;
+ std::vector<FilePath> files;
files.push_back(path);
Send(new ViewMsg_RunFileChooserResponse(routing_id(), files));
}
void RenderViewHost::MultiFilesSelected(
- const std::vector<std::wstring>& files) {
- for (std::vector<std::wstring>::const_iterator file = files.begin();
+ const std::vector<FilePath>& files) {
+ for (std::vector<FilePath>::const_iterator file = files.begin();
file != files.end(); ++file) {
RendererSecurityPolicy::GetInstance()->GrantUploadFile(
process()->pid(), *file);
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 68fe3c2..1923aff 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -370,11 +370,11 @@ class RenderViewHost : public RenderWidgetHost {
// Notifies the RenderViewHost that a file has been chosen by the user from
// an Open File dialog for the form.
- void FileSelected(const std::wstring& path);
+ void FileSelected(const FilePath& path);
// Notifies the Listener that many files have been chosen by the user from
// an Open File dialog for the form.
- void MultiFilesSelected(const std::vector<std::wstring>& files);
+ void MultiFilesSelected(const std::vector<FilePath>& files);
// Notifies the RenderViewHost that its load state changed.
void LoadStateChanged(const GURL& url, net::LoadState load_state);
diff --git a/chrome/browser/renderer_host/renderer_security_policy.cc b/chrome/browser/renderer_host/renderer_security_policy.cc
index 753dff8..fd34ef6 100644
--- a/chrome/browser/renderer_host/renderer_security_policy.cc
+++ b/chrome/browser/renderer_host/renderer_security_policy.cc
@@ -4,6 +4,7 @@
#include "chrome/browser/renderer_host/renderer_security_policy.h"
+#include "base/file_path.h"
#include "base/logging.h"
#include "base/string_util.h"
#include "chrome/common/url_constants.h"
@@ -30,7 +31,7 @@ class RendererSecurityPolicy::SecurityState {
}
// Grant permission to upload the specified file to the web.
- void GrantUploadFile(const std::wstring& file) {
+ void GrantUploadFile(const FilePath& file) {
uploadable_files_.insert(file);
}
@@ -51,7 +52,7 @@ class RendererSecurityPolicy::SecurityState {
// Determine whether permission has been granted to upload file.
// Files that have not been granted default to being denied.
- bool CanUploadFile(const std::wstring& file) {
+ bool CanUploadFile(const FilePath& file) {
return uploadable_files_.find(file) != uploadable_files_.end();
}
@@ -59,7 +60,7 @@ class RendererSecurityPolicy::SecurityState {
private:
typedef std::map<std::string, bool> SchemeMap;
- typedef std::set<std::wstring> FileSet;
+ typedef std::set<FilePath> FileSet;
// Maps URL schemes to whether permission has been granted or revoked:
// |true| means the scheme has been granted.
@@ -181,7 +182,7 @@ void RendererSecurityPolicy::GrantRequestURL(int renderer_id, const GURL& url) {
}
void RendererSecurityPolicy::GrantUploadFile(int renderer_id,
- const std::wstring& file) {
+ const FilePath& file) {
AutoLock lock(lock_);
SecurityStateMap::iterator state = security_state_.find(renderer_id);
@@ -266,7 +267,7 @@ bool RendererSecurityPolicy::CanRequestURL(int renderer_id, const GURL& url) {
}
bool RendererSecurityPolicy::CanUploadFile(int renderer_id,
- const std::wstring& file) {
+ const FilePath& file) {
AutoLock lock(lock_);
SecurityStateMap::iterator state = security_state_.find(renderer_id);
diff --git a/chrome/browser/renderer_host/renderer_security_policy.h b/chrome/browser/renderer_host/renderer_security_policy.h
index a726d28..2064700 100644
--- a/chrome/browser/renderer_host/renderer_security_policy.h
+++ b/chrome/browser/renderer_host/renderer_security_policy.h
@@ -13,6 +13,7 @@
#include "base/lock.h"
#include "base/singleton.h"
+class FilePath;
class GURL;
// The RendererSecurityPolicy class is used to grant and revoke security
@@ -61,7 +62,7 @@ class RendererSecurityPolicy {
// Whenever the user picks a file from a <input type="file"> element, the
// browser should call this function to grant the renderer the capability to
// upload the file to the web.
- void GrantUploadFile(int renderer_id, const std::wstring& file);
+ void GrantUploadFile(int renderer_id, const FilePath& file);
// Whenever the browser processes commands the renderer to run web inspector,
// it should call this method to grant the renderer process the capability to
@@ -79,7 +80,7 @@ class RendererSecurityPolicy {
// Before servicing a renderer's request to upload a file to the web, the
// browser should call this method to determine whether the renderer has the
// capability to upload the requested file.
- bool CanUploadFile(int renderer_id, const std::wstring& file);
+ bool CanUploadFile(int renderer_id, const FilePath& file);
// Returns true of the specified renderer_id has been granted DOMUIBindings.
// The browser should check this property before assuming the renderer is
diff --git a/chrome/browser/renderer_host/renderer_security_policy_unittest.cc b/chrome/browser/renderer_host/renderer_security_policy_unittest.cc
index 42c90bd..464abc8 100644
--- a/chrome/browser/renderer_host/renderer_security_policy_unittest.cc
+++ b/chrome/browser/renderer_host/renderer_security_policy_unittest.cc
@@ -5,6 +5,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/file_path.h"
#include "chrome/browser/renderer_host/renderer_security_policy.h"
#include "chrome/common/url_constants.h"
#include "net/url_request/url_request.h"
@@ -189,16 +190,21 @@ TEST_F(RendererSecurityPolicyTest, CanUploadFiles) {
p->Add(kRendererID);
- EXPECT_FALSE(p->CanUploadFile(kRendererID, L"/etc/passwd"));
- p->GrantUploadFile(kRendererID, L"/etc/passwd");
- EXPECT_TRUE(p->CanUploadFile(kRendererID, L"/etc/passwd"));
- EXPECT_FALSE(p->CanUploadFile(kRendererID, L"/etc/shadow"));
+ EXPECT_FALSE(p->CanUploadFile(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
+ p->GrantUploadFile(kRendererID, FilePath(FILE_PATH_LITERAL("/etc/passwd")));
+ EXPECT_TRUE(p->CanUploadFile(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
+ EXPECT_FALSE(p->CanUploadFile(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/shadow"))));
p->Remove(kRendererID);
p->Add(kRendererID);
- EXPECT_FALSE(p->CanUploadFile(kRendererID, L"/etc/passwd"));
- EXPECT_FALSE(p->CanUploadFile(kRendererID, L"/etc/shadow"));
+ EXPECT_FALSE(p->CanUploadFile(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/passwd"))));
+ EXPECT_FALSE(p->CanUploadFile(kRendererID,
+ FilePath(FILE_PATH_LITERAL("/etc/shadow"))));
p->Remove(kRendererID);
}
@@ -237,7 +243,7 @@ TEST_F(RendererSecurityPolicyTest, RemoveRace) {
RendererSecurityPolicy* p = RendererSecurityPolicy::GetInstance();
GURL url("file:///etc/passwd");
- std::wstring file(L"/etc/passwd");
+ FilePath file(FILE_PATH_LITERAL("/etc/passwd"));
p->Add(kRendererID);
diff --git a/chrome/browser/renderer_host/resource_dispatcher_host.cc b/chrome/browser/renderer_host/resource_dispatcher_host.cc
index 8293a3e..b2b2c73 100644
--- a/chrome/browser/renderer_host/resource_dispatcher_host.cc
+++ b/chrome/browser/renderer_host/resource_dispatcher_host.cc
@@ -122,7 +122,8 @@ bool ShouldServiceRequest(ChildProcessInfo::ProcessType process_type,
std::vector<net::UploadData::Element>::const_iterator iter;
for (iter = uploads.begin(); iter != uploads.end(); ++iter) {
if (iter->type() == net::UploadData::TYPE_FILE &&
- !policy->CanUploadFile(process_id, iter->file_path())) {
+ !policy->CanUploadFile(process_id,
+ FilePath::FromWStringHack(iter->file_path()))) {
NOTREACHED() << "Denied unauthorized upload of " << iter->file_path();
return false;
}