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

Side by Side Diff: chrome/browser/extensions/api/developer_private/developer_private_mangle.cc

Issue 1811413002: [Extensions] Update generated code to support move operations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compile fix Created 4 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/browser/extensions/api/developer_private/developer_private_mang le.h" 5 #include "chrome/browser/extensions/api/developer_private/developer_private_mang le.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/common/extensions/api/developer_private.h" 9 #include "chrome/common/extensions/api/developer_private.h"
10 #include "extensions/browser/extension_error.h" 10 #include "extensions/browser/extension_error.h"
11 #include "extensions/common/constants.h" 11 #include "extensions/common/constants.h"
12 12
13 namespace extensions { 13 namespace extensions {
14 namespace developer_private_mangle { 14 namespace developer_private_mangle {
15 15
16 linked_ptr<api::developer_private::ItemInfo> MangleExtensionInfo( 16 api::developer_private::ItemInfo MangleExtensionInfo(
17 const api::developer_private::ExtensionInfo& info) { 17 const api::developer_private::ExtensionInfo& info) {
18 linked_ptr<api::developer_private::ItemInfo> result( 18 api::developer_private::ItemInfo result;
19 new api::developer_private::ItemInfo()); 19 result.id = info.id;
20 result->id = info.id; 20 result.name = info.name;
21 result->name = info.name; 21 result.version = info.version;
22 result->version = info.version; 22 result.description = info.description;
23 result->description = info.description; 23 result.may_disable = info.user_may_modify;
24 result->may_disable = info.user_may_modify; 24 result.enabled =
25 result->enabled =
26 info.state == api::developer_private::EXTENSION_STATE_ENABLED; 25 info.state == api::developer_private::EXTENSION_STATE_ENABLED;
27 switch (info.type) { 26 switch (info.type) {
28 case api::developer_private::EXTENSION_TYPE_HOSTED_APP: 27 case api::developer_private::EXTENSION_TYPE_HOSTED_APP:
29 result->type = api::developer_private::ITEM_TYPE_HOSTED_APP; 28 result.type = api::developer_private::ITEM_TYPE_HOSTED_APP;
30 result->is_app = true; 29 result.is_app = true;
31 break; 30 break;
32 case api::developer_private::EXTENSION_TYPE_PLATFORM_APP: 31 case api::developer_private::EXTENSION_TYPE_PLATFORM_APP:
33 result->type = api::developer_private::ITEM_TYPE_PACKAGED_APP; 32 result.type = api::developer_private::ITEM_TYPE_PACKAGED_APP;
34 result->is_app = true; 33 result.is_app = true;
35 break; 34 break;
36 case api::developer_private::EXTENSION_TYPE_LEGACY_PACKAGED_APP: 35 case api::developer_private::EXTENSION_TYPE_LEGACY_PACKAGED_APP:
37 result->type = api::developer_private::ITEM_TYPE_LEGACY_PACKAGED_APP; 36 result.type = api::developer_private::ITEM_TYPE_LEGACY_PACKAGED_APP;
38 result->is_app = true; 37 result.is_app = true;
39 break; 38 break;
40 case api::developer_private::EXTENSION_TYPE_EXTENSION: 39 case api::developer_private::EXTENSION_TYPE_EXTENSION:
41 result->type = api::developer_private::ITEM_TYPE_EXTENSION; 40 result.type = api::developer_private::ITEM_TYPE_EXTENSION;
42 result->is_app = false; 41 result.is_app = false;
43 break; 42 break;
44 case api::developer_private::EXTENSION_TYPE_THEME: 43 case api::developer_private::EXTENSION_TYPE_THEME:
45 result->type = api::developer_private::ITEM_TYPE_THEME; 44 result.type = api::developer_private::ITEM_TYPE_THEME;
46 result->is_app = false; 45 result.is_app = false;
47 break; 46 break;
48 case api::developer_private::EXTENSION_TYPE_SHARED_MODULE: 47 case api::developer_private::EXTENSION_TYPE_SHARED_MODULE:
49 // Old api doesn't account for this. 48 // Old api doesn't account for this.
50 break; 49 break;
51 default: 50 default:
52 NOTREACHED(); 51 NOTREACHED();
53 } 52 }
54 result->allow_file_access = info.file_access.is_active; 53 result.allow_file_access = info.file_access.is_active;
55 result->wants_file_access = info.file_access.is_enabled; 54 result.wants_file_access = info.file_access.is_enabled;
56 55
57 result->icon_url = info.icon_url; 56 result.icon_url = info.icon_url;
58 57
59 result->incognito_enabled = info.incognito_access.is_active; 58 result.incognito_enabled = info.incognito_access.is_active;
60 result->allow_incognito = info.incognito_access.is_enabled; 59 result.allow_incognito = info.incognito_access.is_enabled;
61 60
62 result->is_unpacked = 61 result.is_unpacked =
63 info.location == api::developer_private::LOCATION_UNPACKED; 62 info.location == api::developer_private::LOCATION_UNPACKED;
64 result->allow_reload = result->is_unpacked; 63 result.allow_reload = result.is_unpacked;
65 result->terminated = 64 result.terminated =
66 info.state == api::developer_private::EXTENSION_STATE_TERMINATED; 65 info.state == api::developer_private::EXTENSION_STATE_TERMINATED;
67 66
68 if (info.path) 67 if (info.path)
69 result->path.reset(new std::string(*info.path)); 68 result.path.reset(new std::string(*info.path));
70 if (info.options_page) 69 if (info.options_page)
71 result->options_url.reset(new std::string(info.options_page->url)); 70 result.options_url.reset(new std::string(info.options_page->url));
72 if (info.launch_url) 71 if (info.launch_url)
73 result->app_launch_url.reset(new std::string(*info.launch_url)); 72 result.app_launch_url.reset(new std::string(*info.launch_url));
74 if (!info.home_page.url.empty()) 73 if (!info.home_page.url.empty())
75 result->homepage_url.reset(new std::string(info.home_page.url)); 74 result.homepage_url.reset(new std::string(info.home_page.url));
76 result->update_url.reset(new std::string(info.update_url)); 75 result.update_url.reset(new std::string(info.update_url));
77 for (const std::string& str_warning : info.install_warnings) { 76 for (const std::string& str_warning : info.install_warnings) {
78 scoped_ptr<api::developer_private::InstallWarning> warning( 77 api::developer_private::InstallWarning warning;
79 new api::developer_private::InstallWarning()); 78 warning.message = str_warning;
80 warning->message = str_warning; 79 result.install_warnings.push_back(std::move(warning));
81 result->install_warnings.push_back(make_linked_ptr(warning.release()));
82 } 80 }
83 for (const linked_ptr<api::developer_private::ManifestError>& error : 81 for (const api::developer_private::ManifestError& error :
84 info.manifest_errors) { 82 info.manifest_errors) {
85 CHECK(error.get()); 83 scoped_ptr<base::DictionaryValue> value = error.ToValue();
86 scoped_ptr<base::DictionaryValue> value = error->ToValue();
87 value->SetInteger("type", static_cast<int>(ExtensionError::MANIFEST_ERROR)); 84 value->SetInteger("type", static_cast<int>(ExtensionError::MANIFEST_ERROR));
88 value->SetInteger("level", static_cast<int>(logging::LOG_WARNING)); 85 value->SetInteger("level", static_cast<int>(logging::LOG_WARNING));
89 result->manifest_errors.push_back(make_linked_ptr(value.release())); 86 result.manifest_errors.push_back(make_linked_ptr(value.release()));
90 } 87 }
91 for (const linked_ptr<api::developer_private::RuntimeError>& error : 88 for (const api::developer_private::RuntimeError& error :
92 info.runtime_errors) { 89 info.runtime_errors) {
93 CHECK(error.get()); 90 scoped_ptr<base::DictionaryValue> value = error.ToValue();
94 scoped_ptr<base::DictionaryValue> value = error->ToValue();
95 value->SetInteger("type", static_cast<int>(ExtensionError::RUNTIME_ERROR)); 91 value->SetInteger("type", static_cast<int>(ExtensionError::RUNTIME_ERROR));
96 logging::LogSeverity severity = logging::LOG_INFO; 92 logging::LogSeverity severity = logging::LOG_INFO;
97 if (error->severity == api::developer_private::ERROR_LEVEL_WARN) 93 if (error.severity == api::developer_private::ERROR_LEVEL_WARN)
98 severity = logging::LOG_WARNING; 94 severity = logging::LOG_WARNING;
99 else if (error->severity == api::developer_private::ERROR_LEVEL_ERROR) 95 else if (error.severity == api::developer_private::ERROR_LEVEL_ERROR)
100 severity = logging::LOG_ERROR; 96 severity = logging::LOG_ERROR;
101 value->SetInteger("level", static_cast<int>(severity)); 97 value->SetInteger("level", static_cast<int>(severity));
102 result->runtime_errors.push_back(make_linked_ptr(value.release())); 98 result.runtime_errors.push_back(make_linked_ptr(value.release()));
103 } 99 }
104 result->offline_enabled = info.offline_enabled; 100 result.offline_enabled = info.offline_enabled;
105 for (const linked_ptr<api::developer_private::ExtensionView>& view : 101 for (const api::developer_private::ExtensionView& view : info.views) {
106 info.views) { 102 api::developer_private::ItemInspectView view_copy;
107 linked_ptr<api::developer_private::ItemInspectView> view_copy( 103 GURL url(view.url);
108 new api::developer_private::ItemInspectView());
109 GURL url(view->url);
110 if (url.scheme() == kExtensionScheme) { 104 if (url.scheme() == kExtensionScheme) {
111 // No leading slash. 105 // No leading slash.
112 view_copy->path = url.path().substr(1); 106 view_copy.path = url.path().substr(1);
113 } else { 107 } else {
114 // For live pages, use the full URL. 108 // For live pages, use the full URL.
115 view_copy->path = url.spec(); 109 view_copy.path = url.spec();
116 } 110 }
117 view_copy->render_process_id = view->render_process_id; 111 view_copy.render_process_id = view.render_process_id;
118 view_copy->render_view_id = view->render_view_id; 112 view_copy.render_view_id = view.render_view_id;
119 view_copy->incognito = view->incognito; 113 view_copy.incognito = view.incognito;
120 view_copy->generated_background_page = 114 view_copy.generated_background_page =
121 view_copy->path == kGeneratedBackgroundPageFilename; 115 view_copy.path == kGeneratedBackgroundPageFilename;
122 result->views.push_back(view_copy); 116 result.views.push_back(std::move(view_copy));
123 } 117 }
124 118
125 return result; 119 return result;
126 } 120 }
127 121
128 } // namespace developer_private_mangle 122 } // namespace developer_private_mangle
129 } // namespace extensions 123 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698