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 21 matching lines...) Expand all Loading... |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 bool IsCheckoutURL(const std::string& url_spec) { | 35 bool IsCheckoutURL(const std::string& url_spec) { |
36 std::string checkout_url_prefix = | 36 std::string checkout_url_prefix = |
37 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 37 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
38 switches::kAppsCheckoutURL); | 38 switches::kAppsCheckoutURL); |
39 if (checkout_url_prefix.empty()) | 39 if (checkout_url_prefix.empty()) |
40 checkout_url_prefix = "https://checkout.google.com/"; | 40 checkout_url_prefix = "https://checkout.google.com/"; |
41 | 41 |
42 return StartsWithASCII(url_spec, checkout_url_prefix, false); | 42 return base::StartsWithASCII(url_spec, checkout_url_prefix, false); |
43 } | 43 } |
44 | 44 |
45 bool CheckAccessToAppDetails(WebFrame* frame, v8::Isolate* isolate) { | 45 bool CheckAccessToAppDetails(WebFrame* frame, v8::Isolate* isolate) { |
46 if (!IsCheckoutURL(frame->document().url().spec())) { | 46 if (!IsCheckoutURL(frame->document().url().spec())) { |
47 std::string error("Access denied for URL: "); | 47 std::string error("Access denied for URL: "); |
48 error += frame->document().url().spec(); | 48 error += frame->document().url().spec(); |
49 isolate->ThrowException(v8::String::NewFromUtf8(isolate, error.c_str())); | 49 isolate->ThrowException(v8::String::NewFromUtf8(isolate, error.c_str())); |
50 return false; | 50 return false; |
51 } | 51 } |
52 | 52 |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 v8::Context::Scope context_scope(context()->v8_context()); | 218 v8::Context::Scope context_scope(context()->v8_context()); |
219 v8::Local<v8::Value> argv[] = { | 219 v8::Local<v8::Value> argv[] = { |
220 v8::String::NewFromUtf8(isolate, state.c_str()), | 220 v8::String::NewFromUtf8(isolate, state.c_str()), |
221 v8::Integer::New(isolate, callback_id) | 221 v8::Integer::New(isolate, callback_id) |
222 }; | 222 }; |
223 context()->module_system()->CallModuleMethod( | 223 context()->module_system()->CallModuleMethod( |
224 "app", "onInstallStateResponse", arraysize(argv), argv); | 224 "app", "onInstallStateResponse", arraysize(argv), argv); |
225 } | 225 } |
226 | 226 |
227 } // namespace extensions | 227 } // namespace extensions |
OLD | NEW |