Revision: 6128 Author: j...@google.com Date: Fri Sep 11 16:24:58 2009 Log: Move Windows registry and dialog box code to common location to share between NPAPI and IE (for now, eventually Chrome needs a platform-independent UI), checkin packaged Chrome extension with access list UI.
http://code.google.com/p/google-web-toolkit/source/detail?r=6128 Added: /trunk/plugins/platform /trunk/plugins/platform/Win /trunk/plugins/platform/Win/AllowDialog.cpp /trunk/plugins/platform/Win/AllowDialog.h /trunk/plugins/platform/Win/Preferences.cpp /trunk/plugins/platform/Win/Preferences.h Deleted: /trunk/plugins/ie/oophm/oophm/AllowDialog.cpp /trunk/plugins/ie/oophm/oophm/AllowDialog.h /trunk/plugins/ie/oophm/oophm/Preferences.cpp /trunk/plugins/ie/oophm/oophm/Preferences.h /trunk/plugins/npapi/extension/platform/WINNT_x86-msvc/plugins/npOOPHM.dll Modified: /trunk/plugins/ie/oophm/oophm/oophm.vcproj /trunk/plugins/npapi/ScriptableInstance.cpp /trunk/plugins/npapi/VisualStudio/npapi-plugin.vcproj /trunk/plugins/npapi/main.cpp /trunk/plugins/npapi/npOOPHM.rc /trunk/plugins/npapi/prebuilt/gwtdmp/WINNT_x86-msvc/npOOPHM.dll /trunk/plugins/npapi/prebuilt/gwtdmp.crx /trunk/plugins/npapi/resource.h ======================================= --- /dev/null +++ /trunk/plugins/platform/Win/AllowDialog.cpp Fri Sep 11 16:24:58 2009 @@ -0,0 +1,54 @@ +/* + * Copyright 2009 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +#include "AllowDialog.h" +#include "Debug.h" +#include "resource.h" + +HINSTANCE AllowDialog::hInstance; + +static BOOL CALLBACK allowDialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { + if (message != WM_COMMAND) { + return false; + } + bool allowed; + switch (LOWORD(wParam)) { + case IDCANCEL: + allowed = false; + break; + case IDC_ALLOW_BUTTON: + allowed = true; + break; + default: + // ignore anything but buttons which close the dialog + return false; + } + bool remember = IsDlgButtonChecked(hwndDlg, IDC_REMEMBER_CHECKBOX) == BST_CHECKED; + int returnVal = (allowed ? 1 : 0) + (remember ? 2 : 0); + EndDialog(hwndDlg, (INT_PTR) returnVal); + return true; +} + +void AllowDialog::setHInstance(HINSTANCE hInstance) { + AllowDialog::hInstance = hInstance; +} + +bool AllowDialog::askUserToAllow(bool* remember) { + int result = (int) DialogBox(hInstance, MAKEINTRESOURCE(IDD_ALLOW_DIALOG), + NULL, (DLGPROC) allowDialogProc); + *remember = (result & 2) != 0; + return (result & 1) != 0; +} ======================================= --- /dev/null +++ /trunk/plugins/platform/Win/AllowDialog.h Fri Sep 11 16:24:58 2009 @@ -0,0 +1,42 @@ +#ifndef _H_AllowDialog +#define _H_AllowDialog +/* + * Copyright 2009 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +#ifdef _WINDOWS +#include <windows.h> +#include <winnt.h> +#include <windef.h> + +class AllowDialog { +public: + static void setHInstance(HINSTANCE hInstance); + + /** + * Ask the user if a connection should be allowed. + * + * @param remember *remember is set to true if the user asked us to remember this decision, + * false otherwise + * @return return true if this connection should be allowed + */ + static bool askUserToAllow(bool* remember); + +private: + static HINSTANCE hInstance; +}; +#endif + +#endif ======================================= --- /dev/null +++ /trunk/plugins/platform/Win/Preferences.cpp Fri Sep 11 16:24:58 2009 @@ -0,0 +1,100 @@ +/* + * Copyright 2009 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +#include <windows.h> +#include <winnt.h> +#include <winreg.h> +#include "Debug.h" +#include "Preferences.h" +#include "AllowedConnections.h" + +#define REG_ACCESS_LIST "SOFTWARE\\Google\\Google Web Toolkit\\gwt-dmp.accessList" + +/** + * Return a null-terminated string containing the access list. + * + * @param HKEY registry key for the access list value + * @return null-terminated string containing the access list (an empty string + * if the value does not exist) -- caller is responsible for freeing with + * delete[] + */ +static char* getAccessList(HKEY keyHandle) { + char *buf; + DWORD len = 512; + while(true) { + buf = new char[len]; + int cc = RegQueryValueExA(keyHandle, NULL, 0, NULL, (LPBYTE) buf, &len); + if (cc == ERROR_SUCCESS) { + break; + } else if (cc == ERROR_FILE_NOT_FOUND) { + // special handling if the value doesn't exist + len = 0; + break; + } else if (cc != ERROR_MORE_DATA) { + // log unexpected errors + Debug::log(Debug::Error) << "Unable to load access list from registry: " + << cc << Debug::flush; + len = 0; + break; + } + // Buffer wasn't big enough, so make it bigger and try again + delete [] buf; + len *= 2; + } + buf[len] = 0; + return buf; +} + +void Preferences::addNewRule(const std::string& pattern, bool exclude) { + HKEY keyHandle; + if (RegCreateKeyExA(HKEY_CURRENT_USER, REG_ACCESS_LIST, 0, 0, + REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &keyHandle, NULL) + != ERROR_SUCCESS) { + return; + } + char *buf = getAccessList(keyHandle); + std::string pref(buf); + delete [] buf; + if (pref.length() > 0) { + pref += ','; + } + if (exclude) { + pref += '!'; + } + pref += pattern; + int cc = RegSetValueExA(keyHandle, NULL, 0, REG_SZ, (LPBYTE) pref.c_str(), + pref.length() + 1); + if (cc != ERROR_SUCCESS) { + Debug::log(Debug::Error) << "Unable to store access list in registry: " + << cc << Debug::flush; + } + RegCloseKey(keyHandle); +} + +void Preferences::loadAccessList() { + // TODO(jat): can Reg* routines throw exceptions? If so, we need to make + // this exception safe about closing the key hendle and freeing the buffer. + HKEY keyHandle; + if (RegCreateKeyExA(HKEY_CURRENT_USER, REG_ACCESS_LIST, 0, 0, + REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &keyHandle, NULL) + != ERROR_SUCCESS) { + return; + } + char *buf = getAccessList(keyHandle); + AllowedConnections::initFromAccessList(buf); + delete [] buf; + RegCloseKey(keyHandle); +} ======================================= --- /dev/null +++ /trunk/plugins/platform/Win/Preferences.h Fri Sep 11 16:24:58 2009 @@ -0,0 +1,34 @@ +#ifndef _H_Preferences +#define _H_Preferences +/* + * Copyright 2009 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +#include <string> + +/** + * Deal with getting/storing/updating preferences in the Windows registry. + */ +class Preferences { +private: + // prevent instantiation + Preferences() {} + +public: + static void loadAccessList(); + static void addNewRule(const std::string& pattern, bool exclude); +}; + +#endif ======================================= --- /trunk/plugins/ie/oophm/oophm/AllowDialog.cpp Thu Sep 3 15:22:56 2009 +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2009 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -#include "AllowDialog.h" -#include "Debug.h" -#include "resource.h" - -HINSTANCE AllowDialog::hInstance; - -static BOOL CALLBACK allowDialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { - if (message != WM_COMMAND) { - return false; - } - bool allowed; - switch (LOWORD(wParam)) { - case IDCANCEL: - allowed = false; - break; - case IDC_ALLOW_BUTTON: - allowed = true; - break; - default: - // ignore anything but buttons which close the dialog - return false; - } - bool remember = IsDlgButtonChecked(hwndDlg, IDC_REMEMBER_CHECKBOX) == BST_CHECKED; - int returnVal = (allowed ? 1 : 0) + (remember ? 2 : 0); - EndDialog(hwndDlg, (INT_PTR) returnVal); - return true; -} - -void AllowDialog::setHInstance(HINSTANCE hInstance) { - AllowDialog::hInstance = hInstance; -} - -bool AllowDialog::askUserToAllow(bool* remember) { - int result = (int) DialogBox(hInstance, MAKEINTRESOURCE(IDD_ALLOW_DIALOG), - NULL, (DLGPROC) allowDialogProc); - *remember = (result & 2) != 0; - return (result & 1) != 0; -} ======================================= --- /trunk/plugins/ie/oophm/oophm/AllowDialog.h Thu Sep 3 15:22:56 2009 +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef _H_AllowDialog -#define _H_AllowDialog -/* - * Copyright 2009 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -#include "stdafx.h" - -class AllowDialog { -public: - static void setHInstance(HINSTANCE hInstance); - - /** - * Ask the user if a connection should be allowed. - * - * @param remember *remember is set to true if the user asked us to remember this decision, - * false otherwise - * @return return true if this connection should be allowed - */ - static bool askUserToAllow(bool* remember); - -private: - static HINSTANCE hInstance; -}; - -#endif ======================================= --- /trunk/plugins/ie/oophm/oophm/Preferences.cpp Fri Sep 4 15:16:50 2009 +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright 2009 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -#include "stdafx.h" -#include <winnt.h> -#include <winreg.h> -#include "Debug.h" -#include "Preferences.h" -#include "AllowedConnections.h" - -#define REG_ACCESS_LIST "SOFTWARE\\Google\\Google Web Toolkit\\gwt-dmp.accessList" - -/** - * Return a null-terminated string containing the access list. - * - * @param HKEY registry key for the access list value - * @return null-terminated string containing the access list (an empty string - * if the value does not exist) -- caller is responsible for freeing with - * delete[] - */ -static char* getAccessList(HKEY keyHandle) { - char *buf; - DWORD len = 512; - while(true) { - buf = new char[len]; - int cc = RegQueryValueExA(keyHandle, NULL, 0, NULL, (LPBYTE) buf, &len); - if (cc == ERROR_SUCCESS) { - break; - } else if (cc == ERROR_FILE_NOT_FOUND) { - // special handling if the value doesn't exist - len = 0; - break; - } else if (cc != ERROR_MORE_DATA) { - // log unexpected errors - Debug::log(Debug::Error) << "Unable to load access list from registry: " - << cc << Debug::flush; - len = 0; - break; - } - // Buffer wasn't big enough, so make it bigger and try again - delete [] buf; - len *= 2; - } - buf[len] = 0; - return buf; -} - -void Preferences::addNewRule(const std::string& pattern, bool exclude) { - HKEY keyHandle; - if (RegCreateKeyExA(HKEY_CURRENT_USER, REG_ACCESS_LIST, 0, 0, - REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &keyHandle, NULL) - != ERROR_SUCCESS) { - return; - } - char *buf = getAccessList(keyHandle); - std::string pref(buf); - delete [] buf; - if (pref.length() > 0) { - pref += ','; - } - if (exclude) { - pref += '!'; - } - pref += pattern; - int cc = RegSetValueExA(keyHandle, NULL, 0, REG_SZ, (LPBYTE) pref.c_str(), - pref.length() + 1); - if (cc != ERROR_SUCCESS) { - Debug::log(Debug::Error) << "Unable to store access list in registry: " - << cc << Debug::flush; - } - RegCloseKey(keyHandle); -} - -void Preferences::loadAccessList() { - // TODO(jat): can Reg* routines throw exceptions? If so, we need to make - // this exception safe about closing the key hendle and freeing the buffer. - HKEY keyHandle; - if (RegCreateKeyExA(HKEY_CURRENT_USER, REG_ACCESS_LIST, 0, 0, - REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &keyHandle, NULL) - != ERROR_SUCCESS) { - return; - } - char *buf = getAccessList(keyHandle); - AllowedConnections::initFromAccessList(buf); - delete [] buf; - RegCloseKey(keyHandle); -} ======================================= --- /trunk/plugins/ie/oophm/oophm/Preferences.h Thu Sep 3 15:22:56 2009 +++ /dev/null @@ -1,34 +0,0 @@ -#ifndef _H_Preferences -#define _H_Preferences -/* - * Copyright 2009 Google Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not - * use this file except in compliance with the License. You may obtain a copy of - * the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations under - * the License. - */ - -#include <string> - -/** - * Deal with getting/storing/updating preferences in the Windows registry. - */ -class Preferences { -private: - // prevent instantiation - Preferences() {} - -public: - static void loadAccessList(); - static void addNewRule(const std::string& pattern, bool exclude); -}; - -#endif ======================================= --- /trunk/plugins/npapi/extension/platform/WINNT_x86-msvc/plugins/npOOPHM.dll Mon Aug 3 08:30:11 2009 +++ /dev/null Binary file, no diff available. ======================================= --- /trunk/plugins/ie/oophm/oophm/oophm.vcproj Fri Sep 4 15:16:50 2009 +++ /trunk/plugins/ie/oophm/oophm/oophm.vcproj Fri Sep 11 16:24:58 2009 @@ -115,9 +115,9 @@ /> </Configuration> <Configuration - Name="Release|Win32" - OutputDirectory="$(ConfigurationName)32" - IntermediateDirectory="$(ConfigurationName)32" + Name="Debug|x64" + OutputDirectory="$(PlatformName)\$(ConfigurationName)" + IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="2" UseOfMFC="1" UseOfATL="1" @@ -138,23 +138,24 @@ /> <Tool Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" + PreprocessorDefinitions="_DEBUG" MkTypLibCompatible="false" - TargetEnvironment="1" + TargetEnvironment="3" GenerateStublessProxies="true" TypeLibraryName="$(IntDir)/oophm.tlb" HeaderFileName="oophm_i.h" DLLDataFileName="" InterfaceIdentifierFileName="oophm_i.c" ProxyFileName="oophm_p.c" - ValidateParameters="true" /> <Tool Name="VCCLCompilerTool" - Optimization="2" + Optimization="0" AdditionalIncludeDirectories="../../../common" - PreprocessorDefinitions="_WINDOWS;GWT_DEBUGDISABLE" - RuntimeLibrary="0" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GWT_DEBUGLEVEL=Spam" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="1" UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="3" @@ -164,7 +165,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" + PreprocessorDefinitions="_DEBUG" Culture="1033" AdditionalIncludeDirectories="$(IntDir)" /> @@ -173,17 +174,14 @@ /> <Tool Name="VCLinkerTool" - RegisterOutput="true" IgnoreImportLibrary="true" AdditionalDependencies="comsuppw.lib ws2_32.lib" - OutputFile="..\..\prebuilt\$(ProjectName).dll" - LinkIncremental="1" + OutputFile="..\..\prebuilt\$(ProjectName)64.dll" + LinkIncremental="2" ModuleDefinitionFile=".\oophm.def" GenerateDebugInformation="true" SubSystem="2" - OptimizeReferences="2" - EnableCOMDATFolding="2" - TargetMachine="1" + TargetMachine="17" /> <Tool Name="VCALinkTool" @@ -211,9 +209,9 @@ /> </Configuration> <Configuration - Name="Debug|x64" - OutputDirectory="$(PlatformName)\$(ConfigurationName)" - IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" + Name="Release|Win32" + OutputDirectory="$(ConfigurationName)32" + IntermediateDirectory="$(ConfigurationName)32" ConfigurationType="2" UseOfMFC="1" UseOfATL="1" @@ -234,24 +232,23 @@ /> <Tool Name="VCMIDLTool" - PreprocessorDefinitions="_DEBUG" + PreprocessorDefinitions="NDEBUG" MkTypLibCompatible="false" - TargetEnvironment="3" + TargetEnvironment="1" GenerateStublessProxies="true" TypeLibraryName="$(IntDir)/oophm.tlb" HeaderFileName="oophm_i.h" DLLDataFileName="" InterfaceIdentifierFileName="oophm_i.c" ProxyFileName="oophm_p.c" + ValidateParameters="true" /> <Tool Name="VCCLCompilerTool" - Optimization="0" - AdditionalIncludeDirectories="../../../common" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;GWT_DEBUGLEVEL=Spam" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="1" + Optimization="2" + AdditionalIncludeDirectories=""$(ProjectDir)";../../../platform/Win;../../../common" + PreprocessorDefinitions="_WINDOWS;GWT_DEBUGDISABLE" + RuntimeLibrary="0" UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="3" @@ -261,7 +258,7 @@ /> <Tool Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" + PreprocessorDefinitions="NDEBUG" Culture="1033" AdditionalIncludeDirectories="$(IntDir)" /> @@ -270,14 +267,17 @@ /> <Tool Name="VCLinkerTool" + RegisterOutput="true" IgnoreImportLibrary="true" AdditionalDependencies="comsuppw.lib ws2_32.lib" - OutputFile="..\..\prebuilt\$(ProjectName)64.dll" - LinkIncremental="2" + OutputFile="..\..\prebuilt\$(ProjectName).dll" + LinkIncremental="1" ModuleDefinitionFile=".\oophm.def" GenerateDebugInformation="true" SubSystem="2" - TargetMachine="17" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" /> <Tool Name="VCALinkTool" @@ -342,7 +342,7 @@ Name="VCCLCompilerTool" Optimization="2" FavorSizeOrSpeed="1" - AdditionalIncludeDirectories="../../../common" + AdditionalIncludeDirectories="../../../platform/Win;../../../common" PreprocessorDefinitions="_WINDOWS;GWT_DEBUGDISABLE" RuntimeLibrary="0" UsePrecompiledHeader="0" @@ -410,7 +410,7 @@ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > <File - RelativePath=".\AllowDialog.cpp" + RelativePath="..\..\..\platform\Win\AllowDialog.cpp" > </File> <File @@ -426,7 +426,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Release|Win32" + Name="Debug|x64" > <Tool Name="VCCLCompilerTool" @@ -435,7 +435,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Debug|x64" + Name="Release|Win32" > <Tool Name="VCCLCompilerTool" @@ -466,7 +466,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Release|Win32" + Name="Debug|x64" > <Tool Name="VCCLCompilerTool" @@ -475,7 +475,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Debug|x64" + Name="Release|Win32" > <Tool Name="VCCLCompilerTool" @@ -522,7 +522,7 @@ > </File> <File - RelativePath=".\Preferences.cpp" + RelativePath="..\..\..\platform\Win\Preferences.cpp" > </File> <File @@ -537,7 +537,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Release|Win32" + Name="Debug|x64" > <Tool Name="VCCLCompilerTool" @@ -545,7 +545,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Debug|x64" + Name="Release|Win32" > <Tool Name="VCCLCompilerTool" @@ -636,7 +636,7 @@ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > <File - RelativePath=".\AllowDialog.h" + RelativePath="..\..\..\platform\Win\AllowDialog.h" > </File> <File @@ -668,7 +668,7 @@ > </File> <File - RelativePath=".\Preferences.h" + RelativePath="..\..\..\platform\Win\Preferences.h" > </File> <File @@ -831,7 +831,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Release|Win32" + Name="Debug|x64" > <Tool Name="VCCLCompilerTool" @@ -840,7 +840,7 @@ /> </FileConfiguration> <FileConfiguration - Name="Debug|x64" + Name="Release|Win32" > <Tool Name="VCCLCompilerTool" ======================================= --- /trunk/plugins/npapi/ScriptableInstance.cpp Thu Sep 10 11:55:16 2009 +++ /trunk/plugins/npapi/ScriptableInstance.cpp Fri Sep 11 16:24:58 2009 @@ -21,6 +21,9 @@ #include "ReturnMessage.h" #include "ServerMethods.h" #include "AllowedConnections.h" +#include "Preferences.h" +#include "AllowDialog.h" + #include "mozincludes.h" #include "scoped_ptr/scoped_ptr.h" #include "NPVariantWrapper.h" @@ -31,12 +34,6 @@ static inline string convertToString(const NPString& str) { return string(GetNPStringUTF8Characters(str), GetNPStringUTF8Length(str)); } - -static bool askUserToAllow(const std::string& url, bool* remember) { - // TODO(jat): implement, for now allow anything but don't remember - *remember = false; - return true; -} string ScriptableInstance::computeTabIdentity() { return ""; @@ -273,14 +270,15 @@ << ",module=" << NPVariantProxy::toString(args[3]) << ",hostedHtmlVers=" << NPVariantProxy::toString(args[4]) << ")" << Debug::flush; const std::string urlStr = convertToString(url); + + Preferences::loadAccessList(); bool allowed = false; - // TODO(jat): load access list if (!AllowedConnections::matchesRule(urlStr, &allowed)) { - // If we didn't match an existing rule, prompt the user bool remember = false; - allowed = askUserToAllow(urlStr, &remember); + allowed = AllowDialog::askUserToAllow(&remember); if (remember) { - // TODO(jat): update access list + std::string host = AllowedConnections::getHostFromUrl(urlStr); + Preferences::addNewRule(host, !allowed); } } if (!allowed) { ======================================= --- /trunk/plugins/npapi/VisualStudio/npapi-plugin.vcproj Thu Sep 10 11:52:42 2009 +++ /trunk/plugins/npapi/VisualStudio/npapi-plugin.vcproj Fri Sep 11 16:24:58 2009 @@ -39,7 +39,7 @@ <Tool Name="VCCLCompilerTool" Optimization="0" - AdditionalIncludeDirectories=""$(ProjectDir)\..\..\common"" + AdditionalIncludeDirectories=""$(ProjectDir)\..\..\platform\Win";"$(ProjectDir)\..";"$(ProjectDir)\..\..\common"" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FIREFOXPLUGIN_EXPORTS" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -122,7 +122,7 @@ Name="VCCLCompilerTool" Optimization="3" EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories=""..\..\common"" + AdditionalIncludeDirectories=""$(ProjectDir)\..\..\platform\Win";"$(ProjectDir)\..";"$(ProjectDir)\..\..\common"" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FIREFOXPLUGIN_EXPORTS" ExceptionHandling="1" RuntimeLibrary="2" @@ -144,7 +144,7 @@ Name="VCLinkerTool" AdditionalDependencies="ws2_32.lib" ShowProgress="2" - OutputFile="..\extension\platform\WINNT_x86-msvc\plugins\npOOPHM.dll" + OutputFile="$(ProjectDir)\..\prebuilt\gwtdmp\WINNT_x86-msvc\npOOPHM.dll" LinkIncremental="0" AdditionalLibraryDirectories="" ModuleDefinitionFile="..\npOOPHM.def" @@ -190,6 +190,10 @@ Filter="h;hpp;hxx;hm;inl;inc;xsd" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" > + <File + RelativePath="..\..\platform\Win\AllowDialog.h" + > + </File> <File RelativePath="..\..\common\AllowedConnections.h" > @@ -289,6 +293,10 @@ <File RelativePath="..\Plugin.h" > + </File> + <File + RelativePath="..\..\platform\Win\Preferences.h" + > </File> <File RelativePath="..\..\common\ProtocolVersionMessage.h" @@ -350,6 +358,10 @@ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" > + <File + RelativePath="..\..\platform\Win\AllowDialog.cpp" + > + </File> <File RelativePath="..\..\common\AllowedConnections.cpp" > @@ -417,6 +429,10 @@ <File RelativePath="..\Plugin.cpp" > + </File> + <File + RelativePath="..\..\platform\Win\Preferences.cpp" + > </File> <File RelativePath="..\..\common\ProtocolVersionMessage.cpp" ======================================= --- /trunk/plugins/npapi/main.cpp Wed Sep 9 14:57:53 2009 +++ /trunk/plugins/npapi/main.cpp Fri Sep 11 16:24:58 2009 @@ -17,11 +17,13 @@ #include "Plugin.h" #include "ScriptableInstance.h" #include "scoped_ptr/scoped_ptr.h" +#include "AllowDialog.h" #ifdef _WINDOWS #include <windows.h> BOOL APIENTRY DllMain(HMODULE hModule, DWORD ulReasonForCall, LPVOID lpReserved) { + AllowDialog::setHInstance(hModule); switch (ulReasonForCall) { case DLL_PROCESS_ATTACH: case DLL_THREAD_ATTACH: ======================================= --- /trunk/plugins/npapi/npOOPHM.rc Fri Sep 4 16:37:06 2009 +++ /trunk/plugins/npapi/npOOPHM.rc Fri Sep 11 16:24:58 2009 @@ -2,6 +2,7 @@ #define APSTUDIO_READONLY_SYMBOLS #include "windows.h" +#include "winres.h" #undef APSTUDIO_READONLY_SYMBOLS #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) @@ -11,8 +12,8 @@ #endif 1 VERSIONINFO - FILEVERSION 0,1,1,0 - PRODUCTVERSION 0,1,1,0 + FILEVERSION 0,9,0,0 + PRODUCTVERSION 0,9,0,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -28,18 +29,18 @@ BLOCK "040904e4" BEGIN VALUE "CompanyName", "Google Inc" - VALUE "FileDescription", "GWT OOPHM Plugin" + VALUE "FileDescription", "GWT Development Mode Plugin" #if 0 VALUE "FileExtents", "" #endif VALUE "FileOpenName", "Plugin to allow debugging of GWT applications in hosted mode." - VALUE "FileVersion", "0.1a" - VALUE "InternalName", "GWT OOPHM Plugin" - VALUE "LegalCopyright", "Copyright © 2008 Google Inc. All rights reserved." + VALUE "FileVersion", "0.9.0" + VALUE "InternalName", "GWT DMP" + VALUE "LegalCopyright", "Copyright © 2009 Google Inc. All rights reserved." VALUE "MIMEType", "application/x-gwt-hosted-mode" VALUE "OriginalFilename", "npOOPHM.dll" - VALUE "ProductName", "GWT OOPHM Plugin" - VALUE "ProductVersion", "0.1a" + VALUE "ProductName", "GWT DMP Plugin" + VALUE "ProductVersion", "0.9.0" END END BLOCK "VarFileInfo" @@ -68,6 +69,43 @@ #endif +///////////////////////////////////////////////////////////////////////////// +// +// Dialog +// + +IDD_ALLOW_DIALOG DIALOGEX 0, 0, 188, 73 +STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CAPTION +EXSTYLE WS_EX_TOPMOST +CAPTION "GWT Plugin Security Alert" +FONT 10, "Microsoft Sans Serif", 400, 0, 0x0 +BEGIN + CONTROL "Remember this decision for this server",IDC_REMEMBER_CHECKBOX, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,30,31,129,10 + LTEXT "This web server is trying to initiate a GWT Development\r\nMode Conncetion -- should it be allowed?",IDC_STATIC,10,7,167,19 + PUSHBUTTON "Allow",IDC_ALLOW_BUTTON,37,50,50,14 + DEFPUSHBUTTON "Deny",IDCANCEL,100,50,50,14 +END + + +///////////////////////////////////////////////////////////////////////////// +// +// DESIGNINFO +// + +#ifdef APSTUDIO_INVOKED +GUIDELINES DESIGNINFO +BEGIN + IDD_ALLOW_DIALOG, DIALOG + BEGIN + LEFTMARGIN, 7 + RIGHTMARGIN, 181 + TOPMARGIN, 7 + BOTTOMMARGIN, 66 + END +END +#endif // APSTUDIO_INVOKED + #else #endif ======================================= --- /trunk/plugins/npapi/prebuilt/gwtdmp/WINNT_x86-msvc/npOOPHM.dll Thu Sep 10 11:52:42 2009 +++ /trunk/plugins/npapi/prebuilt/gwtdmp/WINNT_x86-msvc/npOOPHM.dll Fri Sep 11 16:24:58 2009 Binary file, no diff available. ======================================= --- /trunk/plugins/npapi/prebuilt/gwtdmp.crx Thu Sep 10 11:52:42 2009 +++ /trunk/plugins/npapi/prebuilt/gwtdmp.crx Fri Sep 11 16:24:58 2009 Binary file, no diff available. ======================================= --- /trunk/plugins/npapi/resource.h Mon Aug 3 08:30:11 2009 +++ /trunk/plugins/npapi/resource.h Fri Sep 11 16:24:58 2009 @@ -1,12 +1,15 @@ //{{NO_DEPENDENCIES}} // Microsoft Visual C++ generated include file. -// Used by npApuProto.rc +// Used by npOOPHM.rc // #define IDD_MAIN 101 #define IDC_BUTTON_GO 1002 #define IDC_STATIC_UA 1003 #define IDC_BUTTON1 1005 #define IDC_BUTTON_DONT 1005 +#define IDD_ALLOW_DIALOG 103 +#define IDC_REMEMBER_CHECKBOX 201 +#define IDC_ALLOW_BUTTON 202 // Next default values for new objects // --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---