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

Side by Side Diff: chrome/browser/apps/app_shim/app_shim_interactive_uitest_mac.mm

Issue 1038573002: Fixed thread-unsafe use of gfx::Image in app shortcut creation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 #include <vector> 6 #include <vector>
7 7
8 #include "apps/app_lifetime_monitor_factory.h" 8 #include "apps/app_lifetime_monitor_factory.h"
9 #include "apps/switches.h" 9 #include "apps/switches.h"
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 bool HasAppShimHost(Profile* profile, const std::string& app_id) { 258 bool HasAppShimHost(Profile* profile, const std::string& app_id) {
259 return g_browser_process->platform_part() 259 return g_browser_process->platform_part()
260 ->app_shim_host_manager() 260 ->app_shim_host_manager()
261 ->extension_app_shim_handler() 261 ->extension_app_shim_handler()
262 ->FindHost(profile, app_id); 262 ->FindHost(profile, app_id);
263 } 263 }
264 264
265 base::FilePath GetAppShimPath(Profile* profile, 265 base::FilePath GetAppShimPath(Profile* profile,
266 const extensions::Extension* app) { 266 const extensions::Extension* app) {
267 // Use a WebAppShortcutCreator to get the path. 267 // Use a WebAppShortcutCreator to get the path.
268 scoped_ptr<web_app::ShortcutInfo> shortcut_info =
269 web_app::ShortcutInfoForExtensionAndProfile(app, profile);
268 web_app::WebAppShortcutCreator shortcut_creator( 270 web_app::WebAppShortcutCreator shortcut_creator(
269 web_app::GetWebAppDataDirectory(profile->GetPath(), app->id(), GURL()), 271 web_app::GetWebAppDataDirectory(profile->GetPath(), app->id(), GURL()),
270 web_app::ShortcutInfoForExtensionAndProfile(app, profile), 272 *shortcut_info, extensions::FileHandlersInfo());
271 extensions::FileHandlersInfo());
272 return shortcut_creator.GetInternalShortcutPath(); 273 return shortcut_creator.GetInternalShortcutPath();
273 } 274 }
274 275
275 void UpdateAppAndAwaitShimCreation(Profile* profile, 276 void UpdateAppAndAwaitShimCreation(Profile* profile,
276 const extensions::Extension* app, 277 const extensions::Extension* app,
277 const base::FilePath& shim_path) { 278 const base::FilePath& shim_path) {
278 // Create the internal app shim by simulating an app update. FilePathWatcher 279 // Create the internal app shim by simulating an app update. FilePathWatcher
279 // is used to wait for file operations on the shim to be finished before 280 // is used to wait for file operations on the shim to be finished before
280 // attempting to launch it. Since all of the file operations are done in the 281 // attempting to launch it. Since all of the file operations are done in the
281 // same event on the FILE thread, everything will be done by the time the 282 // same event on the FILE thread, everything will be done by the time the
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 base::FilePath test_data_dir; 643 base::FilePath test_data_dir;
643 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); 644 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir);
644 base::FilePath shim_path_32 = 645 base::FilePath shim_path_32 =
645 test_data_dir.Append("app_shim").Append("app_shim_32_bit.app"); 646 test_data_dir.Append("app_shim").Append("app_shim_32_bit.app");
646 EXPECT_TRUE(base::PathExists(shim_path_32)); 647 EXPECT_TRUE(base::PathExists(shim_path_32));
647 648
648 // Install test app. 649 // Install test app.
649 const extensions::Extension* app = InstallPlatformApp("minimal"); 650 const extensions::Extension* app = InstallPlatformApp("minimal");
650 651
651 // Use WebAppShortcutCreator to create a 64 bit shim. 652 // Use WebAppShortcutCreator to create a 64 bit shim.
653 scoped_ptr<web_app::ShortcutInfo> shortcut_info =
654 web_app::ShortcutInfoForExtensionAndProfile(app, profile());
652 web_app::WebAppShortcutCreator shortcut_creator( 655 web_app::WebAppShortcutCreator shortcut_creator(
653 web_app::GetWebAppDataDirectory(profile()->GetPath(), app->id(), GURL()), 656 web_app::GetWebAppDataDirectory(profile()->GetPath(), app->id(), GURL()),
654 web_app::ShortcutInfoForExtensionAndProfile(app, profile()), 657 *shortcut_info, extensions::FileHandlersInfo());
655 extensions::FileHandlersInfo());
656 shortcut_creator.UpdateShortcuts(); 658 shortcut_creator.UpdateShortcuts();
657 base::FilePath shim_path = shortcut_creator.GetInternalShortcutPath(); 659 base::FilePath shim_path = shortcut_creator.GetInternalShortcutPath();
658 NSMutableDictionary* plist_64 = [NSMutableDictionary 660 NSMutableDictionary* plist_64 = [NSMutableDictionary
659 dictionaryWithContentsOfFile:base::mac::FilePathToNSString( 661 dictionaryWithContentsOfFile:base::mac::FilePathToNSString(
660 shim_path.Append("Contents").Append("Info.plist"))]; 662 shim_path.Append("Contents").Append("Info.plist"))];
661 663
662 // Copy 32 bit shim to where it's expected to be. 664 // Copy 32 bit shim to where it's expected to be.
663 // CopyDirectory doesn't seem to work when copying and renaming in one go. 665 // CopyDirectory doesn't seem to work when copying and renaming in one go.
664 ASSERT_TRUE(base::DeleteFile(shim_path, true)); 666 ASSERT_TRUE(base::DeleteFile(shim_path, true));
665 ASSERT_TRUE(base::PathExists(shim_path.DirName())); 667 ASSERT_TRUE(base::PathExists(shim_path.DirName()));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 // the shim is rebuilt. 717 // the shim is rebuilt.
716 WindowedAppShimLaunchObserver(app->id()).Wait(); 718 WindowedAppShimLaunchObserver(app->id()).Wait();
717 719
718 EXPECT_TRUE(GetFirstAppWindow()); 720 EXPECT_TRUE(GetFirstAppWindow());
719 EXPECT_TRUE(HasAppShimHost(profile(), app->id())); 721 EXPECT_TRUE(HasAppShimHost(profile(), app->id()));
720 } 722 }
721 723
722 #endif // defined(ARCH_CPU_64_BITS) 724 #endif // defined(ARCH_CPU_64_BITS)
723 725
724 } // namespace apps 726 } // namespace apps
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698