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

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

Issue 989813002: [Extensions] Make a chrome.developerPrivate.getExtensionsInfo function (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
(Empty)
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
3 // found in the LICENSE file.
not at google - send to devlin 2015/03/11 17:43:05 Have you tested that CDE still works?
Devlin 2015/03/11 21:45:53 Yes.
4
5 #include "chrome/browser/extensions/api/developer_private/developer_private_mang le.h"
6
7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h"
9 #include "chrome/common/extensions/api/developer_private.h"
10
11 namespace extensions {
12 namespace developer_private_mangle {
13
14 linked_ptr<api::developer_private::ItemInfo> MangleExtensionInfo(
15 const api::developer_private::ExtensionInfo& info) {
16 linked_ptr<api::developer_private::ItemInfo> result(
17 new api::developer_private::ItemInfo());
18 result->id = info.id;
19 result->name = info.name;
20 result->version = info.version;
21 result->description = info.description;
22 result->may_disable = info.user_may_modify;
23 result->enabled =
24 info.state == api::developer_private::EXTENSION_STATE_ENABLED;
25 switch (info.type) {
26 case api::developer_private::EXTENSION_TYPE_HOSTED_APP:
27 result->type = api::developer_private::ITEM_TYPE_HOSTED_APP;
28 result->is_app = true;
29 break;
30 case api::developer_private::EXTENSION_TYPE_PLATFORM_APP:
31 result->type = api::developer_private::ITEM_TYPE_PACKAGED_APP;
32 result->is_app = true;
33 break;
34 case api::developer_private::EXTENSION_TYPE_LEGACY_PACKAGED_APP:
35 result->type = api::developer_private::ITEM_TYPE_LEGACY_PACKAGED_APP;
36 result->is_app = true;
37 break;
38 case api::developer_private::EXTENSION_TYPE_EXTENSION:
39 result->type = api::developer_private::ITEM_TYPE_EXTENSION;
40 result->is_app = false;
41 break;
42 case api::developer_private::EXTENSION_TYPE_THEME:
43 result->type = api::developer_private::ITEM_TYPE_THEME;
44 result->is_app = false;
45 break;
46 case api::developer_private::EXTENSION_TYPE_SHARED_MODULE:
47 // Old api doesn't account for this.
48 break;
49 default:
50 NOTREACHED();
51 }
52 result->allow_file_access = info.file_access.is_enabled;
53 result->wants_file_access = info.file_access.is_active;
54
55 result->incognito_enabled = info.incognito_access.is_active;
56 result->allow_incognito = info.incognito_access.is_enabled;
57
58 result->is_unpacked =
59 info.location == api::developer_private::LOCATION_UNPACKED;
60 result->allow_reload = result->is_unpacked;
61 result->terminated =
62 info.state == api::developer_private::EXTENSION_STATE_TERMINATED;
63
64 if (info.path)
65 result->path.reset(new std::string(*info.path));
66 if (!info.options_page)
67 result->options_url.reset(new std::string(info.options_page->url));
68 if (info.launch_url)
69 result->app_launch_url.reset(new std::string(*info.launch_url));
70 if (!info.home_page.url.empty())
71 result->homepage_url.reset(new std::string(info.home_page.url));
72 result->update_url.reset(new std::string(info.update_url));
73 for (const std::string& str_warning : info.install_warnings) {
74 scoped_ptr<api::developer_private::InstallWarning> warning(
75 new api::developer_private::InstallWarning());
76 warning->message = str_warning;
77 result->install_warnings.push_back(make_linked_ptr(warning.release()));
78 }
79 for (const linked_ptr<api::developer_private::ManifestError>& error :
80 info.manifest_errors) {
81 scoped_ptr<base::Value> value = error->ToValue();
82 scoped_ptr<api::developer_private::ManifestError> error_copy =
83 api::developer_private::ManifestError::FromValue(*value);
84 result->manifest_errors.push_back(make_linked_ptr(error_copy.release()));
85 }
86 for (const linked_ptr<api::developer_private::RuntimeError>& error :
87 info.runtime_errors) {
88 scoped_ptr<base::Value> value = error->ToValue();
89 scoped_ptr<api::developer_private::RuntimeError> error_copy =
90 api::developer_private::RuntimeError::FromValue(*value);
91 result->runtime_errors.push_back(make_linked_ptr(error_copy.release()));
92 }
93 result->offline_enabled = info.offline_enabled;
94 for (const linked_ptr<api::developer_private::ExtensionView>& view :
95 info.views) {
96 linked_ptr<api::developer_private::ItemInspectView> view_copy(
97 new api::developer_private::ItemInspectView());
98 view_copy->path = view->path;
99 view_copy->render_process_id = view->render_process_id;
100 view_copy->render_view_id = view->render_view_id;
101 view_copy->incognito = view->incognito;
102 view_copy->generated_background_page = view->generated_background_page;
103 result->views.push_back(view_copy);
104 }
105
106 return result;
107 }
108
109 } // namespace developer_private_mangle
110 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698