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

Side by Side Diff: apps/launcher.cc

Issue 2272813003: 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, 4 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 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"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/strings/string_util.h" 17 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" 19 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
19 #include "chrome/browser/extensions/api/file_handlers/directory_util.h" 20 #include "chrome/browser/extensions/api/file_handlers/directory_util.h"
20 #include "chrome/browser/extensions/api/file_handlers/mime_util.h" 21 #include "chrome/browser/extensions/api/file_handlers/mime_util.h"
21 #include "chrome/browser/extensions/api/file_system/file_system_api.h" 22 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
22 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
23 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/render_process_host.h" 25 #include "content/public/browser/render_process_host.h"
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 } 197 }
197 198
198 void LaunchWithNoLaunchData() { 199 void LaunchWithNoLaunchData() {
199 // This method is required as an entry point on the UI thread. 200 // This method is required as an entry point on the UI thread.
200 DCHECK_CURRENTLY_ON(BrowserThread::UI); 201 DCHECK_CURRENTLY_ON(BrowserThread::UI);
201 202
202 const Extension* app = GetExtension(); 203 const Extension* app = GetExtension();
203 if (!app) 204 if (!app)
204 return; 205 return;
205 206
207 std::unique_ptr<app_runtime::LaunchData> launch_data =
208 base::MakeUnique<app_runtime::LaunchData>();
209 launch_data->action_data = std::move(action_data_);
210
206 AppRuntimeEventRouter::DispatchOnLaunchedEvent( 211 AppRuntimeEventRouter::DispatchOnLaunchedEvent(
207 profile_, app, launch_source_, std::move(action_data_)); 212 profile_, app, launch_source_, std::move(launch_data));
208 } 213 }
209 214
210 void OnAreDirectoriesCollected( 215 void OnAreDirectoriesCollected(
211 bool has_file_system_write_permission, 216 bool has_file_system_write_permission,
212 std::unique_ptr<std::set<base::FilePath>> directory_paths) { 217 std::unique_ptr<std::set<base::FilePath>> directory_paths) {
213 if (has_file_system_write_permission) { 218 if (has_file_system_write_permission) {
214 std::set<base::FilePath>* const directory_paths_ptr = 219 std::set<base::FilePath>* const directory_paths_ptr =
215 directory_paths.get(); 220 directory_paths.get();
216 PrepareFilesForWritableApp( 221 PrepareFilesForWritableApp(
217 entry_paths_, profile_, *directory_paths_ptr, 222 entry_paths_, profile_, *directory_paths_ptr,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 extensions::app_file_handler_util::MimeTypeCollector mime_type_collector_; 350 extensions::app_file_handler_util::MimeTypeCollector mime_type_collector_;
346 extensions::app_file_handler_util::IsDirectoryCollector 351 extensions::app_file_handler_util::IsDirectoryCollector
347 is_directory_collector_; 352 is_directory_collector_;
348 353
349 DISALLOW_COPY_AND_ASSIGN(PlatformAppPathLauncher); 354 DISALLOW_COPY_AND_ASSIGN(PlatformAppPathLauncher);
350 }; 355 };
351 356
352 } // namespace 357 } // namespace
353 358
354 void LaunchPlatformAppWithCommandLine(Profile* profile, 359 void LaunchPlatformAppWithCommandLine(Profile* profile,
355 const Extension* app, 360 const extensions::Extension* app,
356 const base::CommandLine& command_line, 361 const base::CommandLine& command_line,
357 const base::FilePath& current_directory, 362 const base::FilePath& current_directory,
358 extensions::AppLaunchSource source) { 363 extensions::AppLaunchSource source,
364 PlayStoreStatus play_store_status) {
359 // An app with "kiosk_only" should not be installed and launched 365 // An app with "kiosk_only" should not be installed and launched
360 // outside of ChromeOS kiosk mode in the first place. This is a defensive 366 // outside of ChromeOS kiosk mode in the first place. This is a defensive
361 // check in case this scenario does occur. 367 // check in case this scenario does occur.
362 if (extensions::KioskModeInfo::IsKioskOnly(app)) { 368 if (extensions::KioskModeInfo::IsKioskOnly(app)) {
363 bool in_kiosk_mode = false; 369 bool in_kiosk_mode = false;
364 #if defined(OS_CHROMEOS) 370 #if defined(OS_CHROMEOS)
365 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); 371 user_manager::UserManager* user_manager = user_manager::UserManager::Get();
366 in_kiosk_mode = user_manager && user_manager->IsLoggedInAsKioskApp(); 372 in_kiosk_mode = user_manager && user_manager->IsLoggedInAsKioskApp();
367 #endif 373 #endif
368 if (!in_kiosk_mode) { 374 if (!in_kiosk_mode) {
(...skipping 10 matching lines...) Expand all
379 #else 385 #else
380 base::CommandLine::StringType about_blank_url(url::kAboutBlankURL); 386 base::CommandLine::StringType about_blank_url(url::kAboutBlankURL);
381 #endif 387 #endif
382 base::CommandLine::StringVector args = command_line.GetArgs(); 388 base::CommandLine::StringVector args = command_line.GetArgs();
383 // Browser tests will add about:blank to the command line. This should 389 // Browser tests will add about:blank to the command line. This should
384 // never be interpreted as a file to open, as doing so with an app that 390 // never be interpreted as a file to open, as doing so with an app that
385 // has write access will result in a file 'about' being created, which 391 // has write access will result in a file 'about' being created, which
386 // causes problems on the bots. 392 // causes problems on the bots.
387 if (args.empty() || (command_line.HasSwitch(switches::kTestType) && 393 if (args.empty() || (command_line.HasSwitch(switches::kTestType) &&
388 args[0] == about_blank_url)) { 394 args[0] == about_blank_url)) {
389 AppRuntimeEventRouter::DispatchOnLaunchedEvent( 395 std::unique_ptr<app_runtime::LaunchData> launch_data =
390 profile, app, source, std::unique_ptr<app_runtime::ActionData>()); 396 base::MakeUnique<app_runtime::LaunchData>();
397 if (play_store_status != PlayStoreStatus::PLAY_STORE_STATUS_UNKNOWN)
398 launch_data->play_store_status = play_store_status;
xiyuan 2016/08/24 20:50:31 If this line is skipped (i.e. play_store_status =
rkc 2016/08/24 20:56:29 It ends up being 'undefined' in the app. I tested
399 AppRuntimeEventRouter::DispatchOnLaunchedEvent(profile, app, source,
400 std::move(launch_data));
391 return; 401 return;
392 } 402 }
393 403
394 base::FilePath file_path(command_line.GetArgs()[0]); 404 base::FilePath file_path(command_line.GetArgs()[0]);
395 scoped_refptr<PlatformAppPathLauncher> launcher = 405 scoped_refptr<PlatformAppPathLauncher> launcher =
396 new PlatformAppPathLauncher(profile, app, file_path); 406 new PlatformAppPathLauncher(profile, app, file_path);
397 launcher->LaunchWithRelativePath(current_directory); 407 launcher->LaunchWithRelativePath(current_directory);
398 } 408 }
399 409
400 void LaunchPlatformAppWithPath(Profile* profile, 410 void LaunchPlatformAppWithPath(Profile* profile,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 extensions::ExtensionPrefs* extension_prefs = 458 extensions::ExtensionPrefs* extension_prefs =
449 extensions::ExtensionPrefs::Get(profile); 459 extensions::ExtensionPrefs::Get(profile);
450 bool had_windows = extension_prefs->IsActive(app->id()); 460 bool had_windows = extension_prefs->IsActive(app->id());
451 extension_prefs->SetIsActive(app->id(), false); 461 extension_prefs->SetIsActive(app->id(), false);
452 bool listening_to_launch = event_router->ExtensionHasEventListener( 462 bool listening_to_launch = event_router->ExtensionHasEventListener(
453 app->id(), app_runtime::OnLaunched::kEventName); 463 app->id(), app_runtime::OnLaunched::kEventName);
454 464
455 if (listening_to_launch && had_windows) { 465 if (listening_to_launch && had_windows) {
456 AppRuntimeEventRouter::DispatchOnLaunchedEvent( 466 AppRuntimeEventRouter::DispatchOnLaunchedEvent(
457 profile, app, extensions::SOURCE_RESTART, 467 profile, app, extensions::SOURCE_RESTART,
458 std::unique_ptr<app_runtime::ActionData>()); 468 std::unique_ptr<app_runtime::LaunchData>());
459 } 469 }
460 } 470 }
461 471
462 void LaunchPlatformAppWithUrl(Profile* profile, 472 void LaunchPlatformAppWithUrl(Profile* profile,
463 const Extension* app, 473 const Extension* app,
464 const std::string& handler_id, 474 const std::string& handler_id,
465 const GURL& url, 475 const GURL& url,
466 const GURL& referrer_url) { 476 const GURL& referrer_url) {
467 AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl( 477 AppRuntimeEventRouter::DispatchOnLaunchedEventWithUrl(
468 profile, app, handler_id, url, referrer_url); 478 profile, app, handler_id, url, referrer_url);
469 } 479 }
470 480
471 } // namespace apps 481 } // namespace apps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698