Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/extensions/app_bindings.h" | 5 #include "chrome/renderer/extensions/app_bindings.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string16.h" | 8 #include "base/strings/string16.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 console::Error(v8::Context::GetCalling(), | 112 console::Error(v8::Context::GetCalling(), |
| 113 "Could not find frame for specified object."); | 113 "Could not find frame for specified object."); |
| 114 return; | 114 return; |
| 115 } | 115 } |
| 116 | 116 |
| 117 args.GetReturnValue().Set(GetDetailsForFrameImpl(target_frame)); | 117 args.GetReturnValue().Set(GetDetailsForFrameImpl(target_frame)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 v8::Handle<v8::Value> AppBindings::GetDetailsForFrameImpl( | 120 v8::Handle<v8::Value> AppBindings::GetDetailsForFrameImpl( |
| 121 WebFrame* frame) { | 121 WebFrame* frame) { |
| 122 if (frame->document().securityOrigin().isUnique()) | |
| 123 return v8::Null(); | |
|
not at google - send to devlin
2013/07/15 22:09:12
i don't think it makes sense to check isUnique her
| |
| 124 | |
| 122 const Extension* extension = | 125 const Extension* extension = |
| 123 dispatcher_->extensions()->GetExtensionOrAppByURL( | 126 dispatcher_->extensions()->GetExtensionOrAppByURL( |
| 124 ExtensionURLInfo(frame->document().securityOrigin(), | 127 frame->document().url()); |
| 125 frame->document().url())); | 128 |
| 126 if (!extension) | 129 if (!extension) |
| 127 return v8::Null(); | 130 return v8::Null(); |
| 128 | 131 |
| 129 scoped_ptr<base::DictionaryValue> manifest_copy( | 132 scoped_ptr<base::DictionaryValue> manifest_copy( |
| 130 extension->manifest()->value()->DeepCopy()); | 133 extension->manifest()->value()->DeepCopy()); |
| 131 manifest_copy->SetString("id", extension->id()); | 134 manifest_copy->SetString("id", extension->id()); |
| 132 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 135 scoped_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| 133 return converter->ToV8Value(manifest_copy.get(), | 136 return converter->ToV8Value(manifest_copy.get(), |
| 134 frame->mainWorldScriptContext()); | 137 frame->mainWorldScriptContext()); |
| 135 } | 138 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 159 // To distinguish between ready_to_run and cannot_run states, we need the top | 162 // To distinguish between ready_to_run and cannot_run states, we need the top |
| 160 // level frame. | 163 // level frame. |
| 161 const WebFrame* parent_frame = context()->web_frame(); | 164 const WebFrame* parent_frame = context()->web_frame(); |
| 162 while (parent_frame->parent()) | 165 while (parent_frame->parent()) |
| 163 parent_frame = parent_frame->parent(); | 166 parent_frame = parent_frame->parent(); |
| 164 | 167 |
| 165 const ExtensionSet* extensions = dispatcher_->extensions(); | 168 const ExtensionSet* extensions = dispatcher_->extensions(); |
| 166 | 169 |
| 167 // The app associated with the top level frame. | 170 // The app associated with the top level frame. |
| 168 const Extension* parent_app = extensions->GetHostedAppByURL( | 171 const Extension* parent_app = extensions->GetHostedAppByURL( |
| 169 ExtensionURLInfo(parent_frame->document().url())); | 172 parent_frame->document().url()); |
| 170 | 173 |
| 171 // The app associated with this frame. | 174 // The app associated with this frame. |
| 172 const Extension* this_app = extensions->GetHostedAppByURL(ExtensionURLInfo( | 175 const Extension* this_app = extensions->GetHostedAppByURL( |
| 173 context()->web_frame()->document().url())); | 176 context()->web_frame()->document().url()); |
| 174 | 177 |
| 175 if (!this_app || !parent_app) { | 178 if (!this_app || !parent_app) { |
| 176 args.GetReturnValue().Set( | 179 args.GetReturnValue().Set( |
| 177 v8::String::New(extension_misc::kAppStateCannotRun)); | 180 v8::String::New(extension_misc::kAppStateCannotRun)); |
| 178 return; | 181 return; |
| 179 } | 182 } |
| 180 | 183 |
| 181 const char* state = NULL; | 184 const char* state = NULL; |
| 182 if (dispatcher_->IsExtensionActive(parent_app->id())) { | 185 if (dispatcher_->IsExtensionActive(parent_app->id())) { |
| 183 if (parent_app == this_app) | 186 if (parent_app == this_app) |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 208 v8::Context::Scope context_scope(context()->v8_context()); | 211 v8::Context::Scope context_scope(context()->v8_context()); |
| 209 v8::Handle<v8::Value> argv[] = { | 212 v8::Handle<v8::Value> argv[] = { |
| 210 v8::String::New(state.c_str()), | 213 v8::String::New(state.c_str()), |
| 211 v8::Integer::New(callback_id) | 214 v8::Integer::New(callback_id) |
| 212 }; | 215 }; |
| 213 context()->module_system()->CallModuleMethod( | 216 context()->module_system()->CallModuleMethod( |
| 214 "app", "onInstallStateResponse", arraysize(argv), argv); | 217 "app", "onInstallStateResponse", arraysize(argv), argv); |
| 215 } | 218 } |
| 216 | 219 |
| 217 } // namespace extensions | 220 } // namespace extensions |
| OLD | NEW |