Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(622)

Side by Side Diff: extensions/renderer/resource_bundle_source_map.cc

Issue 1115563002: extensions/renderer: Use v8::Local instead of v8::Handle. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/resource_bundle_source_map.h ('k') | extensions/renderer/safe_builtins.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/renderer/resource_bundle_source_map.h" 5 #include "extensions/renderer/resource_bundle_source_map.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "ui/base/resource/resource_bundle.h" 8 #include "ui/base/resource/resource_bundle.h"
9 9
10 namespace extensions { 10 namespace extensions {
11 11
12 ResourceBundleSourceMap::ResourceBundleSourceMap( 12 ResourceBundleSourceMap::ResourceBundleSourceMap(
13 const ui::ResourceBundle* resource_bundle) 13 const ui::ResourceBundle* resource_bundle)
14 : resource_bundle_(resource_bundle) { 14 : resource_bundle_(resource_bundle) {
15 } 15 }
16 16
17 ResourceBundleSourceMap::~ResourceBundleSourceMap() { 17 ResourceBundleSourceMap::~ResourceBundleSourceMap() {
18 } 18 }
19 19
20 void ResourceBundleSourceMap::RegisterSource(const std::string& name, 20 void ResourceBundleSourceMap::RegisterSource(const std::string& name,
21 int resource_id) { 21 int resource_id) {
22 resource_id_map_[name] = resource_id; 22 resource_id_map_[name] = resource_id;
23 } 23 }
24 24
25 v8::Handle<v8::Value> ResourceBundleSourceMap::GetSource( 25 v8::Local<v8::Value> ResourceBundleSourceMap::GetSource(
26 v8::Isolate* isolate, 26 v8::Isolate* isolate,
27 const std::string& name) { 27 const std::string& name) {
28 if (!Contains(name)) { 28 if (!Contains(name)) {
29 NOTREACHED() << "No module is registered with name \"" << name << "\""; 29 NOTREACHED() << "No module is registered with name \"" << name << "\"";
30 return v8::Undefined(isolate); 30 return v8::Undefined(isolate);
31 } 31 }
32 base::StringPiece resource = 32 base::StringPiece resource =
33 resource_bundle_->GetRawDataResource(resource_id_map_[name]); 33 resource_bundle_->GetRawDataResource(resource_id_map_[name]);
34 if (resource.empty()) { 34 if (resource.empty()) {
35 NOTREACHED() 35 NOTREACHED()
36 << "Module resource registered as \"" << name << "\" not found"; 36 << "Module resource registered as \"" << name << "\" not found";
37 return v8::Undefined(isolate); 37 return v8::Undefined(isolate);
38 } 38 }
39 return ConvertString(isolate, resource); 39 return ConvertString(isolate, resource);
40 } 40 }
41 41
42 bool ResourceBundleSourceMap::Contains(const std::string& name) { 42 bool ResourceBundleSourceMap::Contains(const std::string& name) {
43 return !!resource_id_map_.count(name); 43 return !!resource_id_map_.count(name);
44 } 44 }
45 45
46 v8::Handle<v8::String> ResourceBundleSourceMap::ConvertString( 46 v8::Local<v8::String> ResourceBundleSourceMap::ConvertString(
47 v8::Isolate* isolate, 47 v8::Isolate* isolate,
48 const base::StringPiece& string) { 48 const base::StringPiece& string) {
49 // v8 takes ownership of the StaticV8ExternalOneByteStringResource (see 49 // v8 takes ownership of the StaticV8ExternalOneByteStringResource (see
50 // v8::String::NewExternal()). 50 // v8::String::NewExternal()).
51 return v8::String::NewExternal( 51 return v8::String::NewExternal(
52 isolate, new StaticV8ExternalOneByteStringResource(string)); 52 isolate, new StaticV8ExternalOneByteStringResource(string));
53 } 53 }
54 54
55 } // namespace extensions 55 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/renderer/resource_bundle_source_map.h ('k') | extensions/renderer/safe_builtins.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698