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

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

Issue 102103005: Move c/c/e/extension_set to top-level extensions/ (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_api. h" 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h"
6 6
7 #include "apps/app_load_service.h" 7 #include "apps/app_load_service.h"
8 #include "apps/app_restore_service.h" 8 #include "apps/app_restore_service.h"
9 #include "apps/saved_files_service.h" 9 #include "apps/saved_files_service.h"
10 #include "apps/shell_window.h" 10 #include "apps/shell_window.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "content/public/browser/notification_service.h" 45 #include "content/public/browser/notification_service.h"
46 #include "content/public/browser/render_process_host.h" 46 #include "content/public/browser/render_process_host.h"
47 #include "content/public/browser/render_view_host.h" 47 #include "content/public/browser/render_view_host.h"
48 #include "content/public/browser/site_instance.h" 48 #include "content/public/browser/site_instance.h"
49 #include "content/public/browser/storage_partition.h" 49 #include "content/public/browser/storage_partition.h"
50 #include "content/public/browser/web_contents.h" 50 #include "content/public/browser/web_contents.h"
51 #include "extensions/browser/management_policy.h" 51 #include "extensions/browser/management_policy.h"
52 #include "extensions/browser/view_type_utils.h" 52 #include "extensions/browser/view_type_utils.h"
53 #include "extensions/common/constants.h" 53 #include "extensions/common/constants.h"
54 #include "extensions/common/extension_resource.h" 54 #include "extensions/common/extension_resource.h"
55 #include "extensions/common/extension_set.h"
55 #include "extensions/common/install_warning.h" 56 #include "extensions/common/install_warning.h"
56 #include "extensions/common/manifest_handlers/background_info.h" 57 #include "extensions/common/manifest_handlers/background_info.h"
57 #include "extensions/common/manifest_handlers/incognito_info.h" 58 #include "extensions/common/manifest_handlers/incognito_info.h"
58 #include "extensions/common/manifest_handlers/offline_enabled_info.h" 59 #include "extensions/common/manifest_handlers/offline_enabled_info.h"
59 #include "extensions/common/switches.h" 60 #include "extensions/common/switches.h"
60 #include "grit/chromium_strings.h" 61 #include "grit/chromium_strings.h"
61 #include "grit/generated_resources.h" 62 #include "grit/generated_resources.h"
62 #include "grit/theme_resources.h" 63 #include "grit/theme_resources.h"
63 #include "net/base/net_util.h" 64 #include "net/base/net_util.h"
64 #include "ui/base/l10n/l10n_util.h" 65 #include "ui/base/l10n/l10n_util.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 124
124 return GetImageURLFromData(contents); 125 return GetImageURLFromData(contents);
125 } 126 }
126 127
127 bool ValidateFolderName(const base::FilePath::StringType& name) { 128 bool ValidateFolderName(const base::FilePath::StringType& name) {
128 base::FilePath::StringType name_sanitized(name); 129 base::FilePath::StringType name_sanitized(name);
129 file_util::ReplaceIllegalCharactersInPath(&name_sanitized, '_'); 130 file_util::ReplaceIllegalCharactersInPath(&name_sanitized, '_');
130 return name == name_sanitized; 131 return name == name_sanitized;
131 } 132 }
132 133
133 const Extension* GetExtensionByPath(const ExtensionSet* extensions, 134 const Extension* GetExtensionByPath(const extensions::ExtensionSet* extensions,
134 const base::FilePath& path) { 135 const base::FilePath& path) {
135 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); 136 base::FilePath extension_path = base::MakeAbsoluteFilePath(path);
136 for (ExtensionSet::const_iterator iter = extensions->begin(); 137 for (extensions::ExtensionSet::const_iterator iter = extensions->begin();
137 iter != extensions->end(); ++iter) { 138 iter != extensions->end(); ++iter) {
138 if ((*iter)->path() == extension_path) 139 if ((*iter)->path() == extension_path)
139 return iter->get(); 140 return iter->get();
140 } 141 }
141 return NULL; 142 return NULL;
142 } 143 }
143 144
144 std::string GetExtensionID(const RenderViewHost* render_view_host) { 145 std::string GetExtensionID(const RenderViewHost* render_view_host) {
145 if (!render_view_host->GetSiteInstance()) 146 if (!render_view_host->GetSiteInstance())
146 return std::string(); 147 return std::string();
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 523 }
523 524
524 bool DeveloperPrivateGetItemsInfoFunction::RunImpl() { 525 bool DeveloperPrivateGetItemsInfoFunction::RunImpl() {
525 scoped_ptr<developer::GetItemsInfo::Params> params( 526 scoped_ptr<developer::GetItemsInfo::Params> params(
526 developer::GetItemsInfo::Params::Create(*args_)); 527 developer::GetItemsInfo::Params::Create(*args_));
527 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); 528 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
528 529
529 bool include_disabled = params->include_disabled; 530 bool include_disabled = params->include_disabled;
530 bool include_terminated = params->include_terminated; 531 bool include_terminated = params->include_terminated;
531 532
532 ExtensionSet items; 533 extensions::ExtensionSet items;
533 534
534 ExtensionService* service = GetProfile()->GetExtensionService(); 535 ExtensionService* service = GetProfile()->GetExtensionService();
535 536
536 items.InsertAll(*service->extensions()); 537 items.InsertAll(*service->extensions());
537 538
538 if (include_disabled) { 539 if (include_disabled) {
539 items.InsertAll(*service->disabled_extensions()); 540 items.InsertAll(*service->disabled_extensions());
540 } 541 }
541 542
542 if (include_terminated) { 543 if (include_terminated) {
543 items.InsertAll(*service->terminated_extensions()); 544 items.InsertAll(*service->terminated_extensions());
544 } 545 }
545 546
546 std::map<std::string, ExtensionResource> id_to_icon; 547 std::map<std::string, ExtensionResource> id_to_icon;
547 ItemInfoList item_list; 548 ItemInfoList item_list;
548 549
549 for (ExtensionSet::const_iterator iter = items.begin(); 550 for (extensions::ExtensionSet::const_iterator iter = items.begin();
550 iter != items.end(); ++iter) { 551 iter != items.end(); ++iter) {
551 const Extension& item = *iter->get(); 552 const Extension& item = *iter->get();
552 553
553 ExtensionResource item_resource = 554 ExtensionResource item_resource =
554 IconsInfo::GetIconResource(&item, 555 IconsInfo::GetIconResource(&item,
555 extension_misc::EXTENSION_ICON_MEDIUM, 556 extension_misc::EXTENSION_ICON_MEDIUM,
556 ExtensionIconSet::MATCH_BIGGER); 557 ExtensionIconSet::MATCH_BIGGER);
557 id_to_icon[item.id()] = item_resource; 558 id_to_icon[item.id()] = item_resource;
558 559
559 // Don't show component extensions and invisible apps. 560 // Don't show component extensions and invisible apps.
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 return false; 1129 return false;
1129 } 1130 }
1130 1131
1131 base::FilePath path(GetProfile()->GetPath()); 1132 base::FilePath path(GetProfile()->GetPath());
1132 path = path.Append(kUnpackedAppsFolder); 1133 path = path.Append(kUnpackedAppsFolder);
1133 // TODO(grv) : Sanitize / check project_name. 1134 // TODO(grv) : Sanitize / check project_name.
1134 path = path.Append(project_name); 1135 path = path.Append(project_name);
1135 ExtensionService* service = GetProfile()->GetExtensionService(); 1136 ExtensionService* service = GetProfile()->GetExtensionService();
1136 UnpackedInstaller::Create(service)->Load(path); 1137 UnpackedInstaller::Create(service)->Load(path);
1137 1138
1138 const ExtensionSet* extensions = service->extensions(); 1139 const extensions::ExtensionSet* extensions = service->extensions();
1139 // Released by GetUnpackedExtension. 1140 // Released by GetUnpackedExtension.
1140 AddRef(); 1141 AddRef();
1141 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, 1142 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE,
1142 base::Bind(&DeveloperPrivateLoadProjectFunction::GetUnpackedExtension, 1143 base::Bind(&DeveloperPrivateLoadProjectFunction::GetUnpackedExtension,
1143 this, path, extensions)); 1144 this, path, extensions));
1144 return true; 1145 return true;
1145 } 1146 }
1146 1147
1147 void DeveloperPrivateLoadProjectFunction::GetUnpackedExtension( 1148 void DeveloperPrivateLoadProjectFunction::GetUnpackedExtension(
1148 const base::FilePath& path, 1149 const base::FilePath& path,
1149 const ExtensionSet* extensions) { 1150 const extensions::ExtensionSet* extensions) {
1150 const Extension* extension = GetExtensionByPath(extensions, path); 1151 const Extension* extension = GetExtensionByPath(extensions, path);
1151 bool success = true; 1152 bool success = true;
1152 if (extension) { 1153 if (extension) {
1153 SetResult(new base::StringValue(extension->id())); 1154 SetResult(new base::StringValue(extension->id()));
1154 } else { 1155 } else {
1155 SetError("unable to load the project"); 1156 SetError("unable to load the project");
1156 success = false; 1157 success = false;
1157 } 1158 }
1158 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 1159 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
1159 base::Bind(&DeveloperPrivateLoadProjectFunction::SendResponse, 1160 base::Bind(&DeveloperPrivateLoadProjectFunction::SendResponse,
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 return true; 1341 return true;
1341 } 1342 }
1342 1343
1343 DeveloperPrivateIsProfileManagedFunction:: 1344 DeveloperPrivateIsProfileManagedFunction::
1344 ~DeveloperPrivateIsProfileManagedFunction() { 1345 ~DeveloperPrivateIsProfileManagedFunction() {
1345 } 1346 }
1346 1347
1347 } // namespace api 1348 } // namespace api
1348 1349
1349 } // namespace extensions 1350 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698