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

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

Issue 2777063003: Stop passing raw pointers to base::Value API in c/b/chromeos and c/b/extensions (Closed)
Patch Set: Just rebased Created 3 years, 8 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
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 <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "apps/launcher.h" 11 #include "apps/launcher.h"
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "base/memory/ptr_util.h"
14 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
15 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
16 #include "chrome/browser/chromeos/drive/file_system_util.h" 17 #include "chrome/browser/chromeos/drive/file_system_util.h"
17 #include "chrome/browser/chromeos/drive/file_task_executor.h" 18 #include "chrome/browser/chromeos/drive/file_task_executor.h"
18 #include "chrome/browser/chromeos/file_manager/app_id.h" 19 #include "chrome/browser/chromeos/file_manager/app_id.h"
19 #include "chrome/browser/chromeos/file_manager/arc_file_tasks.h" 20 #include "chrome/browser/chromeos/file_manager/arc_file_tasks.h"
20 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h" 21 #include "chrome/browser/chromeos/file_manager/file_browser_handlers.h"
21 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 22 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
22 #include "chrome/browser/chromeos/file_manager/open_util.h" 23 #include "chrome/browser/chromeos/file_manager/open_util.h"
23 #include "chrome/browser/extensions/extension_tab_util.h" 24 #include "chrome/browser/extensions/extension_tab_util.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 const std::set<std::string>& suffixes, 191 const std::set<std::string>& suffixes,
191 const std::set<std::string>& mime_types) { 192 const std::set<std::string>& mime_types) {
192 if (!pref_service) 193 if (!pref_service)
193 return; 194 return;
194 195
195 if (!mime_types.empty()) { 196 if (!mime_types.empty()) {
196 DictionaryPrefUpdate mime_type_pref(pref_service, 197 DictionaryPrefUpdate mime_type_pref(pref_service,
197 prefs::kDefaultTasksByMimeType); 198 prefs::kDefaultTasksByMimeType);
198 for (std::set<std::string>::const_iterator iter = mime_types.begin(); 199 for (std::set<std::string>::const_iterator iter = mime_types.begin();
199 iter != mime_types.end(); ++iter) { 200 iter != mime_types.end(); ++iter) {
200 base::Value* value = new base::Value(task_id); 201 mime_type_pref->SetWithoutPathExpansion(
201 mime_type_pref->SetWithoutPathExpansion(*iter, value); 202 *iter, base::MakeUnique<base::Value>(task_id));
202 } 203 }
203 } 204 }
204 205
205 if (!suffixes.empty()) { 206 if (!suffixes.empty()) {
206 DictionaryPrefUpdate mime_type_pref(pref_service, 207 DictionaryPrefUpdate mime_type_pref(pref_service,
207 prefs::kDefaultTasksBySuffix); 208 prefs::kDefaultTasksBySuffix);
208 for (std::set<std::string>::const_iterator iter = suffixes.begin(); 209 for (std::set<std::string>::const_iterator iter = suffixes.begin();
209 iter != suffixes.end(); ++iter) { 210 iter != suffixes.end(); ++iter) {
210 base::Value* value = new base::Value(task_id);
211 // Suffixes are case insensitive. 211 // Suffixes are case insensitive.
212 std::string lower_suffix = base::ToLowerASCII(*iter); 212 std::string lower_suffix = base::ToLowerASCII(*iter);
213 mime_type_pref->SetWithoutPathExpansion(lower_suffix, value); 213 mime_type_pref->SetWithoutPathExpansion(
214 lower_suffix, base::MakeUnique<base::Value>(task_id));
214 } 215 }
215 } 216 }
216 } 217 }
217 218
218 std::string GetDefaultTaskIdFromPrefs(const PrefService& pref_service, 219 std::string GetDefaultTaskIdFromPrefs(const PrefService& pref_service,
219 const std::string& mime_type, 220 const std::string& mime_type,
220 const std::string& suffix) { 221 const std::string& suffix) {
221 VLOG(1) << "Looking for default for MIME type: " << mime_type 222 VLOG(1) << "Looking for default for MIME type: " << mime_type
222 << " and suffix: " << suffix; 223 << " and suffix: " << suffix;
223 std::string task_id; 224 std::string task_id;
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 DCHECK(!task->is_default()); 640 DCHECK(!task->is_default());
640 if (IsFallbackFileHandler(task->task_descriptor())) { 641 if (IsFallbackFileHandler(task->task_descriptor())) {
641 task->set_is_default(true); 642 task->set_is_default(true);
642 return; 643 return;
643 } 644 }
644 } 645 }
645 } 646 }
646 647
647 } // namespace file_tasks 648 } // namespace file_tasks
648 } // namespace file_manager 649 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698