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

Side by Side Diff: chrome/browser/chromeos/file_manager/file_tasks.cc

Issue 313273002: Video Player: Supports multiple files (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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/file_manager/file_tasks.h" 5 #include "chrome/browser/chromeos/file_manager/file_tasks.h"
6 6
7 #include "apps/launcher.h" 7 #include "apps/launcher.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/prefs/scoped_user_pref_update.h" 10 #include "base/prefs/scoped_user_pref_update.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Leaves tasks handled by the file manger itself as is and removes all others. 103 // Leaves tasks handled by the file manger itself as is and removes all others.
104 void KeepOnlyFileManagerInternalTasks(std::vector<FullTaskDescriptor>* tasks) { 104 void KeepOnlyFileManagerInternalTasks(std::vector<FullTaskDescriptor>* tasks) {
105 std::vector<FullTaskDescriptor> filtered; 105 std::vector<FullTaskDescriptor> filtered;
106 for (size_t i = 0; i < tasks->size(); ++i) { 106 for (size_t i = 0; i < tasks->size(); ++i) {
107 if ((*tasks)[i].task_descriptor().app_id == kFileManagerAppId) 107 if ((*tasks)[i].task_descriptor().app_id == kFileManagerAppId)
108 filtered.push_back((*tasks)[i]); 108 filtered.push_back((*tasks)[i]);
109 } 109 }
110 tasks->swap(filtered); 110 tasks->swap(filtered);
111 } 111 }
112 112
113 // Finds a task that matches |app_id| and |action_id| from |task_list|.
114 // Returns a mutable iterator to the handler if found. Returns task_list->end()
115 // if not found.
116 std::vector<FullTaskDescriptor>::iterator
117 FindTaskForAppIdAndActionId(
118 std::vector<FullTaskDescriptor>* task_list,
119 const std::string& app_id,
120 const std::string& action_id) {
121 DCHECK(task_list);
122
123 std::vector<FullTaskDescriptor>::iterator iter = task_list->begin();
124 while (iter != task_list->end() &&
125 !(iter->task_descriptor().app_id == app_id &&
126 iter->task_descriptor().action_id == action_id)) {
127 ++iter;
128 }
129 return iter;
130 }
131
132 // Chooses a suitable video handeler and removes other internal video hander.
133 // Both "watch" and "gallery-video" actions are applicable which means that the
134 // selection is all videos. Showing them both is confusing, so we only keep
135 // the one that makes more sense ("watch" for single selection, "gallery"
136 // for multiple selection).
137 void ChooseSuitableVideoHandler(
138 const std::vector<GURL>& file_urls,
139 std::vector<FullTaskDescriptor>* task_list) {
140 std::vector<FullTaskDescriptor>::iterator video_player_iter =
141 FindTaskForAppIdAndActionId(task_list, kVideoPlayerAppId, "video");
142 std::vector<FullTaskDescriptor>::iterator gallery_video_iter =
143 FindTaskForAppIdAndActionId(task_list, kGalleryAppId, "open");
144
145 if (video_player_iter != task_list->end() &&
146 gallery_video_iter != task_list->end()) {
147 if (file_urls.size() == 1)
148 task_list->erase(gallery_video_iter);
149 else
150 task_list->erase(video_player_iter);
151 }
152 }
153
154 } // namespace 113 } // namespace
155 114
156 FullTaskDescriptor::FullTaskDescriptor( 115 FullTaskDescriptor::FullTaskDescriptor(
157 const TaskDescriptor& task_descriptor, 116 const TaskDescriptor& task_descriptor,
158 const std::string& task_title, 117 const std::string& task_title,
159 const GURL& icon_url, 118 const GURL& icon_url,
160 bool is_default) 119 bool is_default)
161 : task_descriptor_(task_descriptor), 120 : task_descriptor_(task_descriptor),
162 task_title_(task_title), 121 task_title_(task_title),
163 icon_url_(icon_url), 122 icon_url_(icon_url),
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 464
506 // Find and append file browser handler tasks. We know there aren't 465 // Find and append file browser handler tasks. We know there aren't
507 // duplicates because "file_browser_handlers" and "file_handlers" shouldn't 466 // duplicates because "file_browser_handlers" and "file_handlers" shouldn't
508 // be used in the same manifest.json. 467 // be used in the same manifest.json.
509 FindFileBrowserHandlerTasks(profile, file_urls, result_list); 468 FindFileBrowserHandlerTasks(profile, file_urls, result_list);
510 469
511 // Google documents can only be handled by internal handlers. 470 // Google documents can only be handled by internal handlers.
512 if (ContainsGoogleDocument(path_mime_set)) 471 if (ContainsGoogleDocument(path_mime_set))
513 KeepOnlyFileManagerInternalTasks(result_list); 472 KeepOnlyFileManagerInternalTasks(result_list);
514 473
515 ChooseSuitableVideoHandler(file_urls, result_list);
516
517 ChooseAndSetDefaultTask(*profile->GetPrefs(), path_mime_set, result_list); 474 ChooseAndSetDefaultTask(*profile->GetPrefs(), path_mime_set, result_list);
518 } 475 }
519 476
520 void ChooseAndSetDefaultTask(const PrefService& pref_service, 477 void ChooseAndSetDefaultTask(const PrefService& pref_service,
521 const PathAndMimeTypeSet& path_mime_set, 478 const PathAndMimeTypeSet& path_mime_set,
522 std::vector<FullTaskDescriptor>* tasks) { 479 std::vector<FullTaskDescriptor>* tasks) {
523 // Collect the task IDs of default tasks from the preferences into a set. 480 // Collect the task IDs of default tasks from the preferences into a set.
524 std::set<std::string> default_task_ids; 481 std::set<std::string> default_task_ids;
525 for (PathAndMimeTypeSet::const_iterator it = path_mime_set.begin(); 482 for (PathAndMimeTypeSet::const_iterator it = path_mime_set.begin();
526 it != path_mime_set.end(); ++it) { 483 it != path_mime_set.end(); ++it) {
(...skipping 24 matching lines...) Expand all
551 if (file_browser_handlers::IsFallbackFileBrowserHandler( 508 if (file_browser_handlers::IsFallbackFileBrowserHandler(
552 task->task_descriptor())) { 509 task->task_descriptor())) {
553 task->set_is_default(true); 510 task->set_is_default(true);
554 return; 511 return;
555 } 512 }
556 } 513 }
557 } 514 }
558 515
559 } // namespace file_tasks 516 } // namespace file_tasks
560 } // namespace file_manager 517 } // namespace file_manager
OLDNEW
« no previous file with comments | « no previous file | ui/file_manager/video_player/css/arrow_box.css » ('j') | ui/file_manager/video_player/css/arrow_box.css » ('J')

Powered by Google App Engine
This is Rietveld 408576698