| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #define NO_NSPR_10_SUPPORT | |
| 6 #include "chrome_frame/np_utils.h" | |
| 7 | |
| 8 #include "chrome_frame/np_browser_functions.h" | |
| 9 | |
| 10 namespace np_utils { | |
| 11 | |
| 12 std::string GetLocation(NPP instance, NPObject* window) { | |
| 13 if (!window) { | |
| 14 // Can fail if the browser is closing (seen in Opera). | |
| 15 return ""; | |
| 16 } | |
| 17 | |
| 18 std::string result; | |
| 19 ScopedNpVariant href; | |
| 20 ScopedNpVariant location; | |
| 21 | |
| 22 bool ok = npapi::GetProperty(instance, | |
| 23 window, | |
| 24 npapi::GetStringIdentifier("location"), | |
| 25 &location); | |
| 26 DCHECK(ok); | |
| 27 DCHECK(location.type == NPVariantType_Object); | |
| 28 | |
| 29 if (ok) { | |
| 30 ok = npapi::GetProperty(instance, | |
| 31 location.value.objectValue, | |
| 32 npapi::GetStringIdentifier("href"), | |
| 33 &href); | |
| 34 DCHECK(ok); | |
| 35 DCHECK(href.type == NPVariantType_String); | |
| 36 if (ok) { | |
| 37 result.assign(href.value.stringValue.UTF8Characters, | |
| 38 href.value.stringValue.UTF8Length); | |
| 39 } | |
| 40 } | |
| 41 | |
| 42 return result; | |
| 43 } | |
| 44 | |
| 45 } // namespace np_utils | |
| OLD | NEW |