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

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: 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 26 matching lines...) Expand all
37 #include "grit/chromium_strings.h" 37 #include "grit/chromium_strings.h"
38 #include "grit/generated_resources.h" 38 #include "grit/generated_resources.h"
39 #import "skia/ext/skia_utils_mac.h" 39 #import "skia/ext/skia_utils_mac.h"
40 #include "third_party/skia/include/core/SkBitmap.h" 40 #include "third_party/skia/include/core/SkBitmap.h"
41 #include "third_party/skia/include/core/SkColor.h" 41 #include "third_party/skia/include/core/SkColor.h"
42 #include "ui/base/l10n/l10n_util.h" 42 #include "ui/base/l10n/l10n_util.h"
43 #import "ui/base/l10n/l10n_util_mac.h" 43 #import "ui/base/l10n/l10n_util_mac.h"
44 #include "ui/base/resource/resource_bundle.h" 44 #include "ui/base/resource/resource_bundle.h"
45 #include "ui/gfx/image/image_family.h" 45 #include "ui/gfx/image/image_family.h"
46 46
47 bool g_app_shims_enable_internal_for_test = false;
48
47 namespace { 49 namespace {
48 50
49 // Launch Services Key to run as an agent app, which doesn't launch in the dock. 51 // Launch Services Key to run as an agent app, which doesn't launch in the dock.
50 NSString* const kLSUIElement = @"LSUIElement"; 52 NSString* const kLSUIElement = @"LSUIElement";
51 53
52 class ScopedCarbonHandle { 54 class ScopedCarbonHandle {
53 public: 55 public:
54 ScopedCarbonHandle(size_t initial_size) : handle_(NewHandle(initial_size)) { 56 ScopedCarbonHandle(size_t initial_size) : handle_(NewHandle(initial_size)) {
55 DCHECK(handle_); 57 DCHECK(handle_);
56 DCHECK_EQ(noErr, MemError()); 58 DCHECK_EQ(noErr, MemError());
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 inFileViewerRootedAtPath:nil]; 849 inFileViewerRootedAtPath:nil];
848 } 850 }
849 851
850 base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info) { 852 base::FilePath GetAppInstallPath(const ShortcutInfo& shortcut_info) {
851 WebAppShortcutCreator shortcut_creator( 853 WebAppShortcutCreator shortcut_creator(
852 base::FilePath(), shortcut_info, extensions::FileHandlersInfo()); 854 base::FilePath(), shortcut_info, extensions::FileHandlersInfo());
853 return shortcut_creator.GetApplicationsShortcutPath(); 855 return shortcut_creator.GetApplicationsShortcutPath();
854 } 856 }
855 857
856 void MaybeLaunchShortcut(const ShortcutInfo& shortcut_info) { 858 void MaybeLaunchShortcut(const ShortcutInfo& shortcut_info) {
857 if (AppShimsDisabledForTest()) 859 if (AppShimsDisabledForTest() && !g_app_shims_enable_internal_for_test)
858 return; 860 return;
859 861
860 content::BrowserThread::PostTask( 862 content::BrowserThread::PostTask(
861 content::BrowserThread::FILE, FROM_HERE, 863 content::BrowserThread::FILE, FROM_HERE,
862 base::Bind(&LaunchShimOnFileThread, shortcut_info)); 864 base::Bind(&LaunchShimOnFileThread, shortcut_info));
863 } 865 }
864 866
865 // Called when the app's ShortcutInfo (with icon) is loaded when creating app 867 // Called when the app's ShortcutInfo (with icon) is loaded when creating app
866 // shortcuts. 868 // shortcuts.
867 void CreateAppShortcutInfoLoaded( 869 void CreateAppShortcutInfoLoaded(
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 919
918 namespace internals { 920 namespace internals {
919 921
920 bool CreatePlatformShortcuts( 922 bool CreatePlatformShortcuts(
921 const base::FilePath& app_data_path, 923 const base::FilePath& app_data_path,
922 const ShortcutInfo& shortcut_info, 924 const ShortcutInfo& shortcut_info,
923 const extensions::FileHandlersInfo& file_handlers_info, 925 const extensions::FileHandlersInfo& file_handlers_info,
924 const ShortcutLocations& creation_locations, 926 const ShortcutLocations& creation_locations,
925 ShortcutCreationReason creation_reason) { 927 ShortcutCreationReason creation_reason) {
926 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 928 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
927 if (AppShimsDisabledForTest()) 929 if (AppShimsDisabledForTest())
tapted 2014/06/03 07:32:39 should this one be guarded too? (or perhaps commen
jackhou1 2014/06/04 06:55:40 Done.
928 return true; 930 return true;
929 931
930 WebAppShortcutCreator shortcut_creator( 932 WebAppShortcutCreator shortcut_creator(
931 app_data_path, shortcut_info, file_handlers_info); 933 app_data_path, shortcut_info, file_handlers_info);
932 return shortcut_creator.CreateShortcuts(creation_reason, creation_locations); 934 return shortcut_creator.CreateShortcuts(creation_reason, creation_locations);
933 } 935 }
934 936
935 void DeletePlatformShortcuts(const base::FilePath& app_data_path, 937 void DeletePlatformShortcuts(const base::FilePath& app_data_path,
936 const ShortcutInfo& shortcut_info) { 938 const ShortcutInfo& shortcut_info) {
937 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 939 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
938 WebAppShortcutCreator shortcut_creator( 940 WebAppShortcutCreator shortcut_creator(
939 app_data_path, shortcut_info, extensions::FileHandlersInfo()); 941 app_data_path, shortcut_info, extensions::FileHandlersInfo());
940 shortcut_creator.DeleteShortcuts(); 942 shortcut_creator.DeleteShortcuts();
941 } 943 }
942 944
943 void UpdatePlatformShortcuts( 945 void UpdatePlatformShortcuts(
944 const base::FilePath& app_data_path, 946 const base::FilePath& app_data_path,
945 const base::string16& old_app_title, 947 const base::string16& old_app_title,
946 const ShortcutInfo& shortcut_info, 948 const ShortcutInfo& shortcut_info,
947 const extensions::FileHandlersInfo& file_handlers_info) { 949 const extensions::FileHandlersInfo& file_handlers_info) {
948 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE)); 950 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::FILE));
949 if (AppShimsDisabledForTest()) 951 if (AppShimsDisabledForTest() && !g_app_shims_enable_internal_for_test)
950 return; 952 return;
951 953
952 WebAppShortcutCreator shortcut_creator( 954 WebAppShortcutCreator shortcut_creator(
953 app_data_path, shortcut_info, file_handlers_info); 955 app_data_path, shortcut_info, file_handlers_info);
954 shortcut_creator.UpdateShortcuts(); 956 shortcut_creator.UpdateShortcuts();
955 } 957 }
956 958
957 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) { 959 void DeleteAllShortcutsForProfile(const base::FilePath& profile_path) {
958 const std::string profile_base_name = profile_path.BaseName().value(); 960 const std::string profile_base_name = profile_path.BaseName().value();
959 std::vector<base::FilePath> bundles = GetAllAppBundlesInPath( 961 std::vector<base::FilePath> bundles = GetAllAppBundlesInPath(
(...skipping 23 matching lines...) Expand all
983 web_app::UpdateShortcutInfoAndIconForApp( 985 web_app::UpdateShortcutInfoAndIconForApp(
984 app, 986 app,
985 profile, 987 profile,
986 base::Bind(&web_app::CreateAppShortcutInfoLoaded, 988 base::Bind(&web_app::CreateAppShortcutInfoLoaded,
987 profile, 989 profile,
988 app, 990 app,
989 close_callback)); 991 close_callback));
990 } 992 }
991 993
992 } // namespace chrome 994 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698