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

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: Move ExtensionSet to extensions namespace 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 123
124 return GetImageURLFromData(contents); 124 return GetImageURLFromData(contents);
125 } 125 }
126 126
127 bool ValidateFolderName(const base::FilePath::StringType& name) { 127 bool ValidateFolderName(const base::FilePath::StringType& name) {
128 base::FilePath::StringType name_sanitized(name); 128 base::FilePath::StringType name_sanitized(name);
129 file_util::ReplaceIllegalCharactersInPath(&name_sanitized, '_'); 129 file_util::ReplaceIllegalCharactersInPath(&name_sanitized, '_');
130 return name == name_sanitized; 130 return name == name_sanitized;
131 } 131 }
132 132
133 const Extension* GetExtensionByPath(const ExtensionSet* extensions, 133 const Extension* GetExtensionByPath(const extensions::ExtensionSet* extensions,
134 const base::FilePath& path) { 134 const base::FilePath& path) {
135 base::FilePath extension_path = base::MakeAbsoluteFilePath(path); 135 base::FilePath extension_path = base::MakeAbsoluteFilePath(path);
136 for (ExtensionSet::const_iterator iter = extensions->begin(); 136 for (extensions::ExtensionSet::const_iterator iter = extensions->begin();
137 iter != extensions->end(); ++iter) { 137 iter != extensions->end(); ++iter) {
138 if ((*iter)->path() == extension_path) 138 if ((*iter)->path() == extension_path)
139 return iter->get(); 139 return iter->get();
140 } 140 }
141 return NULL; 141 return NULL;
142 } 142 }
143 143
144 std::string GetExtensionID(const RenderViewHost* render_view_host) { 144 std::string GetExtensionID(const RenderViewHost* render_view_host) {
145 if (!render_view_host->GetSiteInstance()) 145 if (!render_view_host->GetSiteInstance())
146 return std::string(); 146 return std::string();
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 } 522 }
523 523
524 bool DeveloperPrivateGetItemsInfoFunction::RunImpl() { 524 bool DeveloperPrivateGetItemsInfoFunction::RunImpl() {
525 scoped_ptr<developer::GetItemsInfo::Params> params( 525 scoped_ptr<developer::GetItemsInfo::Params> params(
526 developer::GetItemsInfo::Params::Create(*args_)); 526 developer::GetItemsInfo::Params::Create(*args_));
527 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); 527 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL);
528 528
529 bool include_disabled = params->include_disabled; 529 bool include_disabled = params->include_disabled;
530 bool include_terminated = params->include_terminated; 530 bool include_terminated = params->include_terminated;
531 531
532 ExtensionSet items; 532 extensions::ExtensionSet items;
533 533
534 ExtensionService* service = GetProfile()->GetExtensionService(); 534 ExtensionService* service = GetProfile()->GetExtensionService();
535 535
536 items.InsertAll(*service->extensions()); 536 items.InsertAll(*service->extensions());
537 537
538 if (include_disabled) { 538 if (include_disabled) {
539 items.InsertAll(*service->disabled_extensions()); 539 items.InsertAll(*service->disabled_extensions());
540 } 540 }
541 541
542 if (include_terminated) { 542 if (include_terminated) {
543 items.InsertAll(*service->terminated_extensions()); 543 items.InsertAll(*service->terminated_extensions());
544 } 544 }
545 545
546 std::map<std::string, ExtensionResource> id_to_icon; 546 std::map<std::string, ExtensionResource> id_to_icon;
547 ItemInfoList item_list; 547 ItemInfoList item_list;
548 548
549 for (ExtensionSet::const_iterator iter = items.begin(); 549 for (extensions::ExtensionSet::const_iterator iter = items.begin();
550 iter != items.end(); ++iter) { 550 iter != items.end(); ++iter) {
551 const Extension& item = *iter->get(); 551 const Extension& item = *iter->get();
552 552
553 ExtensionResource item_resource = 553 ExtensionResource item_resource =
554 IconsInfo::GetIconResource(&item, 554 IconsInfo::GetIconResource(&item,
555 extension_misc::EXTENSION_ICON_MEDIUM, 555 extension_misc::EXTENSION_ICON_MEDIUM,
556 ExtensionIconSet::MATCH_BIGGER); 556 ExtensionIconSet::MATCH_BIGGER);
557 id_to_icon[item.id()] = item_resource; 557 id_to_icon[item.id()] = item_resource;
558 558
559 // Don't show component extensions and invisible apps. 559 // Don't show component extensions and invisible apps.
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
1128 return false; 1128 return false;
1129 } 1129 }
1130 1130
1131 base::FilePath path(GetProfile()->GetPath()); 1131 base::FilePath path(GetProfile()->GetPath());
1132 path = path.Append(kUnpackedAppsFolder); 1132 path = path.Append(kUnpackedAppsFolder);
1133 // TODO(grv) : Sanitize / check project_name. 1133 // TODO(grv) : Sanitize / check project_name.
1134 path = path.Append(project_name); 1134 path = path.Append(project_name);
1135 ExtensionService* service = GetProfile()->GetExtensionService(); 1135 ExtensionService* service = GetProfile()->GetExtensionService();
1136 UnpackedInstaller::Create(service)->Load(path); 1136 UnpackedInstaller::Create(service)->Load(path);
1137 1137
1138 const ExtensionSet* extensions = service->extensions(); 1138 const extensions::ExtensionSet* extensions = service->extensions();
1139 // Released by GetUnpackedExtension. 1139 // Released by GetUnpackedExtension.
1140 AddRef(); 1140 AddRef();
1141 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE, 1141 content::BrowserThread::PostTask(content::BrowserThread::FILE, FROM_HERE,
1142 base::Bind(&DeveloperPrivateLoadProjectFunction::GetUnpackedExtension, 1142 base::Bind(&DeveloperPrivateLoadProjectFunction::GetUnpackedExtension,
1143 this, path, extensions)); 1143 this, path, extensions));
1144 return true; 1144 return true;
1145 } 1145 }
1146 1146
1147 void DeveloperPrivateLoadProjectFunction::GetUnpackedExtension( 1147 void DeveloperPrivateLoadProjectFunction::GetUnpackedExtension(
1148 const base::FilePath& path, 1148 const base::FilePath& path,
1149 const ExtensionSet* extensions) { 1149 const extensions::ExtensionSet* extensions) {
1150 const Extension* extension = GetExtensionByPath(extensions, path); 1150 const Extension* extension = GetExtensionByPath(extensions, path);
1151 bool success = true; 1151 bool success = true;
1152 if (extension) { 1152 if (extension) {
1153 SetResult(new base::StringValue(extension->id())); 1153 SetResult(new base::StringValue(extension->id()));
1154 } else { 1154 } else {
1155 SetError("unable to load the project"); 1155 SetError("unable to load the project");
1156 success = false; 1156 success = false;
1157 } 1157 }
1158 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, 1158 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
1159 base::Bind(&DeveloperPrivateLoadProjectFunction::SendResponse, 1159 base::Bind(&DeveloperPrivateLoadProjectFunction::SendResponse,
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 return true; 1340 return true;
1341 } 1341 }
1342 1342
1343 DeveloperPrivateIsProfileManagedFunction:: 1343 DeveloperPrivateIsProfileManagedFunction::
1344 ~DeveloperPrivateIsProfileManagedFunction() { 1344 ~DeveloperPrivateIsProfileManagedFunction() {
1345 } 1345 }
1346 1346
1347 } // namespace api 1347 } // namespace api
1348 1348
1349 } // namespace extensions 1349 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698