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

Side by Side Diff: extensions/browser/api/runtime/runtime_api.cc

Issue 2025103003: ExtensionFunction: don't pass ownership of base::Value by raw pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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/browser/api/runtime/runtime_api.h" 5 #include "extensions/browser/api/runtime/runtime_api.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/ptr_util.h"
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "base/version.h" 15 #include "base/version.h"
15 #include "content/public/browser/browser_context.h" 16 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/child_process_security_policy.h" 17 #include "content/public/browser/child_process_security_policy.h"
17 #include "content/public/browser/notification_service.h" 18 #include "content/public/browser/notification_service.h"
18 #include "content/public/browser/render_frame_host.h" 19 #include "content/public/browser/render_frame_host.h"
19 #include "content/public/browser/render_process_host.h" 20 #include "content/public/browser/render_process_host.h"
20 #include "extensions/browser/api/runtime/runtime_api_delegate.h" 21 #include "extensions/browser/api/runtime/runtime_api_delegate.h"
21 #include "extensions/browser/event_router.h" 22 #include "extensions/browser/event_router.h"
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 base::Bind(&RuntimeRequestUpdateCheckFunction::CheckComplete, 525 base::Bind(&RuntimeRequestUpdateCheckFunction::CheckComplete,
525 this))) { 526 this))) {
526 return RespondNow(Error(kUpdatesDisabledError)); 527 return RespondNow(Error(kUpdatesDisabledError));
527 } 528 }
528 return RespondLater(); 529 return RespondLater();
529 } 530 }
530 531
531 void RuntimeRequestUpdateCheckFunction::CheckComplete( 532 void RuntimeRequestUpdateCheckFunction::CheckComplete(
532 const RuntimeAPIDelegate::UpdateCheckResult& result) { 533 const RuntimeAPIDelegate::UpdateCheckResult& result) {
533 if (result.success) { 534 if (result.success) {
534 base::DictionaryValue* details = new base::DictionaryValue; 535 std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue);
535 details->SetString("version", result.version); 536 details->SetString("version", result.version);
536 Respond(TwoArguments(new base::StringValue(result.response), details)); 537 Respond(TwoArguments(base::MakeUnique<base::StringValue>(result.response),
538 std::move(details)));
537 } else { 539 } else {
538 // HMM(kalman): Why does !success not imply Error()? 540 // HMM(kalman): Why does !success not imply Error()?
539 Respond(OneArgument(new base::StringValue(result.response))); 541 Respond(OneArgument(base::MakeUnique<base::StringValue>(result.response)));
540 } 542 }
541 } 543 }
542 544
543 ExtensionFunction::ResponseAction RuntimeRestartFunction::Run() { 545 ExtensionFunction::ResponseAction RuntimeRestartFunction::Run() {
544 std::string message; 546 std::string message;
545 bool result = 547 bool result =
546 RuntimeAPI::GetFactoryInstance()->Get(browser_context())->RestartDevice( 548 RuntimeAPI::GetFactoryInstance()->Get(browser_context())->RestartDevice(
547 &message); 549 &message);
548 if (!result) { 550 if (!result) {
549 return RespondNow(Error(message)); 551 return RespondNow(Error(message));
(...skipping 20 matching lines...) Expand all
570 572
571 std::string relative_path = kPackageDirectoryPath; 573 std::string relative_path = kPackageDirectoryPath;
572 base::FilePath path = extension_->path(); 574 base::FilePath path = extension_->path();
573 std::string filesystem_id = isolated_context->RegisterFileSystemForPath( 575 std::string filesystem_id = isolated_context->RegisterFileSystemForPath(
574 storage::kFileSystemTypeNativeLocal, std::string(), path, &relative_path); 576 storage::kFileSystemTypeNativeLocal, std::string(), path, &relative_path);
575 577
576 int renderer_id = render_frame_host()->GetProcess()->GetID(); 578 int renderer_id = render_frame_host()->GetProcess()->GetID();
577 content::ChildProcessSecurityPolicy* policy = 579 content::ChildProcessSecurityPolicy* policy =
578 content::ChildProcessSecurityPolicy::GetInstance(); 580 content::ChildProcessSecurityPolicy::GetInstance();
579 policy->GrantReadFileSystem(renderer_id, filesystem_id); 581 policy->GrantReadFileSystem(renderer_id, filesystem_id);
580 base::DictionaryValue* dict = new base::DictionaryValue(); 582 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue());
581 dict->SetString("fileSystemId", filesystem_id); 583 dict->SetString("fileSystemId", filesystem_id);
582 dict->SetString("baseName", relative_path); 584 dict->SetString("baseName", relative_path);
583 return RespondNow(OneArgument(dict)); 585 return RespondNow(OneArgument(std::move(dict)));
584 } 586 }
585 587
586 } // namespace extensions 588 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/management/management_api.cc ('k') | extensions/browser/api/storage/storage_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698