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

Side by Side Diff: chrome/renderer/extensions/app_bindings_core.cc

Issue 2931393003: [Content] Update V8ValueConverter::create to return a std::unique_ptr (Closed)
Patch Set: rebase Created 3 years, 6 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 | « no previous file | chrome/renderer/extensions/cast_streaming_native_handler.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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_core.h" 5 #include "chrome/renderer/extensions/app_bindings_core.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/common/extensions/extension_constants.h" 10 #include "chrome/common/extensions/extension_constants.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 const Extension* extension = 47 const Extension* extension =
48 RendererExtensionRegistry::Get()->GetExtensionOrAppByURL( 48 RendererExtensionRegistry::Get()->GetExtensionOrAppByURL(
49 web_frame->GetDocument().Url()); 49 web_frame->GetDocument().Url());
50 50
51 if (!extension) 51 if (!extension)
52 return v8::Null(isolate); 52 return v8::Null(isolate);
53 53
54 std::unique_ptr<base::DictionaryValue> manifest_copy = 54 std::unique_ptr<base::DictionaryValue> manifest_copy =
55 extension->manifest()->value()->CreateDeepCopy(); 55 extension->manifest()->value()->CreateDeepCopy();
56 manifest_copy->SetString("id", extension->id()); 56 manifest_copy->SetString("id", extension->id());
57 std::unique_ptr<content::V8ValueConverter> converter( 57 return content::V8ValueConverter::Create()->ToV8Value(
58 content::V8ValueConverter::create()); 58 manifest_copy.get(), script_context->v8_context());
59 return converter->ToV8Value(manifest_copy.get(),
60 script_context->v8_context());
61 } 59 }
62 60
63 void AppBindingsCore::GetInstallState(ScriptContext* script_context, 61 void AppBindingsCore::GetInstallState(ScriptContext* script_context,
64 GetInstallStateCallback callback) { 62 GetInstallStateCallback callback) {
65 content::RenderFrame* render_frame = script_context->GetRenderFrame(); 63 content::RenderFrame* render_frame = script_context->GetRenderFrame();
66 CHECK(render_frame); 64 CHECK(render_frame);
67 65
68 int callback_id = next_callback_id_++; 66 int callback_id = next_callback_id_++;
69 callbacks_[callback_id] = std::move(callback); 67 callbacks_[callback_id] = std::move(callback);
70 68
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 void AppBindingsCore::OnAppInstallStateResponse(const std::string& state, 118 void AppBindingsCore::OnAppInstallStateResponse(const std::string& state,
121 int callback_id) { 119 int callback_id) {
122 auto iter = callbacks_.find(callback_id); 120 auto iter = callbacks_.find(callback_id);
123 DCHECK(iter != callbacks_.end()); 121 DCHECK(iter != callbacks_.end());
124 GetInstallStateCallback callback = std::move(iter->second); 122 GetInstallStateCallback callback = std::move(iter->second);
125 callbacks_.erase(iter); 123 callbacks_.erase(iter);
126 std::move(callback).Run(state); 124 std::move(callback).Run(state);
127 } 125 }
128 126
129 } // namespace extensions 127 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/extensions/cast_streaming_native_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698