| 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 cb75e907e51eb1909b4554d47751f20fdf11a41e..b229cc983ad387d719b6c2f36d4044278ab80294 100644
|
| --- a/content/renderer/web_ui_mojo_context_state.cc
|
| +++ b/content/renderer/web_ui_mojo_context_state.cc
|
| @@ -17,6 +17,7 @@
|
| #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,10 +30,6 @@ 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) {
|
| v8::Isolate* isolate = runner->GetContextHolder()->isolate();
|
| @@ -48,7 +45,8 @@ void RunMain(base::WeakPtr<gin::Runner> runner,
|
| WebUIMojoContextState::WebUIMojoContextState(blink::WebFrame* frame,
|
| v8::Local<v8::Context> context)
|
| : frame_(frame),
|
| - module_added_(false) {
|
| + module_added_(false),
|
| + module_prefix_(frame_->securityOrigin().toString().utf8() + "/") {
|
| gin::PerContextData* context_data = gin::PerContextData::From(context);
|
| gin::ContextHolder* context_holder = context_data->context_holder();
|
| runner_.reset(new WebUIRunner(frame_, context_holder));
|
| @@ -89,7 +87,7 @@ void WebUIMojoContextState::FetchModules(const std::vector<std::string>& ids) {
|
| }
|
|
|
| void WebUIMojoContextState::FetchModule(const std::string& id) {
|
| - const GURL url(kModulePrefix + id);
|
| + const GURL url(module_prefix_ + id);
|
| // TODO(sky): better error checks here?
|
| DCHECK(url.is_valid() && !url.is_empty());
|
| DCHECK(fetched_modules_.find(id) == fetched_modules_.end());
|
| @@ -109,10 +107,10 @@ void WebUIMojoContextState::OnFetchModuleComplete(
|
| ResourceFetcher* fetcher,
|
| const blink::WebURLResponse& response,
|
| const std::string& data) {
|
| - DCHECK_EQ(kModulePrefix,
|
| - response.url().string().utf8().substr(0, arraysize(kModulePrefix) - 1));
|
| + DCHECK_EQ(module_prefix_,
|
| + response.url().string().utf8().substr(0, module_prefix_.size()));
|
| const std::string module =
|
| - response.url().string().utf8().substr(arraysize(kModulePrefix) - 1);
|
| + response.url().string().utf8().substr(module_prefix_.size());
|
| // 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);
|
|
|