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

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.
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 =
53 info.file_access == api::developer_private::RUN_STATE_VALUE_HAS_STATE;
54 result->wants_file_access =
55 info.file_access == api::developer_private::RUN_STATE_VALUE_WANTS_STATE ||
56 info.file_access == api::developer_private::RUN_STATE_VALUE_HAS_STATE;
57
58 result->incognito_enabled =
59 info.incognito_access ==
60 api::developer_private::RUN_STATE_VALUE_HAS_STATE;
61 result->allow_incognito =
62 info.incognito_access ==
63 api::developer_private::RUN_STATE_VALUE_WANTS_STATE ||
64 info.incognito_access ==
65 api::developer_private::RUN_STATE_VALUE_HAS_STATE;
66
67 result->is_unpacked =
68 info.location == api::developer_private::LOCATION_UNPACKED;
69 result->allow_reload = result->is_unpacked;
70 result->terminated =
71 info.state == api::developer_private::EXTENSION_STATE_TERMINATED;
72
73 if (info.path)
74 result->path.reset(new std::string(*info.path));
75 if (!info.options_page)
76 result->options_url.reset(new std::string(info.options_page->url));
77 if (info.launch_url)
78 result->app_launch_url.reset(new std::string(*info.launch_url));
79 if (!info.home_page.url.empty())
80 result->homepage_url.reset(new std::string(info.home_page.url));
81 result->update_url.reset(new std::string(info.update_url));
82 for (const std::string& str_warning : info.install_warnings) {
83 scoped_ptr<api::developer_private::InstallWarning> warning(
84 new api::developer_private::InstallWarning());
85 warning->message = str_warning;
86 result->install_warnings.push_back(make_linked_ptr(warning.release()));
87 }
88 for (const linked_ptr<api::developer_private::ManifestError>& error :
89 info.manifest_errors) {
90 scoped_ptr<base::Value> value = error->ToValue();
91 scoped_ptr<api::developer_private::ManifestError> error_copy =
92 api::developer_private::ManifestError::FromValue(*value);
93 result->manifest_errors.push_back(make_linked_ptr(error_copy.release()));
94 }
95 for (const linked_ptr<api::developer_private::RuntimeError>& error :
96 info.runtime_errors) {
97 scoped_ptr<base::Value> value = error->ToValue();
98 scoped_ptr<api::developer_private::RuntimeError> error_copy =
99 api::developer_private::RuntimeError::FromValue(*value);
100 result->runtime_errors.push_back(make_linked_ptr(error_copy.release()));
101 }
102 result->offline_enabled = info.offline_enabled;
103 for (const linked_ptr<api::developer_private::ExtensionView>& view :
104 info.views) {
105 linked_ptr<api::developer_private::ItemInspectView> view_copy(
106 new api::developer_private::ItemInspectView());
107 view_copy->path = view->path;
108 view_copy->render_process_id = view->render_process_id;
109 view_copy->render_view_id = view->render_view_id;
110 view_copy->incognito = view->incognito;
111 view_copy->generated_background_page = view->generated_background_page;
112 result->views.push_back(view_copy);
113 }
114
115 return result;
116 }
117
118 } // namespace developer_private_mangle
119 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698