Index: content/renderer/web_ui_mojo_context_state.cc |
diff --git a/content/renderer/web_ui_mojo_context_state.cc b/content/renderer/web_ui_mojo_context_state.cc |
index b229cc983ad387d719b6c2f36d4044278ab80294..cb75e907e51eb1909b4554d47751f20fdf11a41e 100644 |
--- a/content/renderer/web_ui_mojo_context_state.cc |
+++ b/content/renderer/web_ui_mojo_context_state.cc |
@@ -17,7 +17,6 @@ |
#include "third_party/WebKit/public/platform/WebURLResponse.h" |
#include "third_party/WebKit/public/web/WebFrame.h" |
#include "third_party/WebKit/public/web/WebScriptSource.h" |
-#include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
using v8::Context; |
using v8::HandleScope; |
@@ -29,6 +28,10 @@ |
namespace content { |
namespace { |
+ |
+// All modules have this prefixed to them when downloading. |
+// TODO(sky): move this into some common place. |
+const char kModulePrefix[] = "chrome://mojo/"; |
void RunMain(base::WeakPtr<gin::Runner> runner, |
v8::Local<v8::Value> module) { |
@@ -45,8 +48,7 @@ |
WebUIMojoContextState::WebUIMojoContextState(blink::WebFrame* frame, |
v8::Local<v8::Context> context) |
: frame_(frame), |
- module_added_(false), |
- module_prefix_(frame_->securityOrigin().toString().utf8() + "/") { |
+ module_added_(false) { |
gin::PerContextData* context_data = gin::PerContextData::From(context); |
gin::ContextHolder* context_holder = context_data->context_holder(); |
runner_.reset(new WebUIRunner(frame_, context_holder)); |
@@ -87,7 +89,7 @@ |
} |
void WebUIMojoContextState::FetchModule(const std::string& id) { |
- const GURL url(module_prefix_ + id); |
+ const GURL url(kModulePrefix + id); |
// TODO(sky): better error checks here? |
DCHECK(url.is_valid() && !url.is_empty()); |
DCHECK(fetched_modules_.find(id) == fetched_modules_.end()); |
@@ -107,10 +109,10 @@ |
ResourceFetcher* fetcher, |
const blink::WebURLResponse& response, |
const std::string& data) { |
- DCHECK_EQ(module_prefix_, |
- response.url().string().utf8().substr(0, module_prefix_.size())); |
+ DCHECK_EQ(kModulePrefix, |
+ response.url().string().utf8().substr(0, arraysize(kModulePrefix) - 1)); |
const std::string module = |
- response.url().string().utf8().substr(module_prefix_.size()); |
+ response.url().string().utf8().substr(arraysize(kModulePrefix) - 1); |
// We can't delete fetch right now as the arguments to this function come from |
// it and are used below. Instead use a scope_ptr to cleanup. |
scoped_ptr<ResourceFetcher> deleter(fetcher); |