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

Side by Side Diff: chrome/common/extensions/manifest_handlers/automation.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 "chrome/common/extensions/manifest_handlers/automation.h" 5 #include "chrome/common/extensions/manifest_handlers/automation.h"
6 6
7 #include <utility>
8
7 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/common/extensions/api/manifest_types.h" 10 #include "chrome/common/extensions/api/manifest_types.h"
9 #include "chrome/grit/generated_resources.h" 11 #include "chrome/grit/generated_resources.h"
10 #include "extensions/common/error_utils.h" 12 #include "extensions/common/error_utils.h"
11 #include "extensions/common/extensions_client.h" 13 #include "extensions/common/extensions_client.h"
12 #include "extensions/common/manifest_constants.h" 14 #include "extensions/common/manifest_constants.h"
13 #include "extensions/common/permissions/api_permission_set.h" 15 #include "extensions/common/permissions/api_permission_set.h"
14 #include "extensions/common/permissions/manifest_permission.h" 16 #include "extensions/common/permissions/manifest_permission.h"
15 #include "extensions/common/permissions/permission_message_util.h" 17 #include "extensions/common/permissions/permission_message_util.h"
16 #include "extensions/common/permissions/permissions_data.h" 18 #include "extensions/common/permissions/permissions_data.h"
(...skipping 16 matching lines...) Expand all
33 } 35 }
34 36
35 namespace errors = manifest_errors; 37 namespace errors = manifest_errors;
36 namespace keys = extensions::manifest_keys; 38 namespace keys = extensions::manifest_keys;
37 using api::manifest_types::Automation; 39 using api::manifest_types::Automation;
38 40
39 class AutomationManifestPermission : public ManifestPermission { 41 class AutomationManifestPermission : public ManifestPermission {
40 public: 42 public:
41 explicit AutomationManifestPermission( 43 explicit AutomationManifestPermission(
42 scoped_ptr<const AutomationInfo> automation_info) 44 scoped_ptr<const AutomationInfo> automation_info)
43 : automation_info_(automation_info.Pass()) {} 45 : automation_info_(std::move(automation_info)) {}
44 46
45 // extensions::ManifestPermission overrides. 47 // extensions::ManifestPermission overrides.
46 std::string name() const override; 48 std::string name() const override;
47 49
48 std::string id() const override; 50 std::string id() const override;
49 51
50 PermissionIDSet GetPermissions() const override; 52 PermissionIDSet GetPermissions() const override;
51 53
52 bool FromValue(const base::Value* value) override; 54 bool FromValue(const base::Value* value) override;
53 55
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 103
102 bool AutomationManifestPermission::FromValue(const base::Value* value) { 104 bool AutomationManifestPermission::FromValue(const base::Value* value) {
103 base::string16 error; 105 base::string16 error;
104 automation_info_.reset(AutomationInfo::FromValue(*value, 106 automation_info_.reset(AutomationInfo::FromValue(*value,
105 NULL /* install_warnings */, 107 NULL /* install_warnings */,
106 &error).release()); 108 &error).release());
107 return error.empty(); 109 return error.empty();
108 } 110 }
109 111
110 scoped_ptr<base::Value> AutomationManifestPermission::ToValue() const { 112 scoped_ptr<base::Value> AutomationManifestPermission::ToValue() const {
111 return AutomationInfo::ToValue(*automation_info_).Pass(); 113 return AutomationInfo::ToValue(*automation_info_);
112 } 114 }
113 115
114 ManifestPermission* AutomationManifestPermission::Diff( 116 ManifestPermission* AutomationManifestPermission::Diff(
115 const ManifestPermission* rhs) const { 117 const ManifestPermission* rhs) const {
116 const AutomationManifestPermission* other = 118 const AutomationManifestPermission* other =
117 static_cast<const AutomationManifestPermission*>(rhs); 119 static_cast<const AutomationManifestPermission*>(rhs);
118 120
119 bool desktop = automation_info_->desktop && !other->automation_info_->desktop; 121 bool desktop = automation_info_->desktop && !other->automation_info_->desktop;
120 bool interact = 122 bool interact =
121 automation_info_->interact && !other->automation_info_->interact; 123 automation_info_->interact && !other->automation_info_->interact;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 if (specified_matches && matches.is_empty()) { 271 if (specified_matches && matches.is_empty()) {
270 install_warnings->push_back( 272 install_warnings->push_back(
271 InstallWarning(automation_errors::kErrorNoMatchesProvided)); 273 InstallWarning(automation_errors::kErrorNoMatchesProvided));
272 } 274 }
273 275
274 return make_scoped_ptr(new AutomationInfo(desktop, matches, interact)); 276 return make_scoped_ptr(new AutomationInfo(desktop, matches, interact));
275 } 277 }
276 278
277 // static 279 // static
278 scoped_ptr<base::Value> AutomationInfo::ToValue(const AutomationInfo& info) { 280 scoped_ptr<base::Value> AutomationInfo::ToValue(const AutomationInfo& info) {
279 return AsManifestType(info)->ToValue().Pass(); 281 return AsManifestType(info)->ToValue();
280 } 282 }
281 283
282 // static 284 // static
283 scoped_ptr<Automation> AutomationInfo::AsManifestType( 285 scoped_ptr<Automation> AutomationInfo::AsManifestType(
284 const AutomationInfo& info) { 286 const AutomationInfo& info) {
285 scoped_ptr<Automation> automation(new Automation); 287 scoped_ptr<Automation> automation(new Automation);
286 if (!info.desktop && !info.interact && info.matches.size() == 0) { 288 if (!info.desktop && !info.interact && info.matches.size() == 0) {
287 automation->as_boolean.reset(new bool(true)); 289 automation->as_boolean.reset(new bool(true));
288 return automation.Pass(); 290 return automation;
289 } 291 }
290 292
291 Automation::Object* as_object = new Automation::Object; 293 Automation::Object* as_object = new Automation::Object;
292 as_object->desktop.reset(new bool(info.desktop)); 294 as_object->desktop.reset(new bool(info.desktop));
293 as_object->interact.reset(new bool(info.interact)); 295 as_object->interact.reset(new bool(info.interact));
294 if (info.matches.size() > 0) { 296 if (info.matches.size() > 0) {
295 as_object->matches.reset(info.matches.ToStringVector().release()); 297 as_object->matches.reset(info.matches.ToStringVector().release());
296 } 298 }
297 automation->as_object.reset(as_object); 299 automation->as_object.reset(as_object);
298 return automation.Pass(); 300 return automation;
299 } 301 }
300 302
301 AutomationInfo::AutomationInfo() : desktop(false), interact(false) { 303 AutomationInfo::AutomationInfo() : desktop(false), interact(false) {
302 } 304 }
303 305
304 AutomationInfo::AutomationInfo(bool desktop, 306 AutomationInfo::AutomationInfo(bool desktop,
305 const URLPatternSet matches, 307 const URLPatternSet matches,
306 bool interact) 308 bool interact)
307 : desktop(desktop), matches(matches), interact(interact) { 309 : desktop(desktop), matches(matches), interact(interact) {
308 } 310 }
309 311
310 AutomationInfo::~AutomationInfo() { 312 AutomationInfo::~AutomationInfo() {
311 } 313 }
312 314
313 } // namespace extensions 315 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698