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

Side by Side Diff: chrome/browser/web_applications/web_app_mac.mm

Issue 316493002: [Mac] Add interactive App Shim test. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Disable quarantine on app shims. Created 6 years, 6 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 | Annotate | Revision Log
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 #import "chrome/browser/web_applications/web_app_mac.h" 5 #import "chrome/browser/web_applications/web_app_mac.h"
6 6
7 #import <Carbon/Carbon.h> 7 #import <Carbon/Carbon.h>
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 29 matching lines...) Expand all
40 #include "grit/chromium_strings.h" 40 #include "grit/chromium_strings.h"
41 #include "grit/generated_resources.h" 41 #include "grit/generated_resources.h"
42 #import "skia/ext/skia_utils_mac.h" 42 #import "skia/ext/skia_utils_mac.h"
43 #include "third_party/skia/include/core/SkBitmap.h" 43 #include "third_party/skia/include/core/SkBitmap.h"
44 #include "third_party/skia/include/core/SkColor.h" 44 #include "third_party/skia/include/core/SkColor.h"
45 #include "ui/base/l10n/l10n_util.h" 45 #include "ui/base/l10n/l10n_util.h"
46 #import "ui/base/l10n/l10n_util_mac.h" 46 #import "ui/base/l10n/l10n_util_mac.h"
47 #include "ui/base/resource/resource_bundle.h" 47 #include "ui/base/resource/resource_bundle.h"
48 #include "ui/gfx/image/image_family.h" 48 #include "ui/gfx/image/image_family.h"
49 49
50 bool g_app_shims_allow_update_and_launch_in_tests = false;
51
50 namespace { 52 namespace {
51 53
52 // Launch Services Key to run as an agent app, which doesn't launch in the dock. 54 // Launch Services Key to run as an agent app, which doesn't launch in the dock.
53 NSString* const kLSUIElement = @"LSUIElement"; 55 NSString* const kLSUIElement = @"LSUIElement";
54 56
55 class ScopedCarbonHandle { 57 class ScopedCarbonHandle {
56 public: 58 public:
57 ScopedCarbonHandle(size_t initial_size) : handle_(NewHandle(initial_size)) { 59 ScopedCarbonHandle(size_t initial_size) : handle_(NewHandle(initial_size)) {
58 DCHECK(handle_); 60 DCHECK(handle_);
59 DCHECK_EQ(noErr, MemError()); 61 DCHECK_EQ(noErr, MemError());
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 LOG(ERROR) << "Creating directory " << dst_path.value() << " failed."; 559 LOG(ERROR) << "Creating directory " << dst_path.value() << " failed.";
558 return succeeded; 560 return succeeded;
559 } 561 }
560 562
561 if (!base::CopyDirectory(staging_path, dst_path, true)) { 563 if (!base::CopyDirectory(staging_path, dst_path, true)) {
562 LOG(ERROR) << "Copying app to dst path: " << dst_path.value() 564 LOG(ERROR) << "Copying app to dst path: " << dst_path.value()
563 << " failed"; 565 << " failed";
564 return succeeded; 566 return succeeded;
565 } 567 }
566 568
567 base::mac::RemoveQuarantineAttribute(dst_path.Append(app_name)); 569 base::mac::RemoveQuarantineAttribute(
570 dst_path.Append(app_name)
571 .Append("Contents").Append("MacOS").Append("app_mode_loader"));
tapted 2014/06/12 05:19:22 Cool - I think this makes more sense. (although wh
Robert Sesek 2014/06/13 17:58:41 I thought the quarantine bit was set on the bundle
jackhou1 2014/06/14 01:16:37 If I comment out the RemoveQuarantineAttribute and
568 ++succeeded; 572 ++succeeded;
569 } 573 }
570 574
571 return succeeded; 575 return succeeded;
572 } 576 }
573 577
574 bool WebAppShortcutCreator::CreateShortcuts( 578 bool WebAppShortcutCreator::CreateShortcuts(
575 ShortcutCreationReason creation_reason, 579 ShortcutCreationReason creation_reason,
576 ShortcutLocations creation_locations) { 580 ShortcutLocations creation_locations) {
577 const base::FilePath applications_dir = GetApplicationsDirname(); 581 const base::FilePath applications_dir = GetApplicationsDirname();
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 inFileViewerRootedAtPath:nil]; 860 inFileViewerRootedAtPath:nil];
857 } 861 }
858 862
859 base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info) { 863 base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info) {
860 WebAppShortcutCreator shortcut_creator( 864 WebAppShortcutCreator shortcut_creator(
861 base::FilePath(), shortcut_info, extensions::FileHandlersInfo()); 865 base::FilePath(), shortcut_info, extensions::FileHandlersInfo());
862 return shortcut_creator.GetApplicationsShortcutPath(); 866 return shortcut_creator.GetApplicationsShortcutPath();
863 } 867 }
864 868
865 void MaybeLaunchShortcut(const ShortcutInfo& shortcut_info) { 869 void MaybeLaunchShortcut(const ShortcutInfo& shortcut_info) {
866 if (AppShimsDisabledForTest()) 870 if (AppShimsDisabledForTest() &&
871 !g_app_shims_allow_update_and_launch_in_tests) {
867 return; 872 return;
873 }
868 874
869 content::BrowserThread::PostTask( 875 content::BrowserThread::PostTask(
870 content::BrowserThread::FILE, FROM_HERE, 876 content::BrowserThread::FILE, FROM_HERE,
871 base::Bind(&LaunchShimOnFileThread, shortcut_info)); 877 base::Bind(&LaunchShimOnFileThread, shortcut_info));
872 } 878 }
873 879
874 // Called when the app's ShortcutInfo (with icon) is loaded when creating app 880 // Called when the app's ShortcutInfo (with icon) is loaded when creating app
875 // shortcuts. 881 // shortcuts.
876 void CreateAppShortcutInfoLoaded( 882 void CreateAppShortcutInfoLoaded(
877 Profile* profile, 883 Profile* profile,
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 app_data_path, shortcut_info, extensions::FileHandlersInfo()); 975 app_data_path, shortcut_info, extensions::FileHandlersInfo());
970 shortcut_creator.DeleteShortcuts(); 976 shortcut_creator.DeleteShortcuts();
971 } 977 }
972 978
973 void UpdatePlatformShortcuts( 979 void UpdatePlatformShortcuts(
974 const base::FilePath& app_data_path, 980 const base::FilePath& app_data_path,
975 const base::string16& old_app_title, 981 const base::string16& old_app_title,
976 const ShortcutInfo& shortcut_info, 982 const ShortcutInfo& shortcut_info,
977 const extensions::FileHandlersInfo& file_handlers_info) { 983 const extensions::FileHandlersInfo& file_handlers_info) {
978 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 984 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
979 if (AppShimsDisabledForTest()) 985 if (AppShimsDisabledForTest() &&
986 !g_app_shims_allow_update_and_launch_in_tests) {
980 return; 987 return;
988 }
981 989
982 WebAppShortcutCreator shortcut_creator( 990 WebAppShortcutCreator shortcut_creator(
983 app_data_path, shortcut_info, file_handlers_info); 991 app_data_path, shortcut_info, file_handlers_info);
984 shortcut_creator.UpdateShortcuts(); 992 shortcut_creator.UpdateShortcuts();
985 } 993 }
986 994
987 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { 995 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) {
988 const std::string profile_base_name = profile_path.BaseName().value(); 996 const std::string profile_base_name = profile_path.BaseName().value();
989 std::vector<base::FilePath> bundles = GetAllAppBundlesInPath( 997 std::vector<base::FilePath> bundles = GetAllAppBundlesInPath(
990 profile_path.Append(chrome::kWebAppDirname), profile_base_name); 998 profile_path.Append(chrome::kWebAppDirname), profile_base_name);
(...skipping 22 matching lines...) Expand all
1013 web_app::UpdateShortcutInfoAndIconForApp( 1021 web_app::UpdateShortcutInfoAndIconForApp(
1014 app, 1022 app,
1015 profile, 1023 profile,
1016 base::Bind(&web_app::CreateAppShortcutInfoLoaded, 1024 base::Bind(&web_app::CreateAppShortcutInfoLoaded,
1017 profile, 1025 profile,
1018 app, 1026 app,
1019 close_callback)); 1027 close_callback));
1020 } 1028 }
1021 1029
1022 } // namespace chrome 1030 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698