From 1664c3fbf0bcd7e2473a4cee269ac32d553fa4dd Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Sat, 7 May 2016 01:54:44 -0400 Subject: [PATCH] Added and configured iOS Extension project with ExtensionPreprocessingJS for webpage analysis. --- bitwarden-mobile.sln | 35 ++++++ src/iOS.Extension/ActionViewController.cs | 59 +++++++++ .../ActionViewController.designer.cs | 24 ++++ src/iOS.Extension/AppDelegate.cs | 46 +++++++ src/iOS.Extension/Entitlements.plist | 5 + src/iOS.Extension/Info.plist | 63 ++++++++++ src/iOS.Extension/Main.cs | 15 +++ src/iOS.Extension/MainInterface.storyboard | 63 ++++++++++ src/iOS.Extension/Properties/AssemblyInfo.cs | 35 ++++++ src/iOS.Extension/extension.js | 16 +++ src/iOS.Extension/iOS.Extension.csproj | 113 ++++++++++++++++++ src/iOS/iOS.csproj | 6 + 12 files changed, 480 insertions(+) create mode 100644 src/iOS.Extension/ActionViewController.cs create mode 100644 src/iOS.Extension/ActionViewController.designer.cs create mode 100644 src/iOS.Extension/AppDelegate.cs create mode 100644 src/iOS.Extension/Entitlements.plist create mode 100644 src/iOS.Extension/Info.plist create mode 100644 src/iOS.Extension/Main.cs create mode 100644 src/iOS.Extension/MainInterface.storyboard create mode 100644 src/iOS.Extension/Properties/AssemblyInfo.cs create mode 100644 src/iOS.Extension/extension.js create mode 100644 src/iOS.Extension/iOS.Extension.csproj diff --git a/bitwarden-mobile.sln b/bitwarden-mobile.sln index ed7bf28d4..00fc1b9bb 100644 --- a/bitwarden-mobile.sln +++ b/bitwarden-mobile.sln @@ -15,6 +15,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{EC730FD9-F62 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App.Test", "test\App.Test\App.Test.csproj", "{A300DCE1-8D10-4267-B96A-CB01AEB7C220}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "iOS.Extension", "src\iOS.Extension\iOS.Extension.csproj", "{32F5A2D6-F54D-4DA1-AE26-0A980D48F422}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Ad-Hoc|Any CPU = Ad-Hoc|Any CPU @@ -243,6 +245,38 @@ Global {A300DCE1-8D10-4267-B96A-CB01AEB7C220}.Release|x64.Build.0 = Release|Any CPU {A300DCE1-8D10-4267-B96A-CB01AEB7C220}.Release|x86.ActiveCfg = Release|Any CPU {A300DCE1-8D10-4267-B96A-CB01AEB7C220}.Release|x86.Build.0 = Release|Any CPU + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Ad-Hoc|Any CPU.ActiveCfg = Ad-Hoc|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Ad-Hoc|ARM.ActiveCfg = Ad-Hoc|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Ad-Hoc|iPhoneSimulator + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Ad-Hoc|iPhoneSimulator.Build.0 = Ad-Hoc|iPhoneSimulator + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Ad-Hoc|x64.ActiveCfg = Ad-Hoc|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Ad-Hoc|x86.ActiveCfg = Ad-Hoc|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.AppStore|Any CPU.ActiveCfg = AppStore|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.AppStore|ARM.ActiveCfg = AppStore|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.AppStore|iPhone.ActiveCfg = AppStore|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.AppStore|iPhone.Build.0 = AppStore|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.AppStore|iPhoneSimulator.ActiveCfg = AppStore|iPhoneSimulator + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.AppStore|iPhoneSimulator.Build.0 = AppStore|iPhoneSimulator + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.AppStore|x64.ActiveCfg = AppStore|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.AppStore|x86.ActiveCfg = AppStore|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Debug|Any CPU.ActiveCfg = Debug|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Debug|ARM.ActiveCfg = Debug|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Debug|iPhone.ActiveCfg = Debug|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Debug|iPhone.Build.0 = Debug|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Debug|x64.ActiveCfg = Debug|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Debug|x86.ActiveCfg = Debug|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Release|Any CPU.ActiveCfg = Release|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Release|ARM.ActiveCfg = Release|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Release|iPhone.ActiveCfg = Release|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Release|iPhone.Build.0 = Release|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Release|x64.ActiveCfg = Release|iPhone + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422}.Release|x86.ActiveCfg = Release|iPhone EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -252,5 +286,6 @@ Global {1F78403F-9A28-405B-9289-B9DBEB55F074} = {EC730FD9-F623-4B6C-B503-95CDCFBCF277} {B490C5DA-639E-4994-ABD2-54222B8A348E} = {EC730FD9-F623-4B6C-B503-95CDCFBCF277} {A300DCE1-8D10-4267-B96A-CB01AEB7C220} = {0D790714-ECF8-4A83-BE4A-E9C84DD1BB5D} + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422} = {EC730FD9-F623-4B6C-B503-95CDCFBCF277} EndGlobalSection EndGlobal diff --git a/src/iOS.Extension/ActionViewController.cs b/src/iOS.Extension/ActionViewController.cs new file mode 100644 index 000000000..41265508e --- /dev/null +++ b/src/iOS.Extension/ActionViewController.cs @@ -0,0 +1,59 @@ +using System; + +using MobileCoreServices; +using Foundation; +using UIKit; + +namespace Bit.iOS.Extension +{ + public partial class ActionViewController : UIViewController + { + public ActionViewController(IntPtr handle) : base(handle) + { + } + + public string Content { get; set; } + public Uri Uri { get; set; } + + public override void DidReceiveMemoryWarning() + { + base.DidReceiveMemoryWarning(); + } + + public override void ViewDidLoad() + { + base.ViewDidLoad(); + + foreach(var item in ExtensionContext.InputItems) + { + foreach(var itemProvider in item.Attachments) + { + if(itemProvider.HasItemConformingTo(UTType.PropertyList)) + { + itemProvider.LoadItem(UTType.PropertyList, null, delegate (NSObject list, NSError error) + { + if(list != null) + { + var dict = list as NSDictionary; + var result = dict[NSJavaScriptExtension.PreprocessingResultsKey]; + if(result != null) + { + Content = result.ValueForKey(new NSString("content")) as NSString; + Uri = new Uri(result.ValueForKey(new NSString("uri")) as NSString); + Console.WriteLine("BITWARDEN LOG, Content: {0}", Content); + Console.WriteLine("BITWARDEN LOG, Uri: {0}", Uri); + } + } + }); + break; + } + } + } + } + + partial void DoneClicked(NSObject sender) + { + + } + } +} diff --git a/src/iOS.Extension/ActionViewController.designer.cs b/src/iOS.Extension/ActionViewController.designer.cs new file mode 100644 index 000000000..fcca0cbd9 --- /dev/null +++ b/src/iOS.Extension/ActionViewController.designer.cs @@ -0,0 +1,24 @@ +// +// This file has been generated automatically to store outlets and +// actions made in the Xcode designer. If it is removed, they will be lost. +// Manual changes to this file may not be handled correctly. +// +using UIKit; +using Foundation; + +namespace Bit.iOS.Extension +{ + [Register("ActionViewController")] + partial class ActionViewController + { + [Outlet] + UIImageView imageView { get; set; } + + [Action("DoneClicked:")] + partial void DoneClicked(NSObject sender); + + void ReleaseDesignerOutlets() + { + } + } +} diff --git a/src/iOS.Extension/AppDelegate.cs b/src/iOS.Extension/AppDelegate.cs new file mode 100644 index 000000000..a8149c102 --- /dev/null +++ b/src/iOS.Extension/AppDelegate.cs @@ -0,0 +1,46 @@ +using System; +using System.Linq; +using System.Collections.Generic; + +using Foundation; +using UIKit; + +namespace Bit.iOS.Extension +{ + // The UIApplicationDelegate for the application. This class is responsible for launching the + // User Interface of the application, as well as listening (and optionally responding) to + // application events from iOS. + [Register("AppDelegate")] + public partial class AppDelegate : UIApplicationDelegate + { + // class-level declarations + + public override UIWindow Window + { + get; set; + } + + // This method is invoked when the application is about to move from active to inactive state. + // OpenGL applications should use this method to pause. + public override void OnResignActivation(UIApplication application) + { + } + + // This method should be used to release shared resources and it should store the application state. + // If your application supports background exection this method is called instead of WillTerminate + // when the user quits. + public override void DidEnterBackground(UIApplication application) + { + } + + // This method is called as part of the transiton from background to active state. + public override void WillEnterForeground(UIApplication application) + { + } + + // This method is called when the application is about to terminate. Save data, if needed. + public override void WillTerminate(UIApplication application) + { + } + } +} diff --git a/src/iOS.Extension/Entitlements.plist b/src/iOS.Extension/Entitlements.plist new file mode 100644 index 000000000..0c67376eb --- /dev/null +++ b/src/iOS.Extension/Entitlements.plist @@ -0,0 +1,5 @@ + + + + + diff --git a/src/iOS.Extension/Info.plist b/src/iOS.Extension/Info.plist new file mode 100644 index 000000000..b1d7a481f --- /dev/null +++ b/src/iOS.Extension/Info.plist @@ -0,0 +1,63 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + bitwarden + CFBundleExecutable + iOS.Extension + CFBundleIdentifier + com.bitwarden.vault.extension + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + com.companyname.iOS.Extension + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + NSExtension + + NSExtensionAttributes + + NSExtensionJavaScriptPreprocessingFile + extension + NSExtensionActivationRule + + NSExtensionActivationSupportsFileWithMaxCount + 0 + NSExtensionActivationSupportsImageWithMaxCount + 0 + NSExtensionActivationSupportsMovieWithMaxCount + 0 + NSExtensionActivationSupportsText + + NSExtensionActivationSupportsWebURLWithMaxCount + 1 + + NSExtensionPointName + com.apple.ui-services + NSExtensionPointVersion + 1.0 + + NSExtensionMainStoryboard + MainInterface + NSExtensionPointIdentifier + com.apple.ui-services + + UIDeviceFamily + + 1 + + MinimumOSVersion + 8.0 + UISupportedInterfaceOrientations + + + diff --git a/src/iOS.Extension/Main.cs b/src/iOS.Extension/Main.cs new file mode 100644 index 000000000..9291201f8 --- /dev/null +++ b/src/iOS.Extension/Main.cs @@ -0,0 +1,15 @@ +using UIKit; + +namespace Bit.iOS.Extension +{ + public class Application + { + // This is the main entry point of the application. + static void Main(string[] args) + { + // if you want to use a different Application Delegate class from "AppDelegate" + // you can specify it here. + UIApplication.Main(args, null, "AppDelegate"); + } + } +} \ No newline at end of file diff --git a/src/iOS.Extension/MainInterface.storyboard b/src/iOS.Extension/MainInterface.storyboard new file mode 100644 index 000000000..c93012146 --- /dev/null +++ b/src/iOS.Extension/MainInterface.storyboard @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/iOS.Extension/Properties/AssemblyInfo.cs b/src/iOS.Extension/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..f42c48bbc --- /dev/null +++ b/src/iOS.Extension/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Bit.iOS.Extension")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("bitwarden")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("32f5a2d6-f54d-4da1-ae26-0a980d48f422")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/iOS.Extension/extension.js b/src/iOS.Extension/extension.js new file mode 100644 index 000000000..50477976b --- /dev/null +++ b/src/iOS.Extension/extension.js @@ -0,0 +1,16 @@ +var BitwardenExtension = function () { }; + +BitwardenExtension.prototype = { + run: function (arguments) { + var args = { + content: document.body.innerHTML, + uri: document.baseURI + }; + arguments.completionFunction(args); + }, + finalize: function (arguments) { + alert('finalize'); + } +}; + +var ExtensionPreprocessingJS = new BitwardenExtension; diff --git a/src/iOS.Extension/iOS.Extension.csproj b/src/iOS.Extension/iOS.Extension.csproj new file mode 100644 index 000000000..6a090c44b --- /dev/null +++ b/src/iOS.Extension/iOS.Extension.csproj @@ -0,0 +1,113 @@ + + + + Debug + iPhoneSimulator + {32F5A2D6-F54D-4DA1-AE26-0A980D48F422} + {EE2C853D-36AF-4FDB-B1AD-8E90477E2198};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Exe + Bit.iOS.Extension + BitiOSExtension + Resources + Properties + + + true + full + false + bin\iPhoneSimulator\Debug + DEBUG + prompt + 4 + false + i386 + None + true + Entitlements.plist + + + none + true + bin\iPhoneSimulator\Release + prompt + 4 + None + i386 + false + Entitlements.plist + + + true + full + false + bin\iPhone\Debug + DEBUG + prompt + 4 + false + ARMv7, ARM64 + Entitlements.plist + iPhone Developer + true + + + none + true + bin\iPhone\Release + prompt + 4 + Entitlements.plist + ARMv7, ARM64 + false + iPhone Developer + + + none + True + bin\iPhone\Ad-Hoc + prompt + 4 + False + ARMv7, ARM64 + Entitlements.plist + True + Automatic:AdHoc + iPhone Distribution + + + none + True + bin\iPhone\AppStore + prompt + 4 + False + ARMv7, ARM64 + Entitlements.plist + Automatic:AppStore + iPhone Distribution + + + + ActionViewController.cs + + + + + + + + + + + + + + + + + + Always + + + + \ No newline at end of file diff --git a/src/iOS/iOS.csproj b/src/iOS/iOS.csproj index 48d277972..00bccbcc5 100644 --- a/src/iOS/iOS.csproj +++ b/src/iOS/iOS.csproj @@ -208,6 +208,12 @@ {b490c5da-639e-4994-abd2-54222b8a348e} App + + {32f5a2d6-f54d-4da1-ae26-0a980d48f422} + iOS.Extension + true + false +