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/macros.h" | 8 #include "base/macros.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 void AppBindings::GetDetails( | 67 void AppBindings::GetDetails( |
68 const v8::FunctionCallbackInfo<v8::Value>& args) { | 68 const v8::FunctionCallbackInfo<v8::Value>& args) { |
69 blink::WebLocalFrame* web_frame = context()->web_frame(); | 69 blink::WebLocalFrame* web_frame = context()->web_frame(); |
70 CHECK(web_frame); | 70 CHECK(web_frame); |
71 args.GetReturnValue().Set(GetDetailsImpl(web_frame)); | 71 args.GetReturnValue().Set(GetDetailsImpl(web_frame)); |
72 } | 72 } |
73 | 73 |
74 v8::Local<v8::Value> AppBindings::GetDetailsImpl(blink::WebLocalFrame* frame) { | 74 v8::Local<v8::Value> AppBindings::GetDetailsImpl(blink::WebLocalFrame* frame) { |
75 v8::Isolate* isolate = frame->mainWorldScriptContext()->GetIsolate(); | 75 v8::Isolate* isolate = frame->mainWorldScriptContext()->GetIsolate(); |
76 if (frame->document().securityOrigin().isUnique()) | 76 if (frame->document().getSecurityOrigin().isUnique()) |
77 return v8::Null(isolate); | 77 return v8::Null(isolate); |
78 | 78 |
79 const Extension* extension = | 79 const Extension* extension = |
80 RendererExtensionRegistry::Get()->GetExtensionOrAppByURL( | 80 RendererExtensionRegistry::Get()->GetExtensionOrAppByURL( |
81 frame->document().url()); | 81 frame->document().url()); |
82 | 82 |
83 if (!extension) | 83 if (!extension) |
84 return v8::Null(isolate); | 84 return v8::Null(isolate); |
85 | 85 |
86 scoped_ptr<base::DictionaryValue> manifest_copy( | 86 scoped_ptr<base::DictionaryValue> manifest_copy( |
(...skipping 23 matching lines...) Expand all Loading... |
110 Send(new ExtensionHostMsg_GetAppInstallState( | 110 Send(new ExtensionHostMsg_GetAppInstallState( |
111 render_frame->GetRoutingID(), context()->web_frame()->document().url(), | 111 render_frame->GetRoutingID(), context()->web_frame()->document().url(), |
112 GetRoutingID(), callback_id)); | 112 GetRoutingID(), callback_id)); |
113 } | 113 } |
114 | 114 |
115 void AppBindings::GetRunningState( | 115 void AppBindings::GetRunningState( |
116 const v8::FunctionCallbackInfo<v8::Value>& args) { | 116 const v8::FunctionCallbackInfo<v8::Value>& args) { |
117 // To distinguish between ready_to_run and cannot_run states, we need the app | 117 // To distinguish between ready_to_run and cannot_run states, we need the app |
118 // from the top frame. | 118 // from the top frame. |
119 blink::WebSecurityOrigin top_frame_security_origin = | 119 blink::WebSecurityOrigin top_frame_security_origin = |
120 context()->web_frame()->top()->securityOrigin(); | 120 context()->web_frame()->top()->getSecurityOrigin(); |
121 const RendererExtensionRegistry* extensions = | 121 const RendererExtensionRegistry* extensions = |
122 RendererExtensionRegistry::Get(); | 122 RendererExtensionRegistry::Get(); |
123 | 123 |
124 // The app associated with the top level frame. | 124 // The app associated with the top level frame. |
125 const Extension* top_app = extensions->GetHostedAppByURL( | 125 const Extension* top_app = extensions->GetHostedAppByURL( |
126 GURL(top_frame_security_origin.toString().utf8())); | 126 GURL(top_frame_security_origin.toString().utf8())); |
127 | 127 |
128 // The app associated with this frame. | 128 // The app associated with this frame. |
129 const Extension* this_app = extensions->GetHostedAppByURL( | 129 const Extension* this_app = extensions->GetHostedAppByURL( |
130 context()->web_frame()->document().url()); | 130 context()->web_frame()->document().url()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 v8::Context::Scope context_scope(context()->v8_context()); | 167 v8::Context::Scope context_scope(context()->v8_context()); |
168 v8::Local<v8::Value> argv[] = { | 168 v8::Local<v8::Value> argv[] = { |
169 v8::String::NewFromUtf8(isolate, state.c_str()), | 169 v8::String::NewFromUtf8(isolate, state.c_str()), |
170 v8::Integer::New(isolate, callback_id) | 170 v8::Integer::New(isolate, callback_id) |
171 }; | 171 }; |
172 context()->module_system()->CallModuleMethod( | 172 context()->module_system()->CallModuleMethod( |
173 "app", "onInstallStateResponse", arraysize(argv), argv); | 173 "app", "onInstallStateResponse", arraysize(argv), argv); |
174 } | 174 } |
175 | 175 |
176 } // namespace extensions | 176 } // namespace extensions |
OLD | NEW |