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

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

Issue 2038613003: Revert of 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"
13 #include "base/metrics/histogram.h" 12 #include "base/metrics/histogram.h"
14 #include "base/values.h" 13 #include "base/values.h"
15 #include "base/version.h" 14 #include "base/version.h"
16 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
17 #include "content/public/browser/child_process_security_policy.h" 16 #include "content/public/browser/child_process_security_policy.h"
18 #include "content/public/browser/notification_service.h" 17 #include "content/public/browser/notification_service.h"
19 #include "content/public/browser/render_frame_host.h" 18 #include "content/public/browser/render_frame_host.h"
20 #include "content/public/browser/render_process_host.h" 19 #include "content/public/browser/render_process_host.h"
21 #include "extensions/browser/api/runtime/runtime_api_delegate.h" 20 #include "extensions/browser/api/runtime/runtime_api_delegate.h"
22 #include "extensions/browser/event_router.h" 21 #include "extensions/browser/event_router.h"
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 base::Bind(&RuntimeRequestUpdateCheckFunction::CheckComplete, 524 base::Bind(&RuntimeRequestUpdateCheckFunction::CheckComplete,
526 this))) { 525 this))) {
527 return RespondNow(Error(kUpdatesDisabledError)); 526 return RespondNow(Error(kUpdatesDisabledError));
528 } 527 }
529 return RespondLater(); 528 return RespondLater();
530 } 529 }
531 530
532 void RuntimeRequestUpdateCheckFunction::CheckComplete( 531 void RuntimeRequestUpdateCheckFunction::CheckComplete(
533 const RuntimeAPIDelegate::UpdateCheckResult& result) { 532 const RuntimeAPIDelegate::UpdateCheckResult& result) {
534 if (result.success) { 533 if (result.success) {
535 std::unique_ptr<base::DictionaryValue> details(new base::DictionaryValue); 534 base::DictionaryValue* details = new base::DictionaryValue;
536 details->SetString("version", result.version); 535 details->SetString("version", result.version);
537 Respond(TwoArguments(base::MakeUnique<base::StringValue>(result.response), 536 Respond(TwoArguments(new base::StringValue(result.response), details));
538 std::move(details)));
539 } else { 537 } else {
540 // HMM(kalman): Why does !success not imply Error()? 538 // HMM(kalman): Why does !success not imply Error()?
541 Respond(OneArgument(base::MakeUnique<base::StringValue>(result.response))); 539 Respond(OneArgument(new base::StringValue(result.response)));
542 } 540 }
543 } 541 }
544 542
545 ExtensionFunction::ResponseAction RuntimeRestartFunction::Run() { 543 ExtensionFunction::ResponseAction RuntimeRestartFunction::Run() {
546 std::string message; 544 std::string message;
547 bool result = 545 bool result =
548 RuntimeAPI::GetFactoryInstance()->Get(browser_context())->RestartDevice( 546 RuntimeAPI::GetFactoryInstance()->Get(browser_context())->RestartDevice(
549 &message); 547 &message);
550 if (!result) { 548 if (!result) {
551 return RespondNow(Error(message)); 549 return RespondNow(Error(message));
(...skipping 20 matching lines...) Expand all
572 570
573 std::string relative_path = kPackageDirectoryPath; 571 std::string relative_path = kPackageDirectoryPath;
574 base::FilePath path = extension_->path(); 572 base::FilePath path = extension_->path();
575 std::string filesystem_id = isolated_context->RegisterFileSystemForPath( 573 std::string filesystem_id = isolated_context->RegisterFileSystemForPath(
576 storage::kFileSystemTypeNativeLocal, std::string(), path, &relative_path); 574 storage::kFileSystemTypeNativeLocal, std::string(), path, &relative_path);
577 575
578 int renderer_id = render_frame_host()->GetProcess()->GetID(); 576 int renderer_id = render_frame_host()->GetProcess()->GetID();
579 content::ChildProcessSecurityPolicy* policy = 577 content::ChildProcessSecurityPolicy* policy =
580 content::ChildProcessSecurityPolicy::GetInstance(); 578 content::ChildProcessSecurityPolicy::GetInstance();
581 policy->GrantReadFileSystem(renderer_id, filesystem_id); 579 policy->GrantReadFileSystem(renderer_id, filesystem_id);
582 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 580 base::DictionaryValue* dict = new base::DictionaryValue();
583 dict->SetString("fileSystemId", filesystem_id); 581 dict->SetString("fileSystemId", filesystem_id);
584 dict->SetString("baseName", relative_path); 582 dict->SetString("baseName", relative_path);
585 return RespondNow(OneArgument(std::move(dict))); 583 return RespondNow(OneArgument(dict));
586 } 584 }
587 585
588 } // namespace extensions 586 } // 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