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

Side by Side Diff: apps/launcher.cc

Issue 1851373002: convert //apps to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « apps/custom_launcher_page_contents.cc ('k') | apps/saved_files_service.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "apps/launcher.h" 5 #include "apps/launcher.h"
6 6
7 #include <memory>
7 #include <set> 8 #include <set>
8 #include <utility> 9 #include <utility>
9 10
10 #include "base/command_line.h" 11 #include "base/command_line.h"
11 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
12 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
13 #include "base/logging.h" 14 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" 18 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
19 #include "chrome/browser/extensions/api/file_handlers/directory_util.h" 19 #include "chrome/browser/extensions/api/file_handlers/directory_util.h"
20 #include "chrome/browser/extensions/api/file_handlers/mime_util.h" 20 #include "chrome/browser/extensions/api/file_handlers/mime_util.h"
21 #include "chrome/browser/extensions/api/file_system/file_system_api.h" 21 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
25 #include "content/public/browser/web_contents.h" 25 #include "content/public/browser/web_contents.h"
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 base::Bind(&PlatformAppPathLauncher::LaunchWithNoLaunchData, this)); 168 base::Bind(&PlatformAppPathLauncher::LaunchWithNoLaunchData, this));
169 return; 169 return;
170 } 170 }
171 } 171 }
172 172
173 BrowserThread::PostTask(BrowserThread::UI, 173 BrowserThread::PostTask(BrowserThread::UI,
174 FROM_HERE, 174 FROM_HERE,
175 base::Bind(&PlatformAppPathLauncher::Launch, this)); 175 base::Bind(&PlatformAppPathLauncher::Launch, this));
176 } 176 }
177 177
178 void OnFilesValid(scoped_ptr<std::set<base::FilePath>> directory_paths) { 178 void OnFilesValid(std::unique_ptr<std::set<base::FilePath>> directory_paths) {
179 mime_type_collector_.CollectForLocalPaths( 179 mime_type_collector_.CollectForLocalPaths(
180 entry_paths_, 180 entry_paths_,
181 base::Bind( 181 base::Bind(
182 &PlatformAppPathLauncher::OnAreDirectoriesAndMimeTypesCollected, 182 &PlatformAppPathLauncher::OnAreDirectoriesAndMimeTypesCollected,
183 this, base::Passed(std::move(directory_paths)))); 183 this, base::Passed(std::move(directory_paths))));
184 } 184 }
185 185
186 void OnFilesInvalid(const base::FilePath& /* error_path */) { 186 void OnFilesInvalid(const base::FilePath& /* error_path */) {
187 LaunchWithNoLaunchData(); 187 LaunchWithNoLaunchData();
188 } 188 }
189 189
190 void LaunchWithNoLaunchData() { 190 void LaunchWithNoLaunchData() {
191 // This method is required as an entry point on the UI thread. 191 // This method is required as an entry point on the UI thread.
192 DCHECK_CURRENTLY_ON(BrowserThread::UI); 192 DCHECK_CURRENTLY_ON(BrowserThread::UI);
193 193
194 const Extension* extension = GetExtension(); 194 const Extension* extension = GetExtension();
195 if (!extension) 195 if (!extension)
196 return; 196 return;
197 197
198 AppRuntimeEventRouter::DispatchOnLaunchedEvent( 198 AppRuntimeEventRouter::DispatchOnLaunchedEvent(
199 profile_, extension, extensions::SOURCE_FILE_HANDLER); 199 profile_, extension, extensions::SOURCE_FILE_HANDLER);
200 } 200 }
201 201
202 void OnAreDirectoriesCollected( 202 void OnAreDirectoriesCollected(
203 bool has_file_system_write_permission, 203 bool has_file_system_write_permission,
204 scoped_ptr<std::set<base::FilePath>> directory_paths) { 204 std::unique_ptr<std::set<base::FilePath>> directory_paths) {
205 if (has_file_system_write_permission) { 205 if (has_file_system_write_permission) {
206 std::set<base::FilePath>* const directory_paths_ptr = 206 std::set<base::FilePath>* const directory_paths_ptr =
207 directory_paths.get(); 207 directory_paths.get();
208 PrepareFilesForWritableApp( 208 PrepareFilesForWritableApp(
209 entry_paths_, profile_, *directory_paths_ptr, 209 entry_paths_, profile_, *directory_paths_ptr,
210 base::Bind(&PlatformAppPathLauncher::OnFilesValid, this, 210 base::Bind(&PlatformAppPathLauncher::OnFilesValid, this,
211 base::Passed(std::move(directory_paths))), 211 base::Passed(std::move(directory_paths))),
212 base::Bind(&PlatformAppPathLauncher::OnFilesInvalid, this)); 212 base::Bind(&PlatformAppPathLauncher::OnFilesInvalid, this));
213 return; 213 return;
214 } 214 }
215 215
216 OnFilesValid(std::move(directory_paths)); 216 OnFilesValid(std::move(directory_paths));
217 } 217 }
218 218
219 void OnAreDirectoriesAndMimeTypesCollected( 219 void OnAreDirectoriesAndMimeTypesCollected(
220 scoped_ptr<std::set<base::FilePath>> directory_paths, 220 std::unique_ptr<std::set<base::FilePath>> directory_paths,
221 scoped_ptr<std::vector<std::string>> mime_types) { 221 std::unique_ptr<std::vector<std::string>> mime_types) {
222 DCHECK(entry_paths_.size() == mime_types->size()); 222 DCHECK(entry_paths_.size() == mime_types->size());
223 // If fetching a mime type failed, then use a fallback one. 223 // If fetching a mime type failed, then use a fallback one.
224 for (size_t i = 0; i < entry_paths_.size(); ++i) { 224 for (size_t i = 0; i < entry_paths_.size(); ++i) {
225 const std::string mime_type = 225 const std::string mime_type =
226 !(*mime_types)[i].empty() ? (*mime_types)[i] : kFallbackMimeType; 226 !(*mime_types)[i].empty() ? (*mime_types)[i] : kFallbackMimeType;
227 bool is_directory = 227 bool is_directory =
228 directory_paths->find(entry_paths_[i]) != directory_paths->end(); 228 directory_paths->find(entry_paths_[i]) != directory_paths->end();
229 entries_.push_back( 229 entries_.push_back(
230 extensions::EntryInfo(entry_paths_[i], mime_type, is_directory)); 230 extensions::EntryInfo(entry_paths_[i], mime_type, is_directory));
231 } 231 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 void LaunchPlatformAppWithUrl(Profile* profile, 442 void LaunchPlatformAppWithUrl(Profile* profile,
443 const Extension* extension, 443 const Extension* extension,
444 const std::string& handler_id, 444 const std::string& handler_id,
445 const GURL& url, 445 const GURL& url,
446 const GURL& referrer_url) { 446 const GURL& referrer_url) {
447 AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl( 447 AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl(
448 profile, extension, handler_id, url, referrer_url); 448 profile, extension, handler_id, url, referrer_url);
449 } 449 }
450 450
451 } // namespace apps 451 } // namespace apps
OLDNEW
« no previous file with comments | « apps/custom_launcher_page_contents.cc ('k') | apps/saved_files_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698