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

Side by Side Diff: apps/launcher.cc

Issue 2276293002: Revert of Add ARC++ specific fields to launch data for specific apps. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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/launcher.h ('k') | chrome/browser/apps/app_launch_for_metro_restart_win.cc » ('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 <memory>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/files/file_util.h" 13 #include "base/files/file_util.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/ptr_util.h"
16 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.h"
17 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
19 #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"
20 #include "chrome/browser/extensions/api/file_handlers/directory_util.h" 19 #include "chrome/browser/extensions/api/file_handlers/directory_util.h"
21 #include "chrome/browser/extensions/api/file_handlers/mime_util.h" 20 #include "chrome/browser/extensions/api/file_handlers/mime_util.h"
22 #include "chrome/browser/extensions/api/file_system/file_system_api.h" 21 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
23 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
24 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
25 #include "content/public/browser/render_process_host.h" 24 #include "content/public/browser/render_process_host.h"
(...skipping 16 matching lines...) Expand all
42 #include "url/gurl.h" 41 #include "url/gurl.h"
43 42
44 #if defined(OS_CHROMEOS) 43 #if defined(OS_CHROMEOS)
45 #include "components/user_manager/user_manager.h" 44 #include "components/user_manager/user_manager.h"
46 #endif 45 #endif
47 46
48 namespace app_runtime = extensions::api::app_runtime; 47 namespace app_runtime = extensions::api::app_runtime;
49 48
50 using content::BrowserThread; 49 using content::BrowserThread;
51 using extensions::AppRuntimeEventRouter; 50 using extensions::AppRuntimeEventRouter;
52 using extensions::api::app_runtime::PlayStoreStatus;
53 using extensions::app_file_handler_util::CreateFileEntry; 51 using extensions::app_file_handler_util::CreateFileEntry;
54 using extensions::app_file_handler_util::FileHandlerCanHandleEntry; 52 using extensions::app_file_handler_util::FileHandlerCanHandleEntry;
55 using extensions::app_file_handler_util::FileHandlerForId; 53 using extensions::app_file_handler_util::FileHandlerForId;
56 using extensions::app_file_handler_util::FirstFileHandlerForEntry; 54 using extensions::app_file_handler_util::FirstFileHandlerForEntry;
57 using extensions::app_file_handler_util::HasFileSystemWritePermission; 55 using extensions::app_file_handler_util::HasFileSystemWritePermission;
58 using extensions::app_file_handler_util::PrepareFilesForWritableApp; 56 using extensions::app_file_handler_util::PrepareFilesForWritableApp;
59 using extensions::EventRouter; 57 using extensions::EventRouter;
60 using extensions::Extension; 58 using extensions::Extension;
61 using extensions::ExtensionHost; 59 using extensions::ExtensionHost;
62 using extensions::GrantedFileEntry; 60 using extensions::GrantedFileEntry;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 196 }
199 197
200 void LaunchWithNoLaunchData() { 198 void LaunchWithNoLaunchData() {
201 // This method is required as an entry point on the UI thread. 199 // This method is required as an entry point on the UI thread.
202 DCHECK_CURRENTLY_ON(BrowserThread::UI); 200 DCHECK_CURRENTLY_ON(BrowserThread::UI);
203 201
204 const Extension* app = GetExtension(); 202 const Extension* app = GetExtension();
205 if (!app) 203 if (!app)
206 return; 204 return;
207 205
208 std::unique_ptr<app_runtime::LaunchData> launch_data =
209 base::MakeUnique<app_runtime::LaunchData>();
210 launch_data->action_data = std::move(action_data_);
211
212 AppRuntimeEventRouter::DispatchOnLaunchedEvent( 206 AppRuntimeEventRouter::DispatchOnLaunchedEvent(
213 profile_, app, launch_source_, std::move(launch_data)); 207 profile_, app, launch_source_, std::move(action_data_));
214 } 208 }
215 209
216 void OnAreDirectoriesCollected( 210 void OnAreDirectoriesCollected(
217 bool has_file_system_write_permission, 211 bool has_file_system_write_permission,
218 std::unique_ptr<std::set<base::FilePath>> directory_paths) { 212 std::unique_ptr<std::set<base::FilePath>> directory_paths) {
219 if (has_file_system_write_permission) { 213 if (has_file_system_write_permission) {
220 std::set<base::FilePath>* const directory_paths_ptr = 214 std::set<base::FilePath>* const directory_paths_ptr =
221 directory_paths.get(); 215 directory_paths.get();
222 PrepareFilesForWritableApp( 216 PrepareFilesForWritableApp(
223 entry_paths_, profile_, *directory_paths_ptr, 217 entry_paths_, profile_, *directory_paths_ptr,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 extensions::app_file_handler_util::MimeTypeCollector mime_type_collector_; 345 extensions::app_file_handler_util::MimeTypeCollector mime_type_collector_;
352 extensions::app_file_handler_util::IsDirectoryCollector 346 extensions::app_file_handler_util::IsDirectoryCollector
353 is_directory_collector_; 347 is_directory_collector_;
354 348
355 DISALLOW_COPY_AND_ASSIGN(PlatformAppPathLauncher); 349 DISALLOW_COPY_AND_ASSIGN(PlatformAppPathLauncher);
356 }; 350 };
357 351
358 } // namespace 352 } // namespace
359 353
360 void LaunchPlatformAppWithCommandLine(Profile* profile, 354 void LaunchPlatformAppWithCommandLine(Profile* profile,
361 const extensions::Extension* app, 355 const Extension* app,
362 const base::CommandLine& command_line, 356 const base::CommandLine& command_line,
363 const base::FilePath& current_directory, 357 const base::FilePath& current_directory,
364 extensions::AppLaunchSource source, 358 extensions::AppLaunchSource source) {
365 PlayStoreStatus play_store_status) {
366 // An app with "kiosk_only" should not be installed and launched 359 // An app with "kiosk_only" should not be installed and launched
367 // outside of ChromeOS kiosk mode in the first place. This is a defensive 360 // outside of ChromeOS kiosk mode in the first place. This is a defensive
368 // check in case this scenario does occur. 361 // check in case this scenario does occur.
369 if (extensions::KioskModeInfo::IsKioskOnly(app)) { 362 if (extensions::KioskModeInfo::IsKioskOnly(app)) {
370 bool in_kiosk_mode = false; 363 bool in_kiosk_mode = false;
371 #if defined(OS_CHROMEOS) 364 #if defined(OS_CHROMEOS)
372 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 365 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
373 in_kiosk_mode = user_manager && user_manager->IsLoggedInAsKioskApp(); 366 in_kiosk_mode = user_manager && user_manager->IsLoggedInAsKioskApp();
374 #endif 367 #endif
375 if (!in_kiosk_mode) { 368 if (!in_kiosk_mode) {
(...skipping 10 matching lines...) Expand all
386 #else 379 #else
387 base::CommandLine::StringType about_blank_url(url::kAboutBlankURL); 380 base::CommandLine::StringType about_blank_url(url::kAboutBlankURL);
388 #endif 381 #endif
389 base::CommandLine::StringVector args = command_line.GetArgs(); 382 base::CommandLine::StringVector args = command_line.GetArgs();
390 // Browser tests will add about:blank to the command line. This should 383 // Browser tests will add about:blank to the command line. This should
391 // never be interpreted as a file to open, as doing so with an app that 384 // never be interpreted as a file to open, as doing so with an app that
392 // has write access will result in a file 'about' being created, which 385 // has write access will result in a file 'about' being created, which
393 // causes problems on the bots. 386 // causes problems on the bots.
394 if (args.empty() || (command_line.HasSwitch(switches::kTestType) && 387 if (args.empty() || (command_line.HasSwitch(switches::kTestType) &&
395 args[0] == about_blank_url)) { 388 args[0] == about_blank_url)) {
396 std::unique_ptr<app_runtime::LaunchData> launch_data = 389 AppRuntimeEventRouter::DispatchOnLaunchedEvent(
397 base::MakeUnique<app_runtime::LaunchData>(); 390 profile, app, source, std::unique_ptr<app_runtime::ActionData>());
398 if (play_store_status != PlayStoreStatus::PLAY_STORE_STATUS_UNKNOWN)
399 launch_data->play_store_status = play_store_status;
400 AppRuntimeEventRouter::DispatchOnLaunchedEvent(profile, app, source,
401 std::move(launch_data));
402 return; 391 return;
403 } 392 }
404 393
405 base::FilePath file_path(command_line.GetArgs()[0]); 394 base::FilePath file_path(command_line.GetArgs()[0]);
406 scoped_refptr<PlatformAppPathLauncher> launcher = 395 scoped_refptr<PlatformAppPathLauncher> launcher =
407 new PlatformAppPathLauncher(profile, app, file_path); 396 new PlatformAppPathLauncher(profile, app, file_path);
408 launcher->LaunchWithRelativePath(current_directory); 397 launcher->LaunchWithRelativePath(current_directory);
409 } 398 }
410 399
411 void LaunchPlatformAppWithPath(Profile* profile, 400 void LaunchPlatformAppWithPath(Profile* profile,
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 447
459 extensions::ExtensionPrefs* extension_prefs = 448 extensions::ExtensionPrefs* extension_prefs =
460 extensions::ExtensionPrefs::Get(profile); 449 extensions::ExtensionPrefs::Get(profile);
461 bool had_windows = extension_prefs->IsActive(app->id()); 450 bool had_windows = extension_prefs->IsActive(app->id());
462 extension_prefs->SetIsActive(app->id(), false); 451 extension_prefs->SetIsActive(app->id(), false);
463 bool listening_to_launch = event_router->ExtensionHasEventListener( 452 bool listening_to_launch = event_router->ExtensionHasEventListener(
464 app->id(), app_runtime::OnLaunched::kEventName); 453 app->id(), app_runtime::OnLaunched::kEventName);
465 454
466 if (listening_to_launch && had_windows) { 455 if (listening_to_launch && had_windows) {
467 AppRuntimeEventRouter::DispatchOnLaunchedEvent( 456 AppRuntimeEventRouter::DispatchOnLaunchedEvent(
468 profile, app, extensions::SOURCE_RESTART, nullptr); 457 profile, app, extensions::SOURCE_RESTART,
458 std::unique_ptr<app_runtime::ActionData>());
469 } 459 }
470 } 460 }
471 461
472 void LaunchPlatformAppWithUrl(Profile* profile, 462 void LaunchPlatformAppWithUrl(Profile* profile,
473 const Extension* app, 463 const Extension* app,
474 const std::string& handler_id, 464 const std::string& handler_id,
475 const GURL& url, 465 const GURL& url,
476 const GURL& referrer_url) { 466 const GURL& referrer_url) {
477 AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl( 467 AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl(
478 profile, app, handler_id, url, referrer_url); 468 profile, app, handler_id, url, referrer_url);
479 } 469 }
480 470
481 } // namespace apps 471 } // namespace apps
OLDNEW
« no previous file with comments | « apps/launcher.h ('k') | chrome/browser/apps/app_launch_for_metro_restart_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698