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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/file_browser_private_api.cc

Issue 15975004: Replace sets with vectors when storing file handlers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 6 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 | Annotate | Revision Log
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/chromeos/extensions/file_manager/file_browser_private_a pi.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/file_browser_private_a pi.h"
6 6
7 #include <sys/stat.h> 7 #include <sys/stat.h>
8 #include <sys/statvfs.h> 8 #include <sys/statvfs.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <utime.h> 10 #include <utime.h>
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 // tasks. 1034 // tasks.
1035 if (!FindAppTasks(file_paths, result_list, &default_already_set)) 1035 if (!FindAppTasks(file_paths, result_list, &default_already_set))
1036 return false; 1036 return false;
1037 1037
1038 // Take the union of Drive and extension tasks: Because any Drive tasks we 1038 // Take the union of Drive and extension tasks: Because any Drive tasks we
1039 // found must apply to all of the files (intersection), and because the same 1039 // found must apply to all of the files (intersection), and because the same
1040 // is true of the extensions, we simply take the union of two lists by adding 1040 // is true of the extensions, we simply take the union of two lists by adding
1041 // the extension tasks to the Drive task list. We know there aren't duplicates 1041 // the extension tasks to the Drive task list. We know there aren't duplicates
1042 // because they're entirely different kinds of tasks, but there could be both 1042 // because they're entirely different kinds of tasks, but there could be both
1043 // kinds of tasks for a file type (an image file, for instance). 1043 // kinds of tasks for a file type (an image file, for instance).
1044 std::set<const FileBrowserHandler*> common_tasks; 1044 file_handler_util::FileBrowserHandlerList common_tasks;
1045 std::set<const FileBrowserHandler*> default_tasks; 1045 file_handler_util::FileBrowserHandlerList default_tasks;
1046 if (!file_handler_util::FindCommonTasks(profile_, file_urls, &common_tasks)) 1046 if (!file_handler_util::FindCommonTasks(profile_, file_urls, &common_tasks))
1047 return false; 1047 return false;
1048 file_handler_util::FindDefaultTasks(profile_, file_paths, 1048 file_handler_util::FindDefaultTasks(profile_, file_paths,
1049 common_tasks, &default_tasks); 1049 common_tasks, &default_tasks);
1050 1050
1051 ExtensionService* service = 1051 ExtensionService* service =
1052 extensions::ExtensionSystem::Get(profile_)->extension_service(); 1052 extensions::ExtensionSystem::Get(profile_)->extension_service();
1053 for (std::set<const FileBrowserHandler*>::const_iterator iter = 1053 for (file_handler_util::FileBrowserHandlerList::const_iterator iter =
1054 common_tasks.begin(); 1054 common_tasks.begin();
1055 iter != common_tasks.end(); 1055 iter != common_tasks.end();
1056 ++iter) { 1056 ++iter) {
1057 const FileBrowserHandler* handler = *iter; 1057 const FileBrowserHandler* handler = *iter;
1058 const std::string extension_id = handler->extension_id(); 1058 const std::string extension_id = handler->extension_id();
1059 const Extension* extension = service->GetExtensionById(extension_id, false); 1059 const Extension* extension = service->GetExtensionById(extension_id, false);
1060 CHECK(extension); 1060 CHECK(extension);
1061 DictionaryValue* task = new DictionaryValue; 1061 DictionaryValue* task = new DictionaryValue;
1062 task->SetString("taskId", file_handler_util::MakeTaskID( 1062 task->SetString("taskId", file_handler_util::MakeTaskID(
1063 extension_id, file_handler_util::kTaskFile, handler->id())); 1063 extension_id, file_handler_util::kTaskFile, handler->id()));
1064 task->SetString("title", handler->title()); 1064 task->SetString("title", handler->title());
1065 // TODO(zelidrag): Figure out how to expose icon URL that task defined in 1065 // TODO(zelidrag): Figure out how to expose icon URL that task defined in
1066 // manifest instead of the default extension icon. 1066 // manifest instead of the default extension icon.
1067 GURL icon = 1067 GURL icon =
1068 ExtensionIconSource::GetIconURL(extension, 1068 ExtensionIconSource::GetIconURL(extension,
1069 extension_misc::EXTENSION_ICON_BITTY, 1069 extension_misc::EXTENSION_ICON_BITTY,
1070 ExtensionIconSet::MATCH_BIGGER, 1070 ExtensionIconSet::MATCH_BIGGER,
1071 false, NULL); // grayscale 1071 false, NULL); // grayscale
1072 task->SetString("iconUrl", icon.spec()); 1072 task->SetString("iconUrl", icon.spec());
1073 task->SetBoolean("driveApp", false); 1073 task->SetBoolean("driveApp", false);
1074 1074
1075 // Only set the default if there isn't already a default set. 1075 // Only set the default if there isn't already a default set.
1076 if (!default_already_set && 1076 if (!default_already_set &&
1077 default_tasks.find(*iter) != default_tasks.end()) { 1077 std::find(default_tasks.begin(), default_tasks.end(), *iter) !=
1078 default_tasks.end()) {
1078 task->SetBoolean("isDefault", true); 1079 task->SetBoolean("isDefault", true);
1079 default_already_set = true; 1080 default_already_set = true;
1080 } else { 1081 } else {
1081 task->SetBoolean("isDefault", false); 1082 task->SetBoolean("isDefault", false);
1082 } 1083 }
1083 1084
1084 result_list->Append(task); 1085 result_list->Append(task);
1085 } 1086 }
1086 1087
1087 if (VLOG_IS_ON(1)) { 1088 if (VLOG_IS_ON(1)) {
(...skipping 2097 matching lines...) Expand 10 before | Expand all | Expand 10 after
3185 OpenNewWindowFunction::OpenNewWindowFunction() {} 3186 OpenNewWindowFunction::OpenNewWindowFunction() {}
3186 3187
3187 OpenNewWindowFunction::~OpenNewWindowFunction() {} 3188 OpenNewWindowFunction::~OpenNewWindowFunction() {}
3188 3189
3189 bool OpenNewWindowFunction::RunImpl() { 3190 bool OpenNewWindowFunction::RunImpl() {
3190 std::string url; 3191 std::string url;
3191 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url)); 3192 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url));
3192 file_manager_util::OpenNewWindow(profile_, GURL(url)); 3193 file_manager_util::OpenNewWindow(profile_, GURL(url));
3193 return true; 3194 return true;
3194 } 3195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698