├── README.md ├── qcef3_1650.png └── qcef3_1650 ├── .gitattributes ├── .gitignore ├── cefclient.vcxproj ├── cefclient.vcxproj.filters ├── cefclient ├── cefclient.cpp ├── cefclient.h ├── cefclient_qt.cpp ├── client_app.cpp ├── client_app.h ├── client_app_delegates.cpp ├── client_app_js.h ├── client_binding.cpp ├── client_binding.h ├── client_handler.cpp ├── client_handler.h ├── client_handler_qt.cpp ├── client_renderer.cpp ├── client_renderer.h ├── client_transfer.cpp ├── client_transfer.h ├── message_event.cpp ├── message_event.h ├── qcefwebview.cpp ├── qcefwebview.h └── util.h ├── cefclient_process.vcxproj ├── cefclient_process.vcxproj.filters ├── exclude.list ├── libcef_dll.vcxproj ├── libcef_dll.vcxproj.filters ├── main.cpp ├── main_process.cpp ├── mainwindow.cpp ├── mainwindow.h ├── mainwindow.ui ├── move.bat ├── qcef3_1650.sln └── www └── SendMessage.html /README.md: -------------------------------------------------------------------------------- 1 | 2 | A simple cef3 client with Qt. 3 | 4 | ![](https://github.com/joinAero/qtcefclient/blob/master/qcef3_1650.png?raw=true) 5 | 6 | 7 | Build 8 | ----- 9 | 10 | * Qt 4.8.5 11 | * CEF 3.1650.1544 12 | 13 | You can download CEF3 here: [CEF3 Builds](http://cefbuilds.com/). 14 | 15 | * Extract the following and copy to `qcef3_1650/`. 16 | 17 | ``` 18 | Debug/ 19 | Release/ 20 | include/ 21 | Resources/ 22 | libcef_dll/ 23 | ``` 24 | 25 | * Add environment variable: `QT_HOME`. 26 | 27 | * Open `qcef3_1650/qcef3_1650.sln`, then build. (VS 2010) 28 | 29 | 30 | Project 31 | ------- 32 | 33 | * cefclient 34 | - the main cef3 client project 35 | * cefclient_process 36 | - a separate sub-process executable project 37 | - `SUB_PROCESS_DISABLED` option in `cefclient.cpp` 38 | * libcef_dll 39 | - cef3's c++ wrapper 40 | -------------------------------------------------------------------------------- /qcef3_1650.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joinAero/qtcefclient/9164b5e658a23f580539b89d453c0f13b88b49ff/qcef3_1650.png -------------------------------------------------------------------------------- /qcef3_1650/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | *.sln merge=union 7 | *.csproj merge=union 8 | *.vbproj merge=union 9 | *.fsproj merge=union 10 | *.dbproj merge=union 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | -------------------------------------------------------------------------------- /qcef3_1650/.gitignore: -------------------------------------------------------------------------------- 1 | out/ 2 | 3 | # CEF 4 | Debug/ 5 | Release/ 6 | include/ 7 | Resources/ 8 | libcef_dll/ 9 | 10 | # Qt 11 | GeneratedFiles/ 12 | 13 | ################# 14 | ## Eclipse 15 | ################# 16 | 17 | *.pydevproject 18 | # .project 19 | .metadata 20 | bin/ 21 | gen/ 22 | tmp/ 23 | *.tmp 24 | *.bak 25 | *.swp 26 | *~.nib 27 | # local.properties 28 | # .classpath 29 | .settings/ 30 | .loadpath 31 | 32 | # External tool builders 33 | .externalToolBuilders/ 34 | 35 | # Locally stored "Eclipse launch configurations" 36 | *.launch 37 | 38 | # CDT-specific 39 | .cproject 40 | 41 | # PDT-specific 42 | .buildpath 43 | 44 | 45 | ################# 46 | ## Visual Studio 47 | ################# 48 | 49 | ## Ignore Visual Studio temporary files, build results, and 50 | ## files generated by popular Visual Studio add-ons. 51 | 52 | # User-specific files 53 | *.suo 54 | *.user 55 | *.sln.docstates 56 | 57 | # Build results 58 | [Dd]ebug/ 59 | [Rr]elease/ 60 | *_i.c 61 | *_p.c 62 | *.ilk 63 | *.meta 64 | *.obj 65 | *.pch 66 | *.pdb 67 | *.pgc 68 | *.pgd 69 | *.rsp 70 | *.sbr 71 | *.tlb 72 | *.tli 73 | *.tlh 74 | *.tmp 75 | *.vspscc 76 | .builds 77 | *.dotCover 78 | 79 | ## TODO: If you have NuGet Package Restore enabled, uncomment this 80 | #packages/ 81 | 82 | # Visual C++ cache files 83 | ipch/ 84 | *.aps 85 | *.ncb 86 | *.opensdf 87 | *.sdf 88 | 89 | # Visual Studio profiler 90 | *.psess 91 | *.vsp 92 | 93 | # ReSharper is a .NET coding add-in 94 | _ReSharper* 95 | 96 | # Installshield output folder 97 | [Ee]xpress 98 | 99 | # DocProject is a documentation generator add-in 100 | DocProject/buildhelp/ 101 | DocProject/Help/*.HxT 102 | DocProject/Help/*.HxC 103 | DocProject/Help/*.hhc 104 | DocProject/Help/*.hhk 105 | DocProject/Help/*.hhp 106 | DocProject/Help/Html2 107 | DocProject/Help/html 108 | 109 | # Click-Once directory 110 | publish 111 | 112 | # Others 113 | [Bb]in 114 | [Oo]bj 115 | sql 116 | TestResults 117 | *.Cache 118 | ClientBin 119 | stylecop.* 120 | ~$* 121 | *.dbmdl 122 | Generated_Code #added for RIA/Silverlight projects 123 | 124 | # Backup & report files from converting an old project file to a newer 125 | # Visual Studio version. Backup files are not needed, because we have git ;-) 126 | _UpgradeReport_Files/ 127 | Backup*/ 128 | UpgradeLog*.XML 129 | 130 | 131 | 132 | ############ 133 | ## Windows 134 | ############ 135 | 136 | # Windows image file caches 137 | Thumbs.db 138 | 139 | # Folder config file 140 | Desktop.ini 141 | 142 | 143 | ############# 144 | ## Python 145 | ############# 146 | 147 | *.py[co] 148 | 149 | # Packages 150 | *.egg 151 | *.egg-info 152 | dist 153 | build 154 | eggs 155 | parts 156 | bin 157 | var 158 | sdist 159 | develop-eggs 160 | .installed.cfg 161 | 162 | # Installer logs 163 | pip-log.txt 164 | 165 | # Unit test / coverage reports 166 | .coverage 167 | .tox 168 | 169 | #Translations 170 | *.mo 171 | 172 | #Mr Developer 173 | .mr.developer.cfg 174 | 175 | # Mac crap 176 | .DS_Store 177 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {43CC1856-8F29-41E5-89ED-0CE19DFF8350} 15 | Qt4VSv1.0 16 | 17 | 18 | 19 | Application 20 | Unicode 21 | 22 | 23 | Application 24 | Unicode 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | <_ProjectFileVersion>10.0.40219.1 38 | AllRules.ruleset 39 | 40 | 41 | AllRules.ruleset 42 | 43 | 44 | $(SolutionDir)out\$(Configuration)\ 45 | $(SolutionDir)out\$(Configuration)\ 46 | $(SolutionDir)out\$(ProjectName)\$(Configuration)\ 47 | $(SolutionDir)out\$(ProjectName)\$(Configuration)\ 48 | 49 | 50 | 51 | UNICODE;WIN32;NOMINMAX;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;%(PreprocessorDefinitions) 52 | .;.\GeneratedFiles;.\GeneratedFiles\$(ConfigurationName);$(SolutionDir);$(QT_HOME)\include;$(QT_HOME)\include\QtCore;$(QT_HOME)\include\QtGui;%(AdditionalIncludeDirectories) 53 | Disabled 54 | ProgramDatabase 55 | MultiThreadedDebugDLL 56 | false 57 | 58 | 59 | Windows 60 | $(OutDir)\$(ProjectName).exe 61 | $(QT_HOME)\lib 62 | true 63 | $(Configuration)\libcef.lib;out\$(Configuration)\lib\libcef_dll.lib;qtmaind.lib;QtCored4.lib;QtGuid4.lib;%(AdditionalDependencies) 64 | 65 | 66 | call $(SolutionDir)move.bat $(SolutionDir) $(Configuration) 67 | 68 | 69 | 70 | 71 | UNICODE;WIN32;NOMINMAX;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;NDEBUG;QT_NO_DEBUG;%(PreprocessorDefinitions) 72 | .;.\GeneratedFiles;.\GeneratedFiles\$(ConfigurationName);$(SolutionDir);$(QT_HOME)\include;$(QT_HOME)\include\QtCore;$(QT_HOME)\include\QtGui;%(AdditionalIncludeDirectories) 73 | 74 | 75 | MultiThreadedDLL 76 | false 77 | 78 | 79 | Windows 80 | $(OutDir)\$(ProjectName).exe 81 | $(QT_HOME)\lib 82 | false 83 | $(Configuration)\libcef.lib;out\$(Configuration)\lib\libcef_dll.lib;qtmain.lib;QtCore4.lib;QtGui4.lib;%(AdditionalDependencies) 84 | 85 | 86 | call $(SolutionDir)move.bat $(SolutionDir) $(Configuration) 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | true 101 | 102 | 103 | true 104 | 105 | 106 | true 107 | 108 | 109 | true 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | $(QT_HOME)\bin\moc.exe;%(FullPath) 119 | Moc%27ing mainwindow.h... 120 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 121 | "$(QT_HOME)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DNOMINMAX -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -D_UNICODE "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(SolutionDir)\." "-I$(QT_HOME)\include" "-I$(QT_HOME)\include\QtCore" "-I$(QT_HOME)\include\QtGui" 122 | $(QT_HOME)\bin\moc.exe;%(FullPath) 123 | Moc%27ing mainwindow.h... 124 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 125 | "$(QT_HOME)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DNOMINMAX -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DNDEBUG -DQT_NO_DEBUG -D_UNICODE "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(SolutionDir)\." "-I$(QT_HOME)\include" "-I$(QT_HOME)\include\QtCore" "-I$(QT_HOME)\include\QtGui" 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | $(QT_HOME)\bin\moc.exe;%(FullPath) 267 | Moc%27ing qcefwebview.h... 268 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 269 | "$(QT_HOME)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DNOMINMAX -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -D_UNICODE "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(SolutionDir)\." "-I$(QT_HOME)\include" "-I$(QT_HOME)\include\QtCore" "-I$(QT_HOME)\include\QtGui" 270 | $(QT_HOME)\bin\moc.exe;%(FullPath) 271 | Moc%27ing qcefwebview.h... 272 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 273 | "$(QT_HOME)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DNOMINMAX -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DNDEBUG -DQT_NO_DEBUG -D_UNICODE "-I." "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(SolutionDir)\." "-I$(QT_HOME)\include" "-I$(QT_HOME)\include\QtCore" "-I$(QT_HOME)\include\QtGui" 274 | 275 | 276 | 277 | 278 | Document 279 | $(QT_HOME)\bin\uic.exe;%(AdditionalInputs) 280 | Uic%27ing %(Identity)... 281 | .\GeneratedFiles\ui_%(Filename).h;%(Outputs) 282 | "$(QT_HOME)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" 283 | $(QT_HOME)\bin\uic.exe;%(AdditionalInputs) 284 | Uic%27ing %(Identity)... 285 | .\GeneratedFiles\ui_%(Filename).h;%(Outputs) 286 | "$(QT_HOME)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} 6 | moc;h;cpp 7 | False 8 | 9 | 10 | {90a77b77-8702-40e9-9389-b24fc3f26d05} 11 | cpp;moc 12 | False 13 | 14 | 15 | {b4d8472d-d242-4d1d-9071-c97fd34f396a} 16 | cpp;moc 17 | False 18 | 19 | 20 | {f5e6f9ad-2724-4cfd-bf33-fb6f59f48147} 21 | 22 | 23 | {33a8de12-5fc3-447c-b714-49abc50747e3} 24 | 25 | 26 | {b9f6cf57-bcad-4fcc-ba7e-7b24d552cfa3} 27 | 28 | 29 | {c108d178-097f-4eb0-a7f8-d3051bcd4e0f} 30 | 31 | 32 | {8078a669-fc91-4b7a-8164-1c959acf4deb} 33 | 34 | 35 | 36 | 37 | 38 | 39 | Generated Files\Debug 40 | 41 | 42 | Generated Files\Release 43 | 44 | 45 | cefclient 46 | 47 | 48 | cefclient 49 | 50 | 51 | cefclient 52 | 53 | 54 | cefclient 55 | 56 | 57 | cefclient 58 | 59 | 60 | cefclient 61 | 62 | 63 | cefclient 64 | 65 | 66 | Generated Files\Debug 67 | 68 | 69 | Generated Files\Release 70 | 71 | 72 | cefclient 73 | 74 | 75 | cefclient 76 | 77 | 78 | cefclient 79 | 80 | 81 | cefclient 82 | 83 | 84 | 85 | 86 | 87 | cefclient 88 | 89 | 90 | 91 | 92 | 93 | include\capi 94 | 95 | 96 | include\capi 97 | 98 | 99 | include\capi 100 | 101 | 102 | include\capi 103 | 104 | 105 | include\capi 106 | 107 | 108 | include\capi 109 | 110 | 111 | include\capi 112 | 113 | 114 | include\capi 115 | 116 | 117 | include\capi 118 | 119 | 120 | include\capi 121 | 122 | 123 | include\capi 124 | 125 | 126 | include\capi 127 | 128 | 129 | include\capi 130 | 131 | 132 | include\capi 133 | 134 | 135 | include\capi 136 | 137 | 138 | include\capi 139 | 140 | 141 | include\capi 142 | 143 | 144 | include\capi 145 | 146 | 147 | include\capi 148 | 149 | 150 | include\capi 151 | 152 | 153 | include\capi 154 | 155 | 156 | include\capi 157 | 158 | 159 | include\capi 160 | 161 | 162 | include\capi 163 | 164 | 165 | include\capi 166 | 167 | 168 | include\capi 169 | 170 | 171 | include\capi 172 | 173 | 174 | include\capi 175 | 176 | 177 | include\capi 178 | 179 | 180 | include\capi 181 | 182 | 183 | include\capi 184 | 185 | 186 | include\capi 187 | 188 | 189 | include\capi 190 | 191 | 192 | include\capi 193 | 194 | 195 | include\capi 196 | 197 | 198 | include\capi 199 | 200 | 201 | include\capi 202 | 203 | 204 | include\capi 205 | 206 | 207 | include\capi 208 | 209 | 210 | include\capi 211 | 212 | 213 | include\capi 214 | 215 | 216 | include\capi 217 | 218 | 219 | include\capi 220 | 221 | 222 | include\capi 223 | 224 | 225 | include\capi 226 | 227 | 228 | include\capi 229 | 230 | 231 | include\capi 232 | 233 | 234 | include\capi 235 | 236 | 237 | include\capi 238 | 239 | 240 | include\capi 241 | 242 | 243 | include\capi 244 | 245 | 246 | include\internal 247 | 248 | 249 | include\internal 250 | 251 | 252 | include\internal 253 | 254 | 255 | include\internal 256 | 257 | 258 | include\internal 259 | 260 | 261 | include\internal 262 | 263 | 264 | include\internal 265 | 266 | 267 | include\internal 268 | 269 | 270 | include\internal 271 | 272 | 273 | include\internal 274 | 275 | 276 | include\internal 277 | 278 | 279 | include\internal 280 | 281 | 282 | include\internal 283 | 284 | 285 | include\internal 286 | 287 | 288 | include\internal 289 | 290 | 291 | include\wrapper 292 | 293 | 294 | include\wrapper 295 | 296 | 297 | include\wrapper 298 | 299 | 300 | include\wrapper 301 | 302 | 303 | include 304 | 305 | 306 | include 307 | 308 | 309 | include 310 | 311 | 312 | include 313 | 314 | 315 | include 316 | 317 | 318 | include 319 | 320 | 321 | include 322 | 323 | 324 | include 325 | 326 | 327 | include 328 | 329 | 330 | include 331 | 332 | 333 | include 334 | 335 | 336 | include 337 | 338 | 339 | include 340 | 341 | 342 | include 343 | 344 | 345 | include 346 | 347 | 348 | include 349 | 350 | 351 | include 352 | 353 | 354 | include 355 | 356 | 357 | include 358 | 359 | 360 | include 361 | 362 | 363 | include 364 | 365 | 366 | include 367 | 368 | 369 | include 370 | 371 | 372 | include 373 | 374 | 375 | include 376 | 377 | 378 | include 379 | 380 | 381 | include 382 | 383 | 384 | include 385 | 386 | 387 | include 388 | 389 | 390 | include 391 | 392 | 393 | include 394 | 395 | 396 | include 397 | 398 | 399 | include 400 | 401 | 402 | include 403 | 404 | 405 | include 406 | 407 | 408 | include 409 | 410 | 411 | include 412 | 413 | 414 | include 415 | 416 | 417 | include 418 | 419 | 420 | include 421 | 422 | 423 | include 424 | 425 | 426 | include 427 | 428 | 429 | include 430 | 431 | 432 | include 433 | 434 | 435 | include 436 | 437 | 438 | include 439 | 440 | 441 | include 442 | 443 | 444 | include 445 | 446 | 447 | include 448 | 449 | 450 | include 451 | 452 | 453 | include 454 | 455 | 456 | include 457 | 458 | 459 | include 460 | 461 | 462 | include 463 | 464 | 465 | include 466 | 467 | 468 | include 469 | 470 | 471 | cefclient 472 | 473 | 474 | cefclient 475 | 476 | 477 | cefclient 478 | 479 | 480 | cefclient 481 | 482 | 483 | cefclient 484 | 485 | 486 | Generated Files 487 | 488 | 489 | cefclient 490 | 491 | 492 | cefclient 493 | 494 | 495 | cefclient 496 | 497 | 498 | cefclient 499 | 500 | 501 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient/cefclient.cpp: -------------------------------------------------------------------------------- 1 | #include "cefclient/cefclient.h" 2 | #include 3 | #include "include/cef_app.h" 4 | #include "include/cef_client.h" 5 | #include "cefclient/client_app.h" 6 | 7 | #include 8 | 9 | // Whether to use a separate sub-process executable? cefclient_process.exe 10 | //#define SUB_PROCESS_DISABLED 11 | 12 | namespace { 13 | 14 | // Initialize the CEF settings. 15 | void CefInitSettings(CefSettings& settings) { 16 | // Make browser process message loop run in a separate thread. 17 | settings.multi_threaded_message_loop = true; 18 | // Store cache data will on disk. 19 | std::string cache_path = AppGetWorkingDirectory().toStdString() + "/.cache"; 20 | CefString(&settings.cache_path) = CefString(cache_path); 21 | // Completely disable logging. 22 | settings.log_severity = LOGSEVERITY_DISABLE; 23 | // The resources(cef.pak and/or devtools_resources.pak) directory. 24 | CefString(&settings.resources_dir_path) = CefString(); 25 | // The locales directory. 26 | CefString(&settings.locales_dir_path) = CefString(); 27 | // Enable remote debugging on the specified port. 28 | settings.remote_debugging_port = 8088; 29 | // Ignore errors related to invalid SSL certificates. 30 | //settings.ignore_certificate_errors = true; 31 | } 32 | 33 | } // namespace 34 | 35 | CefRefPtr g_handler; 36 | 37 | int CefInit(int &argc, char **argv) { 38 | qDebug() << __FUNCTION__; 39 | HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL); 40 | 41 | CefMainArgs main_args(hInstance); 42 | CefRefPtr app(new ClientApp); 43 | 44 | #ifdef SUB_PROCESS_DISABLED 45 | // Execute the secondary process, if any. 46 | int exit_code = CefExecuteProcess(main_args, app.get()); 47 | if (exit_code >= 0) 48 | return exit_code; 49 | #endif 50 | 51 | CefSettings settings; 52 | CefInitSettings(settings); 53 | 54 | #ifndef SUB_PROCESS_DISABLED 55 | // Specify the path for the sub-process executable. 56 | CefString(&settings.browser_subprocess_path).FromASCII("cefclient_process.exe"); 57 | #endif 58 | 59 | // Initialize CEF. 60 | CefInitialize(main_args, settings, app.get()); 61 | 62 | g_handler = new ClientHandler(); 63 | 64 | return -1; 65 | } 66 | 67 | void CefLoadPlugins(bool isWow64) { 68 | // Adobe Flash Player plug-in: 69 | // https://support.google.com/chrome/answer/108086 70 | // How to load chrome flash plugin: 71 | // https://code.google.com/p/chromiumembedded/issues/detail?id=130 72 | 73 | // Load flash system plug-in on Windows. 74 | CefString flash_plugin_dir = isWow64 ? "C:\\Windows\\SysWOW64\\Macromed\\Flash" 75 | : "C:\\Windows\\System32\\Macromed\\Flash"; 76 | CefAddWebPluginDirectory(flash_plugin_dir); 77 | 78 | CefRefreshWebPlugins(); 79 | } 80 | 81 | void CefQuit() { 82 | qDebug() << __FUNCTION__; 83 | // Shut down CEF. 84 | CefShutdown(); 85 | } 86 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient/cefclient.h: -------------------------------------------------------------------------------- 1 | #ifndef CEFCLIENT_CEFCLIENT_H_ 2 | #define CEFCLIENT_CEFCLIENT_H_ 3 | #pragma once 4 | 5 | #include 6 | #include "include/cef_base.h" 7 | #include "cefclient/client_handler.h" 8 | 9 | // Initialize CEF. 10 | int CefInit(int &argc, char **argv); 11 | 12 | // Load web plugins. 13 | void CefLoadPlugins(bool isWow64); 14 | 15 | // Quit CEF. 16 | void CefQuit(); 17 | 18 | // Quit CEF until all browser windows have closed. 19 | /*unavailable*/ void CefQuitUntilAllBrowserClosed(); 20 | 21 | // Returns the application working directory. 22 | QString AppGetWorkingDirectory(); 23 | 24 | // Notify all browser windows have closed. 25 | /*internal*/ void NotifyAllBrowserClosed(); 26 | 27 | #endif // CEFCLIENT_CEFCLIENT_H_ 28 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient/cefclient_qt.cpp: -------------------------------------------------------------------------------- 1 | #include "cefclient/cefclient.h" 2 | #include 3 | 4 | #include 5 | 6 | extern CefRefPtr g_handler; 7 | 8 | void CefQuitUntilAllBrowserClosed() { 9 | qDebug() << __FUNCTION__ << __LINE__; 10 | if (ClientHandler::m_BrowserCount > 0 && g_handler.get()) { 11 | g_handler->CloseAllBrowsers(false); 12 | // TODO Wait until all browser windows have closed. 13 | } 14 | qDebug() << __FUNCTION__ << __LINE__; 15 | CefQuit(); 16 | } 17 | 18 | QString AppGetWorkingDirectory() { 19 | return qApp->applicationDirPath(); 20 | } 21 | 22 | void NotifyAllBrowserClosed() { 23 | qDebug() << __FUNCTION__; 24 | // Notify all browser windows have closed. 25 | } -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_app.cpp: -------------------------------------------------------------------------------- 1 | #include "client_app.h" // NOLINT(build/include) 2 | 3 | #include 4 | 5 | #include "include/cef_cookie.h" 6 | #include "include/cef_process_message.h" 7 | #include "include/cef_task.h" 8 | #include "include/cef_v8.h" 9 | #include "util.h" // NOLINT(build/include) 10 | #include "cefclient/client_transfer.h" 11 | #include "cefclient/client_app_js.h" 12 | 13 | namespace { 14 | 15 | // Handles the native implementation for the client_app extension. 16 | class ClientAppExtensionHandler : public CefV8Handler { 17 | public: 18 | explicit ClientAppExtensionHandler(CefRefPtr client_app) 19 | : client_app_(client_app) { 20 | } 21 | 22 | virtual bool Execute(const CefString& name, 23 | CefRefPtr object, 24 | const CefV8ValueList& arguments, 25 | CefRefPtr& retval, 26 | CefString& exception) { 27 | bool handled = false; 28 | 29 | if (name == JS_FUNC_SENDMESSAGE && arguments.size() >= 1) { 30 | CefRefPtr browser = 31 | CefV8Context::GetCurrentContext()->GetBrowser(); 32 | ASSERT(browser.get()); 33 | 34 | CefRefPtr message = CefProcessMessage::Create(name); 35 | 36 | cefclient::SetList(arguments, message->GetArgumentList()); 37 | 38 | browser->SendProcessMessage(PID_BROWSER, message); 39 | handled = true; 40 | } 41 | 42 | if (!handled) 43 | exception = "Invalid method arguments"; 44 | 45 | return true; 46 | } 47 | 48 | private: 49 | CefRefPtr client_app_; 50 | 51 | IMPLEMENT_REFCOUNTING(ClientAppExtensionHandler); 52 | }; 53 | 54 | } // namespace 55 | 56 | 57 | ClientApp::ClientApp() { 58 | CreateBrowserDelegates(browser_delegates_); 59 | CreateRenderDelegates(render_delegates_); 60 | 61 | // Default schemes that support cookies. 62 | //cookieable_schemes_.push_back("http"); 63 | //cookieable_schemes_.push_back("https"); 64 | } 65 | 66 | void ClientApp::OnContextInitialized() { 67 | // Register cookieable schemes with the global cookie manager. 68 | //CefRefPtr manager = CefCookieManager::GetGlobalManager(); 69 | //ASSERT(manager.get()); 70 | //manager->SetSupportedSchemes(cookieable_schemes_); 71 | 72 | BrowserDelegateSet::iterator it = browser_delegates_.begin(); 73 | for (; it != browser_delegates_.end(); ++it) 74 | (*it)->OnContextInitialized(this); 75 | } 76 | 77 | void ClientApp::OnBeforeChildProcessLaunch( 78 | CefRefPtr command_line) { 79 | BrowserDelegateSet::iterator it = browser_delegates_.begin(); 80 | for (; it != browser_delegates_.end(); ++it) 81 | (*it)->OnBeforeChildProcessLaunch(this, command_line); 82 | } 83 | 84 | void ClientApp::OnRenderProcessThreadCreated( 85 | CefRefPtr extra_info) { 86 | BrowserDelegateSet::iterator it = browser_delegates_.begin(); 87 | for (; it != browser_delegates_.end(); ++it) 88 | (*it)->OnRenderProcessThreadCreated(this, extra_info); 89 | } 90 | 91 | void ClientApp::OnRenderThreadCreated(CefRefPtr extra_info) { 92 | RenderDelegateSet::iterator it = render_delegates_.begin(); 93 | for (; it != render_delegates_.end(); ++it) 94 | (*it)->OnRenderThreadCreated(this, extra_info); 95 | } 96 | 97 | void ClientApp::OnWebKitInitialized() { 98 | // Register the client_app extension. 99 | std::string app_code = 100 | "var app;" 101 | "if (!app) {" 102 | " app = {" 103 | " sendMessage: function(/*one or more*/) {" 104 | " native function sendMessage();" 105 | " return sendMessage.apply(this, Array.prototype.slice.call(arguments));" 106 | " }" 107 | " }" 108 | "}"; 109 | CefRegisterExtension("v8/app", app_code, 110 | new ClientAppExtensionHandler(this)); 111 | 112 | RenderDelegateSet::iterator it = render_delegates_.begin(); 113 | for (; it != render_delegates_.end(); ++it) 114 | (*it)->OnWebKitInitialized(this); 115 | } 116 | 117 | void ClientApp::OnBrowserCreated(CefRefPtr browser) { 118 | RenderDelegateSet::iterator it = render_delegates_.begin(); 119 | for (; it != render_delegates_.end(); ++it) 120 | (*it)->OnBrowserCreated(this, browser); 121 | } 122 | 123 | void ClientApp::OnBrowserDestroyed(CefRefPtr browser) { 124 | RenderDelegateSet::iterator it = render_delegates_.begin(); 125 | for (; it != render_delegates_.end(); ++it) 126 | (*it)->OnBrowserDestroyed(this, browser); 127 | } 128 | 129 | CefRefPtr ClientApp::GetLoadHandler() { 130 | CefRefPtr load_handler; 131 | 132 | RenderDelegateSet::iterator it = render_delegates_.begin(); 133 | for (; it != render_delegates_.end() && !load_handler.get(); ++it) 134 | load_handler = (*it)->GetLoadHandler(this); 135 | 136 | return load_handler; 137 | } 138 | 139 | bool ClientApp::OnBeforeNavigation(CefRefPtr browser, 140 | CefRefPtr frame, 141 | CefRefPtr request, 142 | NavigationType navigation_type, 143 | bool is_redirect) { 144 | RenderDelegateSet::iterator it = render_delegates_.begin(); 145 | for (; it != render_delegates_.end(); ++it) { 146 | if ((*it)->OnBeforeNavigation(this, browser, frame, request, 147 | navigation_type, is_redirect)) { 148 | return true; 149 | } 150 | } 151 | 152 | return false; // Allow the navigation to proceed. 153 | } 154 | 155 | void ClientApp::OnContextCreated(CefRefPtr browser, 156 | CefRefPtr frame, 157 | CefRefPtr context) { 158 | RenderDelegateSet::iterator it = render_delegates_.begin(); 159 | for (; it != render_delegates_.end(); ++it) 160 | (*it)->OnContextCreated(this, browser, frame, context); 161 | } 162 | 163 | void ClientApp::OnContextReleased(CefRefPtr browser, 164 | CefRefPtr frame, 165 | CefRefPtr context) { 166 | RenderDelegateSet::iterator it = render_delegates_.begin(); 167 | for (; it != render_delegates_.end(); ++it) 168 | (*it)->OnContextReleased(this, browser, frame, context); 169 | } 170 | 171 | void ClientApp::OnUncaughtException(CefRefPtr browser, 172 | CefRefPtr frame, 173 | CefRefPtr context, 174 | CefRefPtr exception, 175 | CefRefPtr stackTrace) { 176 | RenderDelegateSet::iterator it = render_delegates_.begin(); 177 | for (; it != render_delegates_.end(); ++it) { 178 | (*it)->OnUncaughtException(this, browser, frame, context, exception, 179 | stackTrace); 180 | } 181 | } 182 | 183 | void ClientApp::OnFocusedNodeChanged(CefRefPtr browser, 184 | CefRefPtr frame, 185 | CefRefPtr node) { 186 | RenderDelegateSet::iterator it = render_delegates_.begin(); 187 | for (; it != render_delegates_.end(); ++it) 188 | (*it)->OnFocusedNodeChanged(this, browser, frame, node); 189 | } 190 | 191 | bool ClientApp::OnProcessMessageReceived( 192 | CefRefPtr browser, 193 | CefProcessId source_process, 194 | CefRefPtr message) { 195 | ASSERT(source_process == PID_BROWSER); 196 | 197 | bool handled = false; 198 | 199 | RenderDelegateSet::iterator it = render_delegates_.begin(); 200 | for (; it != render_delegates_.end() && !handled; ++it) { 201 | handled = (*it)->OnProcessMessageReceived(this, browser, source_process, 202 | message); 203 | } 204 | 205 | if (handled) 206 | return true; 207 | 208 | return handled; 209 | } -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_app.h: -------------------------------------------------------------------------------- 1 | #ifndef CEFCLIENT_CLIENT_APP_H_ 2 | #define CEFCLIENT_CLIENT_APP_H_ 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "include/cef_app.h" 11 | 12 | class ClientApp : public CefApp, 13 | public CefResourceBundleHandler, 14 | public CefBrowserProcessHandler, 15 | public CefRenderProcessHandler { 16 | public: 17 | // Interface for browser delegates. All BrowserDelegates must be returned via 18 | // CreateBrowserDelegates. Do not perform work in the BrowserDelegate 19 | // constructor. See CefBrowserProcessHandler for documentation. 20 | class BrowserDelegate : public virtual CefBase { 21 | public: 22 | virtual void OnContextInitialized(CefRefPtr app) {} 23 | 24 | virtual void OnBeforeChildProcessLaunch( 25 | CefRefPtr app, 26 | CefRefPtr command_line) {} 27 | 28 | virtual void OnRenderProcessThreadCreated( 29 | CefRefPtr app, 30 | CefRefPtr extra_info) {} 31 | }; 32 | 33 | typedef std::set > BrowserDelegateSet; 34 | 35 | // Interface for renderer delegates. All RenderDelegates must be returned via 36 | // CreateRenderDelegates. Do not perform work in the RenderDelegate 37 | // constructor. See CefRenderProcessHandler for documentation. 38 | class RenderDelegate : public virtual CefBase { 39 | public: 40 | virtual void OnRenderThreadCreated(CefRefPtr app, 41 | CefRefPtr extra_info) {} 42 | 43 | virtual void OnWebKitInitialized(CefRefPtr app) {} 44 | 45 | virtual void OnBrowserCreated(CefRefPtr app, 46 | CefRefPtr browser) {} 47 | 48 | virtual void OnBrowserDestroyed(CefRefPtr app, 49 | CefRefPtr browser) {} 50 | 51 | virtual CefRefPtr GetLoadHandler(CefRefPtr app) { 52 | return NULL; 53 | } 54 | 55 | virtual bool OnBeforeNavigation(CefRefPtr app, 56 | CefRefPtr browser, 57 | CefRefPtr frame, 58 | CefRefPtr request, 59 | cef_navigation_type_t navigation_type, 60 | bool is_redirect) { 61 | return false; // Allow the navigation to proceed. 62 | } 63 | 64 | virtual void OnContextCreated(CefRefPtr app, 65 | CefRefPtr browser, 66 | CefRefPtr frame, 67 | CefRefPtr context) {} 68 | 69 | virtual void OnContextReleased(CefRefPtr app, 70 | CefRefPtr browser, 71 | CefRefPtr frame, 72 | CefRefPtr context) {} 73 | 74 | virtual void OnUncaughtException(CefRefPtr app, 75 | CefRefPtr browser, 76 | CefRefPtr frame, 77 | CefRefPtr context, 78 | CefRefPtr exception, 79 | CefRefPtr stackTrace) {} 80 | 81 | virtual void OnFocusedNodeChanged(CefRefPtr app, 82 | CefRefPtr browser, 83 | CefRefPtr frame, 84 | CefRefPtr node) {} 85 | 86 | // Called when a process message is received. Return true if the message was 87 | // handled and should not be passed on to other handlers. RenderDelegates 88 | // should check for unique message names to avoid interfering with each 89 | // other. 90 | virtual bool OnProcessMessageReceived( 91 | CefRefPtr app, 92 | CefRefPtr browser, 93 | CefProcessId source_process, 94 | CefRefPtr message) { 95 | return false; 96 | } 97 | }; 98 | 99 | typedef std::set > RenderDelegateSet; 100 | 101 | ClientApp(); 102 | 103 | private: 104 | // Creates all of the BrowserDelegate objects. Implemented in 105 | // client_app_delegates. 106 | static void CreateBrowserDelegates(BrowserDelegateSet& delegates); 107 | 108 | // Creates all of the RenderDelegate objects. Implemented in 109 | // client_app_delegates. 110 | static void CreateRenderDelegates(RenderDelegateSet& delegates); 111 | 112 | // Registers custom schemes. Implemented in client_app_delegates. 113 | static void RegisterCustomSchemes(CefRefPtr registrar, 114 | std::vector& cookiable_schemes); 115 | 116 | // CefApp methods. 117 | virtual void OnBeforeCommandLineProcessing( 118 | const CefString& process_type, 119 | CefRefPtr command_line) OVERRIDE { 120 | } 121 | virtual void OnRegisterCustomSchemes( 122 | CefRefPtr registrar) OVERRIDE { 123 | RegisterCustomSchemes(registrar, cookieable_schemes_); 124 | } 125 | virtual CefRefPtr GetResourceBundleHandler() 126 | OVERRIDE { return this; } 127 | virtual CefRefPtr GetBrowserProcessHandler() 128 | OVERRIDE { return this; } 129 | virtual CefRefPtr GetRenderProcessHandler() 130 | OVERRIDE { return this; } 131 | 132 | // CefResourceBundleHandler methods. 133 | virtual bool GetLocalizedString(int message_id, 134 | CefString& string) OVERRIDE { 135 | return false; // Use the default translation. 136 | }; 137 | virtual bool GetDataResource(int resource_id, 138 | void*& data, 139 | size_t& data_size) OVERRIDE { 140 | return false; // Use the default resource data. 141 | } 142 | 143 | // CefBrowserProcessHandler methods. 144 | virtual void OnContextInitialized() OVERRIDE; 145 | virtual void OnBeforeChildProcessLaunch( 146 | CefRefPtr command_line) OVERRIDE; 147 | virtual void OnRenderProcessThreadCreated(CefRefPtr extra_info) 148 | OVERRIDE; 149 | 150 | // CefRenderProcessHandler methods. 151 | virtual void OnRenderThreadCreated(CefRefPtr extra_info) 152 | OVERRIDE; 153 | virtual void OnWebKitInitialized() OVERRIDE; 154 | virtual void OnBrowserCreated(CefRefPtr browser) OVERRIDE; 155 | virtual void OnBrowserDestroyed(CefRefPtr browser) OVERRIDE; 156 | virtual CefRefPtr GetLoadHandler() OVERRIDE; 157 | virtual bool OnBeforeNavigation(CefRefPtr browser, 158 | CefRefPtr frame, 159 | CefRefPtr request, 160 | NavigationType navigation_type, 161 | bool is_redirect) OVERRIDE; 162 | virtual void OnContextCreated(CefRefPtr browser, 163 | CefRefPtr frame, 164 | CefRefPtr context) OVERRIDE; 165 | virtual void OnContextReleased(CefRefPtr browser, 166 | CefRefPtr frame, 167 | CefRefPtr context) OVERRIDE; 168 | virtual void OnUncaughtException(CefRefPtr browser, 169 | CefRefPtr frame, 170 | CefRefPtr context, 171 | CefRefPtr exception, 172 | CefRefPtr stackTrace) 173 | OVERRIDE; 174 | virtual void OnFocusedNodeChanged(CefRefPtr browser, 175 | CefRefPtr frame, 176 | CefRefPtr node) OVERRIDE; 177 | virtual bool OnProcessMessageReceived( 178 | CefRefPtr browser, 179 | CefProcessId source_process, 180 | CefRefPtr message) OVERRIDE; 181 | 182 | // Set of supported BrowserDelegates. 183 | BrowserDelegateSet browser_delegates_; 184 | 185 | // Set of supported RenderDelegates. 186 | RenderDelegateSet render_delegates_; 187 | 188 | // Schemes that will be registered with the global cookie manager. 189 | std::vector cookieable_schemes_; 190 | 191 | IMPLEMENT_REFCOUNTING(ClientApp); 192 | }; 193 | 194 | #endif // CEFCLIENT_CLIENT_APP_H_ -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_app_delegates.cpp: -------------------------------------------------------------------------------- 1 | #include "cefclient/client_app.h" 2 | #include "cefclient/client_renderer.h" 3 | 4 | // static 5 | void ClientApp::CreateBrowserDelegates(BrowserDelegateSet& delegates) { 6 | } 7 | 8 | // static 9 | void ClientApp::CreateRenderDelegates(RenderDelegateSet& delegates) { 10 | client_renderer::CreateRenderDelegates(delegates); 11 | } 12 | 13 | // static 14 | void ClientApp::RegisterCustomSchemes( 15 | CefRefPtr registrar, 16 | std::vector& cookiable_schemes) { 17 | } 18 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_app_js.h: -------------------------------------------------------------------------------- 1 | #ifndef CEFCLIENT_CLIENT_APP_JS_H_ 2 | #define CEFCLIENT_CLIENT_APP_JS_H_ 3 | #pragma once 4 | 5 | #define JS_FUNC_SENDMESSAGE "sendMessage" 6 | 7 | #endif // CEFCLIENT_CLIENT_APP_JS_H_ -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_binding.cpp: -------------------------------------------------------------------------------- 1 | #include "client_binding.h" 2 | #include "cefclient/client_transfer.h" 3 | #include "cefclient/message_event.h" 4 | #include "cefclient/client_app_js.h" 5 | 6 | extern CefRefPtr g_handler; 7 | 8 | namespace client_binding { 9 | 10 | namespace { 11 | 12 | // Handle messages in the browser process. 13 | class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate { 14 | public: 15 | ProcessMessageDelegate() { 16 | } 17 | 18 | // From ClientHandler::ProcessMessageDelegate. 19 | virtual bool OnProcessMessageReceived( 20 | CefRefPtr handler, 21 | CefRefPtr browser, 22 | CefProcessId source_process, 23 | CefRefPtr message) OVERRIDE { 24 | CefString name = message->GetName(); 25 | 26 | if (name == JS_FUNC_SENDMESSAGE) { 27 | 28 | if (g_handler.get() && g_handler->listener()) { 29 | CefRefPtr args = message->GetArgumentList(); 30 | QVariantList message_args; 31 | cefclient::SetList(args, message_args); 32 | 33 | QString message_name = QString::fromStdWString(name.ToWString()); 34 | MessageEvent* e = new MessageEvent(message_name, message_args); 35 | g_handler->listener()->OnMessageEvent(e); 36 | 37 | return true; 38 | } 39 | 40 | } 41 | 42 | return false; 43 | } 44 | 45 | IMPLEMENT_REFCOUNTING(ProcessMessageDelegate); 46 | }; 47 | 48 | } // namespace 49 | 50 | void CreateProcessMessageDelegates( 51 | ClientHandler::ProcessMessageDelegateSet& delegates) { 52 | delegates.insert(new ProcessMessageDelegate); 53 | } 54 | 55 | } // namespace client_binding 56 | 57 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_binding.h: -------------------------------------------------------------------------------- 1 | #ifndef CEFCLIENT_CLIENT_BINDING_H 2 | #define CEFCLIENT_CLIENT_BINDING_H 3 | #pragma once 4 | 5 | #include "cefclient/client_handler.h" 6 | 7 | namespace client_binding { 8 | 9 | // Delegate creation. Called from ClientHandler. 10 | void CreateProcessMessageDelegates( 11 | ClientHandler::ProcessMessageDelegateSet& delegates); 12 | 13 | } // namespace client_binding 14 | 15 | #endif // CEFCLIENT_CLIENT_BINDING_H -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_handler.cpp: -------------------------------------------------------------------------------- 1 | #include "client_handler.h" 2 | #include 3 | #include 4 | #include 5 | #include "include/cef_browser.h" 6 | #include "include/cef_frame.h" 7 | #include "include/cef_runnable.h" 8 | #include "cefclient/cefclient.h" 9 | #include "cefclient/client_renderer.h" 10 | #include "cefclient/client_binding.h" 11 | 12 | #include 13 | 14 | namespace { 15 | 16 | // Custom menu command Ids. 17 | enum client_menu_ids { 18 | CLIENT_ID_SHOW_DEVTOOLS = MENU_ID_USER_FIRST, 19 | }; 20 | 21 | } // namespace 22 | 23 | int ClientHandler::m_BrowserCount = 0; 24 | 25 | ClientHandler::ClientHandler() 26 | : m_BrowserId(0), 27 | m_bIsClosing(false), 28 | m_bFocusOnEditableField(false) { 29 | CreateProcessMessageDelegates(process_message_delegates_); 30 | 31 | if (m_StartupURL.empty()) 32 | m_StartupURL = "about:blank"; 33 | } 34 | 35 | ClientHandler::~ClientHandler() { 36 | } 37 | 38 | bool ClientHandler::OnProcessMessageReceived( 39 | CefRefPtr browser, 40 | CefProcessId source_process, 41 | CefRefPtr message) { 42 | // Check for messages from the client renderer. 43 | std::string message_name = message->GetName(); 44 | if (message_name == client_renderer::kFocusedNodeChangedMessage) { 45 | // A message is sent from ClientRenderDelegate to tell us whether the 46 | // currently focused DOM node is editable. Use of |m_bFocusOnEditableField| 47 | // is redundant with CefKeyEvent.focus_on_editable_field in OnPreKeyEvent 48 | // but is useful for demonstration purposes. 49 | m_bFocusOnEditableField = message->GetArgumentList()->GetBool(0); 50 | return true; 51 | } 52 | 53 | bool handled = false; 54 | 55 | // Execute delegate callbacks. 56 | ProcessMessageDelegateSet::iterator it = process_message_delegates_.begin(); 57 | for (; it != process_message_delegates_.end() && !handled; ++it) { 58 | handled = (*it)->OnProcessMessageReceived(this, browser, source_process, 59 | message); 60 | } 61 | 62 | return handled; 63 | } 64 | 65 | void ClientHandler::OnBeforeContextMenu( 66 | CefRefPtr browser, 67 | CefRefPtr frame, 68 | CefRefPtr params, 69 | CefRefPtr model) { 70 | if ((params->GetTypeFlags() & (CM_TYPEFLAG_PAGE | CM_TYPEFLAG_FRAME)) != 0) { 71 | // Clear all context menus. 72 | //model->Clear(); 73 | 74 | // Clear all context menus except MENU_ID_VIEW_SOURCE. 75 | int count = model->GetCount(); 76 | for (int i = count - 1; i >=0; i--) { 77 | if (model->GetCommandIdAt(i) != MENU_ID_VIEW_SOURCE) { 78 | model->RemoveAt(i); 79 | } 80 | } 81 | 82 | // Add a "Show DevTools" item to all context menus. 83 | model->AddItem(CLIENT_ID_SHOW_DEVTOOLS, "&Show DevTools"); 84 | 85 | CefString devtools_url = browser->GetHost()->GetDevToolsURL(true); 86 | if (devtools_url.empty() || 87 | m_OpenDevToolsURLs.find(devtools_url) != m_OpenDevToolsURLs.end()) { 88 | // Disable the menu option if DevTools isn't enabled or if a window is 89 | // already open for the current URL. 90 | model->SetEnabled(CLIENT_ID_SHOW_DEVTOOLS, false); 91 | } 92 | } 93 | } 94 | 95 | bool ClientHandler::OnContextMenuCommand( 96 | CefRefPtr browser, 97 | CefRefPtr frame, 98 | CefRefPtr params, 99 | int command_id, 100 | EventFlags event_flags) { 101 | switch (command_id) { 102 | case CLIENT_ID_SHOW_DEVTOOLS: 103 | ShowDevTools(browser); 104 | return true; 105 | default: // Allow default handling, if any. 106 | return false; 107 | } 108 | } 109 | 110 | bool ClientHandler::OnConsoleMessage(CefRefPtr browser, 111 | const CefString& message, 112 | const CefString& source, 113 | int line) { 114 | return false; // Output the message to the console. 115 | } 116 | 117 | void ClientHandler::OnBeforeDownload( 118 | CefRefPtr browser, 119 | CefRefPtr download_item, 120 | const CefString& suggested_name, 121 | CefRefPtr callback) { 122 | REQUIRE_UI_THREAD(); 123 | } 124 | 125 | void ClientHandler::OnDownloadUpdated( 126 | CefRefPtr browser, 127 | CefRefPtr download_item, 128 | CefRefPtr callback) { 129 | REQUIRE_UI_THREAD(); 130 | /*if (download_item->IsComplete()) { 131 | }*/ 132 | } 133 | 134 | bool ClientHandler::OnDragEnter(CefRefPtr browser, 135 | CefRefPtr dragData, 136 | DragOperationsMask mask) { 137 | REQUIRE_UI_THREAD(); 138 | 139 | // Forbid dragging of link URLs. 140 | if (mask & DRAG_OPERATION_LINK) 141 | return true; 142 | 143 | return false; 144 | } 145 | 146 | void ClientHandler::OnRequestGeolocationPermission( 147 | CefRefPtr browser, 148 | const CefString& requesting_url, 149 | int request_id, 150 | CefRefPtr callback) { 151 | // Allow geolocation access from all websites. 152 | callback->Continue(true); 153 | } 154 | 155 | 156 | bool ClientHandler::OnPreKeyEvent(CefRefPtr browser, 157 | const CefKeyEvent& event, 158 | CefEventHandle os_event, 159 | bool* is_keyboard_shortcut) { 160 | return false; 161 | } 162 | 163 | bool ClientHandler::OnBeforePopup(CefRefPtr browser, 164 | CefRefPtr frame, 165 | const CefString& target_url, 166 | const CefString& target_frame_name, 167 | const CefPopupFeatures& popupFeatures, 168 | CefWindowInfo& windowInfo, 169 | CefRefPtr& client, 170 | CefBrowserSettings& settings, 171 | bool* no_javascript_access) { 172 | if (browser->GetHost()->IsWindowRenderingDisabled()) { 173 | // Cancel popups in off-screen rendering mode. 174 | return true; 175 | } 176 | return false; 177 | } 178 | 179 | void ClientHandler::OnAfterCreated(CefRefPtr browser) { 180 | REQUIRE_UI_THREAD(); 181 | 182 | AutoLock lock_scope(this); 183 | if (!m_Browser.get()) { 184 | // We need to keep the main child window, but not popup windows 185 | m_Browser = browser; 186 | m_BrowserId = browser->GetIdentifier(); 187 | if (listener_) { 188 | listener_->OnAfterCreated(); 189 | } 190 | } else if (browser->IsPopup()) { 191 | // Add to the list of popup browsers. 192 | m_PopupBrowsers.push_back(browser); 193 | } 194 | 195 | m_BrowserCount++; 196 | } 197 | 198 | bool ClientHandler::DoClose(CefRefPtr browser) { 199 | REQUIRE_UI_THREAD(); 200 | 201 | // Closing the main window requires special handling. See the DoClose() 202 | // documentation in the CEF header for a detailed destription of this 203 | // process. 204 | if (m_BrowserId == browser->GetIdentifier()) { 205 | // Notify the browser that the parent window is about to close. 206 | browser->GetHost()->ParentWindowWillClose(); 207 | 208 | // Set a flag to indicate that the window close should be allowed. 209 | m_bIsClosing = true; 210 | } 211 | 212 | // Allow the close. For windowed browsers this will result in the OS close 213 | // event being sent. 214 | return false; 215 | } 216 | 217 | void ClientHandler::OnBeforeClose(CefRefPtr browser) { 218 | REQUIRE_UI_THREAD(); 219 | 220 | if (m_BrowserId == browser->GetIdentifier()) { 221 | // Free the browser pointer so that the browser can be destroyed 222 | m_Browser = NULL; 223 | } else if (browser->IsPopup()) { 224 | // Remove the record for DevTools popup windows. 225 | std::set::iterator it = 226 | m_OpenDevToolsURLs.find(browser->GetMainFrame()->GetURL()); 227 | if (it != m_OpenDevToolsURLs.end()) 228 | m_OpenDevToolsURLs.erase(it); 229 | 230 | // Remove from the browser popup list. 231 | BrowserList::iterator bit = m_PopupBrowsers.begin(); 232 | for (; bit != m_PopupBrowsers.end(); ++bit) { 233 | if ((*bit)->IsSame(browser)) { 234 | m_PopupBrowsers.erase(bit); 235 | break; 236 | } 237 | } 238 | } 239 | 240 | if (--m_BrowserCount == 0) { 241 | NotifyAllBrowserClosed(); 242 | } 243 | } 244 | 245 | void ClientHandler::OnLoadingStateChange(CefRefPtr browser, 246 | bool isLoading, 247 | bool canGoBack, 248 | bool canGoForward) { 249 | REQUIRE_UI_THREAD(); 250 | 251 | //SetLoading(isLoading); // For overall browser load status. 252 | SetNavState(canGoBack, canGoForward); 253 | } 254 | 255 | void ClientHandler::OnLoadStart(CefRefPtr browser, 256 | CefRefPtr frame) { 257 | REQUIRE_UI_THREAD(); 258 | 259 | if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) { 260 | SetLoading(true); 261 | } 262 | } 263 | 264 | void ClientHandler::OnLoadEnd(CefRefPtr browser, 265 | CefRefPtr frame, 266 | int httpStatusCode) { 267 | REQUIRE_UI_THREAD(); 268 | 269 | if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) { 270 | SetLoading(false); 271 | } 272 | } 273 | 274 | void ClientHandler::OnLoadError(CefRefPtr browser, 275 | CefRefPtr frame, 276 | ErrorCode errorCode, 277 | const CefString& errorText, 278 | const CefString& failedUrl) { 279 | REQUIRE_UI_THREAD(); 280 | 281 | // Don't display an error for downloaded files. 282 | if (errorCode == ERR_ABORTED) 283 | return; 284 | 285 | // Don't display an error for external protocols that we allow the OS to 286 | // handle. See OnProtocolExecution(). 287 | if (errorCode == ERR_UNKNOWN_URL_SCHEME) { 288 | std::string urlStr = frame->GetURL(); 289 | if (urlStr.find("spotify:") == 0) 290 | return; 291 | } 292 | 293 | // Display a load error message. 294 | std::stringstream ss; 295 | //ss << "" 296 | // "

Failed to load URL " << std::string(failedUrl) << 297 | // " with error " << std::string(errorText) << " (" << errorCode << 298 | // ").

"; 299 | //frame->LoadString(ss.str(), failedUrl); 300 | 301 | // Issue: It will repeated load the url which is a not existed file path on 302 | // Win32 CEF 3.1650.1522,1544. 303 | // 1. You need load the file:/// (not exists) several times. 304 | // 2. It jumps to about:blank after the first time, then load the url again. 305 | // 3. It also jumps to about:blank and repeated load, but finally displays 306 | // LoadString() on Win32 CEF 3.1547.1551. Sometimes also repeated load forever. 307 | // 4. It will directly repeated load if you stop loading m_StartupURL. 308 | // 5. It doesn't go into OnRenderProcessTerminated().er 309 | // Also have been tested with its own cefclient project. 310 | 311 | ss << "Failed to load URL " << std::string(failedUrl) << 312 | " with error " << std::string(errorText) << " (" << errorCode << ")."; 313 | qDebug() << __FUNCTION__ << QString::fromStdString(ss.str()); 314 | } 315 | 316 | CefRefPtr ClientHandler::GetResourceHandler( 317 | CefRefPtr browser, 318 | CefRefPtr frame, 319 | CefRefPtr request) { 320 | return NULL; 321 | } 322 | 323 | bool ClientHandler::OnQuotaRequest(CefRefPtr browser, 324 | const CefString& origin_url, 325 | int64 new_size, 326 | CefRefPtr callback) { 327 | static const int64 max_size = 1024 * 1024 * 20; // 20mb. 328 | 329 | // Grant the quota request if the size is reasonable. 330 | callback->Continue(new_size <= max_size); 331 | return true; 332 | } 333 | 334 | void ClientHandler::OnProtocolExecution(CefRefPtr browser, 335 | const CefString& url, 336 | bool& allow_os_execution) { 337 | } 338 | 339 | void ClientHandler::OnRenderProcessTerminated(CefRefPtr browser, 340 | TerminationStatus status) { 341 | // Load the startup URL if that's not the website that we terminated on. 342 | CefRefPtr frame = browser->GetMainFrame(); 343 | std::string url = frame->GetURL(); 344 | std::transform(url.begin(), url.end(), url.begin(), tolower); 345 | 346 | std::string startupURL = GetStartupURL(); 347 | if (url.find(startupURL) != 0) 348 | frame->LoadURL(startupURL); 349 | } 350 | 351 | void ClientHandler::CloseAllBrowsers(bool force_close) { 352 | if (!CefCurrentlyOn(TID_UI)) { 353 | // Execute on the UI thread. 354 | CefPostTask(TID_UI, 355 | NewCefRunnableMethod(this, &ClientHandler::CloseAllBrowsers, 356 | force_close)); 357 | return; 358 | } 359 | 360 | if (!m_PopupBrowsers.empty()) { 361 | // Request that any popup browsers close. 362 | BrowserList::const_iterator it = m_PopupBrowsers.begin(); 363 | for (; it != m_PopupBrowsers.end(); ++it) 364 | (*it)->GetHost()->CloseBrowser(force_close); 365 | } 366 | 367 | if (m_Browser.get()) { 368 | // Request that the main browser close. 369 | m_Browser->GetHost()->CloseBrowser(force_close); 370 | } 371 | } 372 | 373 | void ClientHandler::ShowDevTools(CefRefPtr browser) { 374 | std::string devtools_url = browser->GetHost()->GetDevToolsURL(true); 375 | if (!devtools_url.empty()) { 376 | if (m_OpenDevToolsURLs.find(devtools_url) == 377 | m_OpenDevToolsURLs.end()) { 378 | // Open DevTools in a popup window. 379 | m_OpenDevToolsURLs.insert(devtools_url); 380 | browser->GetMainFrame()->ExecuteJavaScript( 381 | "window.open('" + devtools_url + "');", "about:blank", 0); 382 | } 383 | } 384 | } 385 | 386 | // static 387 | void ClientHandler::CreateProcessMessageDelegates( 388 | ProcessMessageDelegateSet& delegates) { 389 | client_binding::CreateProcessMessageDelegates(delegates); 390 | } 391 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_handler.h: -------------------------------------------------------------------------------- 1 | #ifndef CEFCLIENT_CLIENT_HANDLER_H_ 2 | #define CEFCLIENT_CLIENT_HANDLER_H_ 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "include/cef_client.h" 11 | #include "cefclient/util.h" 12 | #include "cefclient/message_event.h" 13 | 14 | // ClientHandler implementation. 15 | class ClientHandler : public CefClient, 16 | public CefContextMenuHandler, 17 | public CefDisplayHandler, 18 | public CefDownloadHandler, 19 | public CefDragHandler, 20 | public CefGeolocationHandler, 21 | public CefKeyboardHandler, 22 | public CefLifeSpanHandler, 23 | public CefLoadHandler, 24 | public CefRequestHandler { 25 | public: 26 | // Interface for process message delegates. Do not perform work in the 27 | // RenderDelegate constructor. 28 | class ProcessMessageDelegate : public virtual CefBase { 29 | public: 30 | // Called when a process message is received. Return true if the message was 31 | // handled and should not be passed on to other handlers. 32 | // ProcessMessageDelegates should check for unique message names to avoid 33 | // interfering with each other. 34 | virtual bool OnProcessMessageReceived( 35 | CefRefPtr handler, 36 | CefRefPtr browser, 37 | CefProcessId source_process, 38 | CefRefPtr message) { 39 | return false; 40 | } 41 | }; 42 | 43 | typedef std::set > 44 | ProcessMessageDelegateSet; 45 | 46 | // Listener interface to be used to handle various events. 47 | class Listener { 48 | public: 49 | virtual ~Listener() {} 50 | 51 | virtual void OnAddressChange(const QString& url) = 0; 52 | virtual void OnTitleChange(const QString& title) = 0; 53 | virtual void SetLoading(bool isLoading) = 0; 54 | virtual void SetNavState(bool canGoBack, bool canGoForward) = 0; 55 | 56 | virtual void OnAfterCreated() = 0; 57 | 58 | virtual void OnMessageEvent(MessageEvent* e) = 0; 59 | }; 60 | 61 | ClientHandler(); 62 | virtual ~ClientHandler(); 63 | 64 | // CefClient methods 65 | virtual CefRefPtr GetContextMenuHandler() OVERRIDE { 66 | return this; 67 | } 68 | virtual CefRefPtr GetDisplayHandler() OVERRIDE { 69 | return this; 70 | } 71 | virtual CefRefPtr GetDownloadHandler() OVERRIDE { 72 | return this; 73 | } 74 | virtual CefRefPtr GetDragHandler() OVERRIDE { 75 | return this; 76 | } 77 | virtual CefRefPtr GetGeolocationHandler() OVERRIDE { 78 | return this; 79 | } 80 | virtual CefRefPtr GetKeyboardHandler() OVERRIDE { 81 | return this; 82 | } 83 | virtual CefRefPtr GetLifeSpanHandler() OVERRIDE { 84 | return this; 85 | } 86 | virtual CefRefPtr GetLoadHandler() OVERRIDE { 87 | return this; 88 | } 89 | virtual CefRefPtr GetRequestHandler() OVERRIDE { 90 | return this; 91 | } 92 | virtual bool OnProcessMessageReceived(CefRefPtr browser, 93 | CefProcessId source_process, 94 | CefRefPtr message) 95 | OVERRIDE; 96 | 97 | // CefContextMenuHandler methods 98 | virtual void OnBeforeContextMenu(CefRefPtr browser, 99 | CefRefPtr frame, 100 | CefRefPtr params, 101 | CefRefPtr model) OVERRIDE; 102 | virtual bool OnContextMenuCommand(CefRefPtr browser, 103 | CefRefPtr frame, 104 | CefRefPtr params, 105 | int command_id, 106 | EventFlags event_flags) OVERRIDE; 107 | 108 | // CefDisplayHandler methods 109 | virtual void OnAddressChange(CefRefPtr browser, 110 | CefRefPtr frame, 111 | const CefString& url) OVERRIDE; 112 | virtual void OnTitleChange(CefRefPtr browser, 113 | const CefString& title) OVERRIDE; 114 | virtual bool OnConsoleMessage(CefRefPtr browser, 115 | const CefString& message, 116 | const CefString& source, 117 | int line) OVERRIDE; 118 | 119 | // CefDownloadHandler methods 120 | virtual void OnBeforeDownload( 121 | CefRefPtr browser, 122 | CefRefPtr download_item, 123 | const CefString& suggested_name, 124 | CefRefPtr callback) OVERRIDE; 125 | virtual void OnDownloadUpdated( 126 | CefRefPtr browser, 127 | CefRefPtr download_item, 128 | CefRefPtr callback) OVERRIDE; 129 | 130 | // CefDragHandler methods 131 | virtual bool OnDragEnter(CefRefPtr browser, 132 | CefRefPtr dragData, 133 | DragOperationsMask mask) OVERRIDE; 134 | 135 | // CefGeolocationHandler methods 136 | virtual void OnRequestGeolocationPermission( 137 | CefRefPtr browser, 138 | const CefString& requesting_url, 139 | int request_id, 140 | CefRefPtr callback) OVERRIDE; 141 | 142 | // CefKeyboardHandler methods 143 | virtual bool OnPreKeyEvent(CefRefPtr browser, 144 | const CefKeyEvent& event, 145 | CefEventHandle os_event, 146 | bool* is_keyboard_shortcut) OVERRIDE; 147 | 148 | // CefLifeSpanHandler methods 149 | virtual bool OnBeforePopup(CefRefPtr browser, 150 | CefRefPtr frame, 151 | const CefString& target_url, 152 | const CefString& target_frame_name, 153 | const CefPopupFeatures& popupFeatures, 154 | CefWindowInfo& windowInfo, 155 | CefRefPtr& client, 156 | CefBrowserSettings& settings, 157 | bool* no_javascript_access) OVERRIDE; 158 | virtual void OnAfterCreated(CefRefPtr browser) OVERRIDE; 159 | virtual bool DoClose(CefRefPtr browser) OVERRIDE; 160 | virtual void OnBeforeClose(CefRefPtr browser) OVERRIDE; 161 | 162 | // CefLoadHandler methods 163 | virtual void OnLoadingStateChange(CefRefPtr browser, 164 | bool isLoading, 165 | bool canGoBack, 166 | bool canGoForward) OVERRIDE; 167 | virtual void OnLoadStart(CefRefPtr browser, 168 | CefRefPtr frame) OVERRIDE; 169 | virtual void OnLoadEnd(CefRefPtr browser, 170 | CefRefPtr frame, 171 | int httpStatusCode) OVERRIDE; 172 | virtual void OnLoadError(CefRefPtr browser, 173 | CefRefPtr frame, 174 | ErrorCode errorCode, 175 | const CefString& errorText, 176 | const CefString& failedUrl) OVERRIDE; 177 | 178 | // CefRequestHandler methods 179 | virtual CefRefPtr GetResourceHandler( 180 | CefRefPtr browser, 181 | CefRefPtr frame, 182 | CefRefPtr request) OVERRIDE; 183 | virtual bool OnQuotaRequest(CefRefPtr browser, 184 | const CefString& origin_url, 185 | int64 new_size, 186 | CefRefPtr callback) OVERRIDE; 187 | virtual void OnProtocolExecution(CefRefPtr browser, 188 | const CefString& url, 189 | bool& allow_os_execution) OVERRIDE; 190 | virtual void OnRenderProcessTerminated(CefRefPtr browser, 191 | TerminationStatus status) OVERRIDE; 192 | virtual bool OnBeforePluginLoad(CefRefPtr browser, 193 | const CefString& url, 194 | const CefString& policy_url, 195 | CefRefPtr info) OVERRIDE { 196 | return false; // Return true to block loading of the plugin. 197 | } 198 | 199 | CefRefPtr GetBrowser() { return m_Browser; } 200 | int GetBrowserId() { return m_BrowserId; } 201 | 202 | // Request that all existing browser windows close. 203 | void CloseAllBrowsers(bool force_close); 204 | 205 | // Returns true if the main browser window is currently closing. Used in 206 | // combination with DoClose() and the OS close notification to properly handle 207 | // 'onbeforeunload' JavaScript events during window close. 208 | bool IsClosing() { return m_bIsClosing; } 209 | 210 | void ShowDevTools(CefRefPtr browser); 211 | 212 | // Returns the startup URL. 213 | std::string GetStartupURL() { return m_StartupURL; } 214 | 215 | void set_listener(Listener* listener) { 216 | listener_ = listener; 217 | } 218 | Listener* listener() const { 219 | return listener_; 220 | } 221 | 222 | // Number of currently existing browser windows. The application will exit 223 | // when the number of windows reaches 0. 224 | static int m_BrowserCount; 225 | 226 | protected: 227 | void SetLoading(bool isLoading); 228 | void SetNavState(bool canGoBack, bool canGoForward); 229 | 230 | // Create all of ProcessMessageDelegate objects. 231 | static void CreateProcessMessageDelegates( 232 | ProcessMessageDelegateSet& delegates); 233 | 234 | // The child browser window 235 | CefRefPtr m_Browser; 236 | 237 | // List of any popup browser windows. Only accessed on the CEF UI thread. 238 | typedef std::list > BrowserList; 239 | BrowserList m_PopupBrowsers; 240 | 241 | // The child browser id 242 | int m_BrowserId; 243 | 244 | // True if the main browser window is currently closing. 245 | bool m_bIsClosing; 246 | 247 | // True if an editable field currently has focus. 248 | bool m_bFocusOnEditableField; 249 | 250 | // Registered delegates. 251 | ProcessMessageDelegateSet process_message_delegates_; 252 | 253 | // List of open DevTools URLs if not using an external browser window. 254 | std::set m_OpenDevToolsURLs; 255 | 256 | // The startup URL. 257 | std::string m_StartupURL; 258 | 259 | // Listener interface 260 | Listener* listener_; 261 | 262 | // Include the default reference counting implementation. 263 | IMPLEMENT_REFCOUNTING(ClientHandler); 264 | // Include the default locking implementation. 265 | IMPLEMENT_LOCKING(ClientHandler); 266 | }; 267 | 268 | #endif // CEFCLIENT_CLIENT_HANDLER_H_ -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_handler_qt.cpp: -------------------------------------------------------------------------------- 1 | #include "cefclient/client_handler.h" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include "include/cef_browser.h" 8 | #include "include/cef_frame.h" 9 | 10 | void ClientHandler::OnAddressChange(CefRefPtr browser, 11 | CefRefPtr frame, 12 | const CefString& url) { 13 | REQUIRE_UI_THREAD(); 14 | if (!listener_) return; 15 | 16 | if (m_BrowserId == browser->GetIdentifier() && frame->IsMain()) { 17 | listener_->OnAddressChange(QString::fromStdWString(url.ToWString())); 18 | } 19 | } 20 | 21 | void ClientHandler::OnTitleChange(CefRefPtr browser, 22 | const CefString& title) { 23 | REQUIRE_UI_THREAD(); 24 | if (!listener_) return; 25 | 26 | if (m_BrowserId == browser->GetIdentifier()) { 27 | listener_->OnTitleChange(QString::fromStdWString(title.ToWString())); 28 | } 29 | } 30 | 31 | void ClientHandler::SetLoading(bool isLoading) { 32 | if (!listener_) return; 33 | listener_->SetLoading(isLoading); 34 | } 35 | 36 | void ClientHandler::SetNavState(bool canGoBack, bool canGoForward) { 37 | if (!listener_) return; 38 | listener_->SetNavState(canGoBack, canGoForward); 39 | } 40 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_renderer.cpp: -------------------------------------------------------------------------------- 1 | #include "cefclient/client_renderer.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "include/cef_dom.h" 7 | 8 | namespace client_renderer { 9 | 10 | const char kFocusedNodeChangedMessage[] = "ClientRenderer.FocusedNodeChanged"; 11 | 12 | namespace { 13 | 14 | class ClientRenderDelegate : public ClientApp::RenderDelegate { 15 | public: 16 | ClientRenderDelegate() 17 | : last_node_is_editable_(false) { 18 | } 19 | 20 | virtual void OnFocusedNodeChanged(CefRefPtr app, 21 | CefRefPtr browser, 22 | CefRefPtr frame, 23 | CefRefPtr node) OVERRIDE { 24 | bool is_editable = (node.get() && node->IsEditable()); 25 | if (is_editable != last_node_is_editable_) { 26 | // Notify the browser of the change in focused element type. 27 | last_node_is_editable_ = is_editable; 28 | CefRefPtr message = 29 | CefProcessMessage::Create(kFocusedNodeChangedMessage); 30 | message->GetArgumentList()->SetBool(0, is_editable); 31 | browser->SendProcessMessage(PID_BROWSER, message); 32 | } 33 | } 34 | 35 | private: 36 | bool last_node_is_editable_; 37 | 38 | IMPLEMENT_REFCOUNTING(ClientRenderDelegate); 39 | }; 40 | 41 | } // namespace 42 | 43 | void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates) { 44 | delegates.insert(new ClientRenderDelegate); 45 | } 46 | 47 | } // namespace client_renderer 48 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_renderer.h: -------------------------------------------------------------------------------- 1 | #ifndef CEFCLIENT_CLIENT_RENDERER_H_ 2 | #define CEFCLIENT_CLIENT_RENDERER_H_ 3 | #pragma once 4 | 5 | #include "include/cef_base.h" 6 | #include "cefclient/client_app.h" 7 | 8 | namespace client_renderer { 9 | 10 | // Message sent when the focused node changes. 11 | extern const char kFocusedNodeChangedMessage[]; 12 | 13 | // Create the render delegate. 14 | void CreateRenderDelegates(ClientApp::RenderDelegateSet& delegates); 15 | 16 | } // namespace client_renderer 17 | 18 | #endif // CEFCLIENT_CLIENT_RENDERER_H_ 19 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_transfer.cpp: -------------------------------------------------------------------------------- 1 | #include "client_transfer.h" 2 | #include "util.h" 3 | 4 | namespace cefclient { 5 | 6 | // Transfer a V8 value to a List index. 7 | void SetListValue(CefRefPtr list, int index, 8 | CefRefPtr value) { 9 | if (value->IsArray()) { 10 | CefRefPtr new_list = CefListValue::Create(); 11 | SetList(value, new_list); 12 | list->SetList(index, new_list); 13 | } else if (value->IsString()) { 14 | list->SetString(index, value->GetStringValue()); 15 | } else if (value->IsBool()) { 16 | list->SetBool(index, value->GetBoolValue()); 17 | } else if (value->IsInt()) { 18 | list->SetInt(index, value->GetIntValue()); 19 | } else if (value->IsDouble()) { 20 | list->SetDouble(index, value->GetDoubleValue()); 21 | } 22 | } 23 | 24 | // Transfer a V8 array to a List. 25 | void SetList(CefRefPtr source, CefRefPtr target) { 26 | ASSERT(source->IsArray()); 27 | 28 | int arg_length = source->GetArrayLength(); 29 | if (arg_length == 0) 30 | return; 31 | 32 | // Start with null types in all spaces. 33 | target->SetSize(arg_length); 34 | 35 | for (int i = 0; i < arg_length; ++i) 36 | SetListValue(target, i, source->GetValue(i)); 37 | } 38 | 39 | // Transfer a V8 list to a List. 40 | void SetList(const CefV8ValueList& source, CefRefPtr target) { 41 | int arg_length = source.size(); 42 | if (arg_length == 0) 43 | return; 44 | 45 | for (int i = 0; i < arg_length; ++i) 46 | SetListValue(target, i, source.at(i)); 47 | } 48 | 49 | // Transfer a List value to a V8 array index. 50 | void SetListValue(CefRefPtr list, int index, 51 | CefRefPtr value) { 52 | CefRefPtr new_value; 53 | 54 | CefValueType type = value->GetType(index); 55 | switch (type) { 56 | case VTYPE_LIST: { 57 | CefRefPtr list = value->GetList(index); 58 | new_value = CefV8Value::CreateArray(static_cast(list->GetSize())); 59 | SetList(list, new_value); 60 | } break; 61 | case VTYPE_BOOL: 62 | new_value = CefV8Value::CreateBool(value->GetBool(index)); 63 | break; 64 | case VTYPE_DOUBLE: 65 | new_value = CefV8Value::CreateDouble(value->GetDouble(index)); 66 | break; 67 | case VTYPE_INT: 68 | new_value = CefV8Value::CreateInt(value->GetInt(index)); 69 | break; 70 | case VTYPE_STRING: 71 | new_value = CefV8Value::CreateString(value->GetString(index)); 72 | break; 73 | default: 74 | break; 75 | } 76 | 77 | if (new_value.get()) { 78 | list->SetValue(index, new_value); 79 | } else { 80 | list->SetValue(index, CefV8Value::CreateNull()); 81 | } 82 | } 83 | 84 | // Transfer a List to a V8 array. 85 | void SetList(CefRefPtr source, CefRefPtr target) { 86 | ASSERT(target->IsArray()); 87 | 88 | int arg_length = static_cast(source->GetSize()); 89 | if (arg_length == 0) 90 | return; 91 | 92 | for (int i = 0; i < arg_length; ++i) 93 | SetListValue(target, i, source); 94 | } 95 | 96 | #ifdef QT_CORE_LIB 97 | // Transfer a List value to a QVariant array index. 98 | void SetListValue(QVariantList& list, int index, 99 | CefRefPtr value) { 100 | QVariant new_value; 101 | 102 | CefValueType type = value->GetType(index); 103 | switch (type) { 104 | case VTYPE_LIST: { 105 | CefRefPtr list = value->GetList(index); 106 | QVariantList new_list; 107 | SetList(list, new_list); 108 | new_value = new_list; 109 | } break; 110 | case VTYPE_BOOL: 111 | new_value = QVariant(value->GetBool(index)); 112 | break; 113 | case VTYPE_DOUBLE: 114 | new_value = QVariant(value->GetDouble(index)); 115 | break; 116 | case VTYPE_INT: 117 | new_value = QVariant(value->GetInt(index)); 118 | break; 119 | case VTYPE_STRING: { 120 | std::wstring str = value->GetString(index).ToWString(); 121 | new_value = QVariant(QString::fromStdWString(str)); 122 | } break; 123 | default: 124 | break; 125 | } 126 | 127 | list.append(new_value); 128 | } 129 | 130 | // Transfer a List to a QVariant array. (append) 131 | void SetList(CefRefPtr source, QVariantList& target) { 132 | int arg_length = static_cast(source->GetSize()); 133 | if (arg_length == 0) 134 | return; 135 | 136 | for (int i = 0; i < arg_length; ++i) 137 | SetListValue(target, i, source); 138 | } 139 | #endif 140 | 141 | } // namespace cefclient 142 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient/client_transfer.h: -------------------------------------------------------------------------------- 1 | #ifndef CEFCLIENT_CLIENT_TRANSFER_H 2 | #define CEFCLIENT_CLIENT_TRANSFER_H 3 | #pragma once 4 | 5 | #include "include/cef_v8.h" 6 | #ifdef QT_CORE_LIB 7 | #include 8 | #endif 9 | 10 | namespace cefclient { 11 | 12 | // Transfer a V8 array to a List. 13 | void SetList(CefRefPtr source, CefRefPtr target); 14 | // Transfer a V8 list to a List. 15 | void SetList(const CefV8ValueList& source, CefRefPtr target); 16 | 17 | // Transfer a List to a V8 array. 18 | void SetList(CefRefPtr source, CefRefPtr target); 19 | #ifdef QT_CORE_LIB 20 | // Transfer a List to a QVariant array. (append) 21 | void SetList(CefRefPtr source, QVariantList& target); 22 | #endif 23 | 24 | } // namespace cefclient 25 | 26 | #endif // CEFCLIENT_CLIENT_TRANSFER_H -------------------------------------------------------------------------------- /qcef3_1650/cefclient/message_event.cpp: -------------------------------------------------------------------------------- 1 | #include "message_event.h" 2 | 3 | const QEvent::Type MessageEvent::MessageEventType = (QEvent::Type)QEvent::registerEventType(); 4 | 5 | MessageEvent::MessageEvent(const QString& name, const QVariantList& args) 6 | : name_(name), 7 | args_(args), 8 | QEvent(MessageEventType) { 9 | } 10 | 11 | MessageEvent::~MessageEvent(void) { 12 | } 13 | 14 | QString MessageEvent::name() const { 15 | return name_; 16 | } 17 | 18 | QVariantList MessageEvent::args() const { 19 | return args_; 20 | } -------------------------------------------------------------------------------- /qcef3_1650/cefclient/message_event.h: -------------------------------------------------------------------------------- 1 | #ifndef CEFCLIENT_MESSAGE_EVENT_H 2 | #define CEFCLIENT_MESSAGE_EVENT_H 3 | #pragma once 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | class MessageEvent : public QEvent { 10 | public: 11 | static const QEvent::Type MessageEventType; 12 | 13 | MessageEvent(const QString& name, const QVariantList& args); 14 | ~MessageEvent(void); 15 | 16 | QString name() const; 17 | QVariantList args() const; 18 | 19 | private: 20 | QString name_; 21 | QVariantList args_; 22 | }; 23 | 24 | #endif // CEFCLIENT_MESSAGE_EVENT_H -------------------------------------------------------------------------------- /qcef3_1650/cefclient/qcefwebview.cpp: -------------------------------------------------------------------------------- 1 | #include "qcefwebview.h" 2 | #include "include/cef_browser.h" 3 | #include 4 | #include "cefclient/message_event.h" 5 | 6 | //#include 7 | //#include 8 | 9 | extern CefRefPtr g_handler; 10 | 11 | const QString QCefWebView::kUrlBlank = "about:blank"; 12 | 13 | QCefWebView::QCefWebView(QWidget* parent) 14 | : QWidget(parent), 15 | browser_state_(kNone), 16 | need_resize_(false), 17 | need_load_(false) { 18 | //qDebug() << __FUNCTION__ << QThread::currentThreadId(); 19 | setAttribute(Qt::WA_NativeWindow); 20 | setAttribute(Qt::WA_DontCreateNativeAncestors); 21 | } 22 | 23 | QCefWebView::~QCefWebView() { 24 | //qDebug() << __FUNCTION__; 25 | } 26 | 27 | void QCefWebView::load(const QUrl& url) { 28 | //qDebug() << __FUNCTION__ << url; 29 | url_ = url; 30 | switch (browser_state_) { 31 | case kNone: 32 | CreateBrowser(size()); break; 33 | case kCreating: 34 | // If resizeEvent()/showEvent() before you load a url, it will 35 | // CreateBrowser() as soon as possible with "about:blank". 36 | need_load_ = true; break; 37 | default: // The browser should have been created. 38 | BrowserLoadUrl(url); 39 | } 40 | } 41 | 42 | void QCefWebView::setHtml(const QString& html, const QUrl& baseUrl) { 43 | // Custom Scheme and Request Handling: 44 | // https://code.google.com/p/chromiumembedded/wiki/GeneralUsage#Request_Handling 45 | if (GetBrowser().get()) { 46 | QUrl url = baseUrl.isEmpty() ? this->url(): baseUrl; 47 | if (!url.isEmpty()) { 48 | CefRefPtr frame = GetBrowser()->GetMainFrame(); 49 | frame->LoadString(CefString(html.toStdWString()), 50 | CefString(url.toString().toStdWString())); 51 | } 52 | } 53 | } 54 | 55 | QUrl QCefWebView::url() const { 56 | if (GetBrowser().get()) { 57 | CefString url = GetBrowser()->GetMainFrame()->GetURL(); 58 | return QUrl(QString::fromStdWString(url.ToWString())); 59 | } 60 | return QUrl(); 61 | } 62 | 63 | void QCefWebView::back() { 64 | CefRefPtr browser = GetBrowser(); 65 | if (browser.get()) 66 | browser->GoBack(); 67 | } 68 | 69 | void QCefWebView::forward() { 70 | CefRefPtr browser = GetBrowser(); 71 | if (browser.get()) 72 | browser->GoForward(); 73 | } 74 | 75 | void QCefWebView::reload() { 76 | CefRefPtr browser = GetBrowser(); 77 | if (browser.get()) 78 | browser->Reload(); 79 | } 80 | 81 | void QCefWebView::stop() { 82 | CefRefPtr browser = GetBrowser(); 83 | if (browser.get()) 84 | browser->StopLoad(); 85 | } 86 | 87 | QVariant QCefWebView::evaluateJavaScript(const QString& scriptSource) { 88 | if (GetBrowser().get()) { 89 | CefString code(scriptSource.toStdWString()); 90 | GetBrowser()->GetMainFrame()->ExecuteJavaScript(code, "", 0); 91 | return true; 92 | } 93 | return false; 94 | } 95 | 96 | void QCefWebView::resizeEvent(QResizeEvent* e) { 97 | //qDebug() << __FUNCTION__ << e->size(); 98 | // On WinXP, if you load a url immediately after constructed, you will 99 | // CreateBrowser() with the wrong Size(). At the same time, it calls 100 | // resizeEvent() to resize. However the browser has not been created now, 101 | // ResizeBrowser() will fail, and it won't displayed with the right size. 102 | // Although resize(0, 0) can fix it, the other platforms maybe 103 | // give you the right size and it will make CreateBrowser() later. 104 | switch (browser_state_) { 105 | case kNone: 106 | CreateBrowser(e->size()); break; 107 | case kCreating: 108 | need_resize_ = true; break; 109 | default: 110 | ResizeBrowser(e->size()); 111 | } 112 | } 113 | 114 | void QCefWebView::closeEvent(QCloseEvent* e) { 115 | if (g_handler.get() && !g_handler->IsClosing()) { 116 | CefRefPtr browser = g_handler->GetBrowser(); 117 | if (browser.get()) { 118 | browser->GetHost()->CloseBrowser(false); 119 | } 120 | } 121 | e->accept(); 122 | } 123 | 124 | void QCefWebView::showEvent(QShowEvent* e) { 125 | //qDebug() << __FUNCTION__; 126 | CreateBrowser(size()); 127 | } 128 | 129 | void QCefWebView::customEvent(QEvent* e) { 130 | //qDebug() << __FUNCTION__ << QThread::currentThreadId(); 131 | if (e->type() == MessageEvent::MessageEventType) { 132 | MessageEvent* event = static_cast(e); 133 | QString name = event->name(); 134 | QVariantList args = event->args(); 135 | //qDebug() << __FUNCTION__ << name << args; 136 | emit jsMessage(name, args); 137 | } 138 | } 139 | 140 | void QCefWebView::OnAddressChange(const QString& url) { 141 | //qDebug() << __FUNCTION__ << url; 142 | emit urlChanged(QUrl(url)); 143 | } 144 | 145 | void QCefWebView::OnTitleChange(const QString& title) { 146 | //qDebug() << __FUNCTION__ << title; 147 | emit titleChanged(title); 148 | } 149 | 150 | void QCefWebView::SetLoading(bool isLoading) { 151 | //qDebug() << __FUNCTION__ << isLoading << url(); 152 | if (isLoading) { 153 | if (!need_load_ && !url_.isEmpty()) 154 | emit loadStarted(); 155 | } else { 156 | if (need_load_) { 157 | //qDebug() << __FUNCTION__ << "need_load_" << url_; 158 | BrowserLoadUrl(url_); 159 | need_load_ = false; 160 | } else if (/*!need_load_ && */!url_.isEmpty()) { 161 | emit loadFinished(true); 162 | } 163 | } 164 | } 165 | 166 | void QCefWebView::SetNavState(bool canGoBack, bool canGoForward) { 167 | //qDebug() << __FUNCTION__ << canGoBack << canGoForward; 168 | emit navStateChanged(canGoBack, canGoForward); 169 | } 170 | 171 | void QCefWebView::OnAfterCreated() { 172 | //qDebug() << __FUNCTION__; 173 | browser_state_ = kCreated; 174 | if (need_resize_) { 175 | //qDebug() << __FUNCTION__ << "need_resize_"; 176 | ResizeBrowser(size()); 177 | need_resize_ = false; 178 | } 179 | } 180 | 181 | void QCefWebView::OnMessageEvent(MessageEvent* e) { 182 | //qDebug() << __FUNCTION__ << QThread::currentThreadId(); 183 | // Cross thread. Not in ui thread here. 184 | QCoreApplication::postEvent(this, e, Qt::HighEventPriority); 185 | } 186 | 187 | bool QCefWebView::CreateBrowser(const QSize& size) { 188 | //qDebug() << __FUNCTION__ << __LINE__; 189 | if (browser_state_ != kNone || size.isEmpty()) { 190 | return false; 191 | } 192 | mutex_.lock(); 193 | if (browser_state_ != kNone) { 194 | mutex_.unlock(); 195 | return false; 196 | } 197 | //qDebug() << __FUNCTION__ << __LINE__; 198 | RECT rect; 199 | rect.left = 0; 200 | rect.top = 0; 201 | rect.right = size.width(); 202 | rect.bottom = size.height(); 203 | 204 | CefWindowInfo info; 205 | CefBrowserSettings settings; 206 | 207 | // By default, as a child window. 208 | info.SetAsChild(this->winId(), rect); 209 | 210 | g_handler->set_listener(this); 211 | 212 | QString url = url_.isEmpty() ? kUrlBlank : url_.toString(); 213 | CefBrowserHost::CreateBrowser(info, 214 | g_handler.get(), 215 | CefString(url.toStdWString()), 216 | settings, 217 | NULL); 218 | 219 | browser_state_ = kCreating; 220 | mutex_.unlock(); 221 | return true; 222 | } 223 | 224 | CefRefPtr QCefWebView::GetBrowser() const { 225 | CefRefPtr browser; 226 | if (g_handler.get()) 227 | browser = g_handler->GetBrowser(); 228 | return browser; 229 | } 230 | 231 | void QCefWebView::ResizeBrowser(const QSize& size) { 232 | if (g_handler.get() && g_handler->GetBrowser()) { 233 | CefWindowHandle hwnd = 234 | g_handler->GetBrowser()->GetHost()->GetWindowHandle(); 235 | if (hwnd) { 236 | HDWP hdwp = BeginDeferWindowPos(1); 237 | hdwp = DeferWindowPos(hdwp, hwnd, NULL, 238 | 0, 0, size.width(), size.height(), 239 | SWP_NOZORDER); 240 | EndDeferWindowPos(hdwp); 241 | } 242 | } 243 | } 244 | 245 | bool QCefWebView::BrowserLoadUrl(const QUrl& url) { 246 | if (!url.isEmpty() && GetBrowser().get()) { 247 | CefString cefurl(url_.toString().toStdWString()); 248 | GetBrowser()->GetMainFrame()->LoadURL(cefurl); 249 | return true; 250 | } 251 | return false; 252 | } -------------------------------------------------------------------------------- /qcef3_1650/cefclient/qcefwebview.h: -------------------------------------------------------------------------------- 1 | #ifndef CEFCLIENT_QCEFWEBVIEW_H 2 | #define CEFCLIENT_QCEFWEBVIEW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include "cefclient/client_handler.h" 11 | 12 | class QCefWebView : public QWidget, 13 | public ClientHandler::Listener { 14 | Q_OBJECT 15 | public: 16 | enum BrowserState { 17 | kNone, 18 | kCreating, 19 | kCreated, 20 | }; 21 | 22 | static const QString kUrlBlank; 23 | 24 | QCefWebView(QWidget* parent = 0); 25 | virtual ~QCefWebView(); 26 | 27 | void load(const QUrl& url); 28 | void setHtml(const QString& html, const QUrl& baseUrl = QUrl()); 29 | QUrl url() const; 30 | 31 | public slots: 32 | void back(); 33 | void forward(); 34 | void reload(); 35 | void stop(); 36 | 37 | QVariant evaluateJavaScript(const QString& scriptSource); 38 | 39 | signals: 40 | void titleChanged(const QString& title); 41 | void urlChanged(const QUrl& url); 42 | void loadStarted(); 43 | void loadFinished(bool ok); 44 | 45 | void navStateChanged(bool canGoBack, bool canGoForward); 46 | void jsMessage(const QString& name, const QVariantList& args); 47 | 48 | protected: 49 | virtual void resizeEvent(QResizeEvent*); 50 | virtual void closeEvent(QCloseEvent*); 51 | virtual void showEvent(QShowEvent*); 52 | virtual void customEvent(QEvent*); 53 | 54 | virtual void OnAddressChange(const QString& url); 55 | virtual void OnTitleChange(const QString& title); 56 | virtual void SetLoading(bool isLoading); 57 | virtual void SetNavState(bool canGoBack, bool canGoForward); 58 | virtual void OnAfterCreated(); 59 | virtual void OnMessageEvent(MessageEvent* e); 60 | 61 | private: 62 | bool CreateBrowser(const QSize& size); 63 | CefRefPtr GetBrowser() const; 64 | void ResizeBrowser(const QSize& size); 65 | bool BrowserLoadUrl(const QUrl& url); 66 | 67 | BrowserState browser_state_; 68 | bool need_resize_; 69 | bool need_load_; 70 | QUrl url_; 71 | QMutex mutex_; 72 | 73 | Q_DISABLE_COPY(QCefWebView) 74 | }; 75 | 76 | #endif // CEFCLIENT_QCEFWEBVIEW_H 77 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient/util.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights 2 | // reserved. Use of this source code is governed by a BSD-style license that 3 | // can be found in the LICENSE file. 4 | 5 | #ifndef CEFCLIENT_UTIL_H_ 6 | #define CEFCLIENT_UTIL_H_ 7 | #pragma once 8 | 9 | #include "include/cef_task.h" 10 | 11 | #if defined(OS_WIN) 12 | 13 | #include // NOLINT(build/include_order) 14 | 15 | #ifndef NDEBUG 16 | #define ASSERT(condition) if (!(condition)) { DebugBreak(); } 17 | #else 18 | #define ASSERT(condition) ((void)0) 19 | #endif 20 | 21 | #else // !OS_WIN 22 | 23 | #include // NOLINT(build/include_order) 24 | 25 | #ifndef NDEBUG 26 | #define ASSERT(condition) if (!(condition)) { assert(false); } 27 | #else 28 | #define ASSERT(condition) ((void)0) 29 | #endif 30 | 31 | #endif // !OS_WIN 32 | 33 | #define REQUIRE_UI_THREAD() ASSERT(CefCurrentlyOn(TID_UI)); 34 | #define REQUIRE_IO_THREAD() ASSERT(CefCurrentlyOn(TID_IO)); 35 | #define REQUIRE_FILE_THREAD() ASSERT(CefCurrentlyOn(TID_FILE)); 36 | 37 | #endif // CEFCLIENT_UTIL_H_ 38 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient_process.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {CE92BEB6-74FC-404A-817B-A2E50C4BCAEA} 15 | Win32Proj 16 | cefclient_process 17 | 18 | 19 | 20 | Application 21 | true 22 | Unicode 23 | 24 | 25 | Application 26 | false 27 | true 28 | Unicode 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | true 42 | $(SolutionDir)out\$(Configuration)\ 43 | $(SolutionDir)out\$(ProjectName)\$(Configuration)\ 44 | 45 | 46 | false 47 | $(SolutionDir)out\$(Configuration)\ 48 | $(SolutionDir)out\$(ProjectName)\$(Configuration)\ 49 | 50 | 51 | 52 | 53 | 54 | Level3 55 | Disabled 56 | WIN32;NOMINMAX;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) 57 | . 58 | false 59 | 60 | 61 | Windows 62 | true 63 | $(Configuration)\libcef.lib;out\$(Configuration)\lib\libcef_dll.lib 64 | 65 | 66 | 67 | 68 | 69 | 70 | Level3 71 | 72 | 73 | MaxSpeed 74 | true 75 | true 76 | WIN32;NOMINMAX;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) 77 | . 78 | false 79 | 80 | 81 | Windows 82 | true 83 | true 84 | true 85 | $(Configuration)\libcef.lib;out\$(Configuration)\lib\libcef_dll.lib 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | -------------------------------------------------------------------------------- /qcef3_1650/cefclient_process.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {3e34b76d-09c8-402f-8a92-7ffe4abe150f} 6 | 7 | 8 | {8a1f151a-beaa-48b2-aaf6-720dab4ed1b1} 9 | 10 | 11 | {521245e2-eec0-42e8-9e48-3dee49cc8913} 12 | 13 | 14 | {bcbaac51-2f4d-4bb4-94fd-cd1cf411d997} 15 | 16 | 17 | {bc843499-0586-4ea3-8dc8-cb2f458500f8} 18 | 19 | 20 | 21 | 22 | include\capi 23 | 24 | 25 | include\capi 26 | 27 | 28 | include\capi 29 | 30 | 31 | include\capi 32 | 33 | 34 | include\capi 35 | 36 | 37 | include\capi 38 | 39 | 40 | include\capi 41 | 42 | 43 | include\capi 44 | 45 | 46 | include\capi 47 | 48 | 49 | include\capi 50 | 51 | 52 | include\capi 53 | 54 | 55 | include\capi 56 | 57 | 58 | include\capi 59 | 60 | 61 | include\capi 62 | 63 | 64 | include\capi 65 | 66 | 67 | include\capi 68 | 69 | 70 | include\capi 71 | 72 | 73 | include\capi 74 | 75 | 76 | include\capi 77 | 78 | 79 | include\capi 80 | 81 | 82 | include\capi 83 | 84 | 85 | include\capi 86 | 87 | 88 | include\capi 89 | 90 | 91 | include\capi 92 | 93 | 94 | include\capi 95 | 96 | 97 | include\capi 98 | 99 | 100 | include\capi 101 | 102 | 103 | include\capi 104 | 105 | 106 | include\capi 107 | 108 | 109 | include\capi 110 | 111 | 112 | include\capi 113 | 114 | 115 | include\capi 116 | 117 | 118 | include\capi 119 | 120 | 121 | include\capi 122 | 123 | 124 | include\capi 125 | 126 | 127 | include\capi 128 | 129 | 130 | include\capi 131 | 132 | 133 | include\capi 134 | 135 | 136 | include\capi 137 | 138 | 139 | include\capi 140 | 141 | 142 | include\capi 143 | 144 | 145 | include\capi 146 | 147 | 148 | include\capi 149 | 150 | 151 | include\capi 152 | 153 | 154 | include\capi 155 | 156 | 157 | include\capi 158 | 159 | 160 | include\capi 161 | 162 | 163 | include\capi 164 | 165 | 166 | include\capi 167 | 168 | 169 | include\capi 170 | 171 | 172 | include\capi 173 | 174 | 175 | include\internal 176 | 177 | 178 | include\internal 179 | 180 | 181 | include\internal 182 | 183 | 184 | include\internal 185 | 186 | 187 | include\internal 188 | 189 | 190 | include\internal 191 | 192 | 193 | include\internal 194 | 195 | 196 | include\internal 197 | 198 | 199 | include\internal 200 | 201 | 202 | include\internal 203 | 204 | 205 | include\internal 206 | 207 | 208 | include\internal 209 | 210 | 211 | include\internal 212 | 213 | 214 | include\internal 215 | 216 | 217 | include\internal 218 | 219 | 220 | include\wrapper 221 | 222 | 223 | include\wrapper 224 | 225 | 226 | include\wrapper 227 | 228 | 229 | include\wrapper 230 | 231 | 232 | include 233 | 234 | 235 | include 236 | 237 | 238 | include 239 | 240 | 241 | include 242 | 243 | 244 | include 245 | 246 | 247 | include 248 | 249 | 250 | include 251 | 252 | 253 | include 254 | 255 | 256 | include 257 | 258 | 259 | include 260 | 261 | 262 | include 263 | 264 | 265 | include 266 | 267 | 268 | include 269 | 270 | 271 | include 272 | 273 | 274 | include 275 | 276 | 277 | include 278 | 279 | 280 | include 281 | 282 | 283 | include 284 | 285 | 286 | include 287 | 288 | 289 | include 290 | 291 | 292 | include 293 | 294 | 295 | include 296 | 297 | 298 | include 299 | 300 | 301 | include 302 | 303 | 304 | include 305 | 306 | 307 | include 308 | 309 | 310 | include 311 | 312 | 313 | include 314 | 315 | 316 | include 317 | 318 | 319 | include 320 | 321 | 322 | include 323 | 324 | 325 | include 326 | 327 | 328 | include 329 | 330 | 331 | include 332 | 333 | 334 | include 335 | 336 | 337 | include 338 | 339 | 340 | include 341 | 342 | 343 | include 344 | 345 | 346 | include 347 | 348 | 349 | include 350 | 351 | 352 | include 353 | 354 | 355 | include 356 | 357 | 358 | include 359 | 360 | 361 | include 362 | 363 | 364 | include 365 | 366 | 367 | include 368 | 369 | 370 | include 371 | 372 | 373 | include 374 | 375 | 376 | include 377 | 378 | 379 | include 380 | 381 | 382 | include 383 | 384 | 385 | include 386 | 387 | 388 | include 389 | 390 | 391 | include 392 | 393 | 394 | include 395 | 396 | 397 | include 398 | 399 | 400 | cefclient 401 | 402 | 403 | cefclient 404 | 405 | 406 | cefclient 407 | 408 | 409 | cefclient 410 | 411 | 412 | cefclient 413 | 414 | 415 | 416 | 417 | cefclient 418 | 419 | 420 | cefclient 421 | 422 | 423 | cefclient 424 | 425 | 426 | 427 | cefclient 428 | 429 | 430 | -------------------------------------------------------------------------------- /qcef3_1650/exclude.list: -------------------------------------------------------------------------------- 1 | libcef.lib -------------------------------------------------------------------------------- /qcef3_1650/libcef_dll.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | {E513F4F2-BE71-4EA8-A577-623B221B278F} 318 | Win32Proj 319 | libcef_dll 320 | 321 | 322 | 323 | StaticLibrary 324 | true 325 | Unicode 326 | 327 | 328 | StaticLibrary 329 | false 330 | true 331 | Unicode 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | $(SolutionDir)out\$(Configuration)\lib\ 345 | 346 | 347 | $(SolutionDir)out\$(ProjectName)\$(Configuration)\ 348 | 349 | 350 | $(SolutionDir)out\$(Configuration)\lib\ 351 | 352 | 353 | $(SolutionDir)out\$(ProjectName)\$(Configuration)\ 354 | 355 | 356 | 357 | 358 | 359 | Level3 360 | Disabled 361 | USING_CEF_SHARED;NOMINMAX;WIN32;_WINDOWS;_DEBUG 362 | . 363 | 4351;4355;4396;4503;4819;4100;4121;4125;4127;4130;4131;4189;4201;4238;4244;4245;4310;4428;4481;4505;4510;4512;4530;4610;4611;4701;4702;4706;%(DisableSpecificWarnings) 364 | 365 | 366 | Windows 367 | true 368 | 369 | 370 | 371 | 372 | Level3 373 | 374 | 375 | MaxSpeed 376 | true 377 | true 378 | USING_CEF_SHARED;NOMINMAX;WIN32;_WINDOWS;NDEBUG 379 | . 380 | 4351;4355;4396;4503;4819;4100;4121;4125;4127;4130;4131;4189;4201;4238;4244;4245;4310;4428;4481;4505;4510;4512;4530;4610;4611;4701;4702;4706;%(DisableSpecificWarnings) 381 | 382 | 383 | Windows 384 | true 385 | true 386 | true 387 | 388 | 389 | 390 | 391 | 392 | -------------------------------------------------------------------------------- /qcef3_1650/main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include 3 | #include "cefclient/cefclient.h" 4 | 5 | #include 6 | #include 7 | 8 | namespace { 9 | 10 | typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); 11 | LPFN_ISWOW64PROCESS fnIsWow64Process; 12 | 13 | } // namespace 14 | 15 | // Detect whether the operating system is a 64-bit. 16 | // http://msdn.microsoft.com/en-us/library/windows/desktop/ms684139%28v=vs.85%29.aspx 17 | BOOL IsWow64() { 18 | BOOL bIsWow64 = FALSE; 19 | 20 | fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress( 21 | GetModuleHandle(TEXT("kernel32")), 22 | "IsWow64Process"); 23 | 24 | if (NULL != fnIsWow64Process) { 25 | if (!fnIsWow64Process(GetCurrentProcess(), &bIsWow64)) { 26 | // handle error 27 | } 28 | } 29 | return bIsWow64; 30 | } 31 | 32 | int main(int argc, char *argv[]) { 33 | QApplication a(argc, argv); 34 | int result = CefInit(argc, argv); 35 | if (result >= 0) 36 | return result; 37 | 38 | // Load flash system plug-in on Windows. 39 | CefLoadPlugins(IsWow64()); 40 | 41 | MainWindow w; 42 | w.show(); 43 | 44 | //a.setQuitOnLastWindowClosed(false); 45 | result = a.exec(); 46 | 47 | CefQuit(); 48 | 49 | return result; 50 | } 51 | -------------------------------------------------------------------------------- /qcef3_1650/main_process.cpp: -------------------------------------------------------------------------------- 1 | #include "include/cef_base.h" 2 | #include "cefclient/client_app.h" 3 | 4 | // Program entry point function. 5 | int APIENTRY wWinMain(HINSTANCE hInstance, 6 | HINSTANCE hPrevInstance, 7 | LPTSTR lpCmdLine, 8 | int nCmdShow) { 9 | UNREFERENCED_PARAMETER(hPrevInstance); 10 | UNREFERENCED_PARAMETER(lpCmdLine); 11 | 12 | // Structure for passing command-line arguments. 13 | // The definition of this structure is platform-specific. 14 | CefMainArgs main_args(hInstance); 15 | 16 | // Optional implementation of the CefApp interface. 17 | CefRefPtr app(new ClientApp); 18 | 19 | // Execute the sub-process logic. This will block until the sub-process should exit. 20 | return CefExecuteProcess(main_args, app.get()); 21 | } 22 | -------------------------------------------------------------------------------- /qcef3_1650/mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | #include 4 | #include 5 | #include 6 | #include "cefclient/cefclient.h" 7 | #include "cefclient/client_app_js.h" 8 | 9 | #include 10 | 11 | MainWindow::MainWindow(QWidget *parent, Qt::WFlags flags) 12 | : QMainWindow(parent, flags), 13 | ui_(new Ui::MainWindow) { 14 | qDebug() << __FUNCTION__; 15 | ui_->setupUi(this); 16 | SetupUi(); 17 | 18 | webview_->load(QUrl("http://www.google.com/")); 19 | } 20 | 21 | MainWindow::~MainWindow() { 22 | qDebug() << __FUNCTION__; 23 | delete ui_; 24 | } 25 | 26 | void MainWindow::closeEvent(QCloseEvent* e) { 27 | e->accept(); 28 | } 29 | 30 | void MainWindow::onTitleChanged(const QString& title) { 31 | qDebug() << __FUNCTION__ << title; 32 | setWindowTitle(title); 33 | } 34 | 35 | void MainWindow::onUrlChanged(const QUrl& url) { 36 | qDebug() << __FUNCTION__ << url; 37 | ui_->lineEdit->setText(url.toString()); 38 | } 39 | 40 | void MainWindow::onLoadStarted() { 41 | qDebug() << __FUNCTION__; 42 | 43 | QString message; 44 | QTextStream stream(&message); 45 | stream << __FUNCTION__ << " : " << webview_->url().toString(); 46 | statusBar()->showMessage(message); 47 | 48 | ui_->lineEdit->setEnabled(true); 49 | ui_->reloadButton->setEnabled(false); 50 | ui_->stopButton->setEnabled(true); 51 | ui_->menuTests->setEnabled(false); 52 | } 53 | 54 | void MainWindow::onLoadFinished(bool ok) { 55 | qDebug() << __FUNCTION__; 56 | 57 | QString message; 58 | QTextStream stream(&message); 59 | stream << __FUNCTION__ << " : " << webview_->url().toString(); 60 | statusBar()->showMessage(message); 61 | 62 | ui_->reloadButton->setEnabled(true); 63 | ui_->stopButton->setEnabled(false); 64 | ui_->menuTests->setEnabled(true); 65 | } 66 | 67 | void MainWindow::onNavStateChanged(bool canGoBack, bool canGoForward) { 68 | //qDebug() << __FUNCTION__ << canGoBack << canGoForward; 69 | ui_->backButton->setEnabled(canGoBack); 70 | ui_->forwardButton->setEnabled(canGoForward); 71 | } 72 | 73 | void MainWindow::onJsMessage(const QString& name, const QVariantList& args) { 74 | //qDebug() << __FUNCTION__ << name << args; 75 | if (name == JS_FUNC_SENDMESSAGE) { 76 | QString message; 77 | foreach (QVariant arg, args) { 78 | message.append(arg.toString()); 79 | message.append(QLatin1Char('\n')); 80 | } 81 | QMessageBox::about(this, name, message); 82 | } 83 | } 84 | 85 | void MainWindow::on_backButton_clicked() { 86 | //qDebug() << __FUNCTION__; 87 | webview_->back(); 88 | } 89 | 90 | void MainWindow::on_forwardButton_clicked() { 91 | //qDebug() << __FUNCTION__; 92 | webview_->forward(); 93 | } 94 | 95 | void MainWindow::on_reloadButton_clicked() { 96 | //qDebug() << __FUNCTION__; 97 | webview_->reload(); 98 | } 99 | 100 | void MainWindow::on_stopButton_clicked() { 101 | //qDebug() << __FUNCTION__; 102 | webview_->stop(); 103 | } 104 | 105 | void MainWindow::on_lineEdit_returnPressed() { 106 | if (ui_->stopButton->isEnabled()) { // loading 107 | webview_->stop(); 108 | } 109 | QUrl url(ui_->lineEdit->text()); 110 | qDebug() << __FUNCTION__ << url; 111 | webview_->load(url); 112 | } 113 | 114 | void MainWindow::on_actionExit_triggered() { 115 | //qApp->quit(); 116 | close(); 117 | } 118 | 119 | void MainWindow::on_actionAbout_triggered() { 120 | //qApp->aboutQt(); 121 | QMessageBox::about(this, tr("About"), 122 | "Qt " 123 | "(CEF3)"); 124 | } 125 | 126 | void MainWindow::on_actionSendMessage_triggered() { 127 | QString url = QString("file:///%1/www/SendMessage.html").arg(QDir::currentPath()); 128 | webview_->load(QUrl(url)); 129 | } 130 | 131 | void MainWindow::on_actionLoadHtml_triggered() { 132 | // If the url is "about:blank" at first, it will fail to setHtml(). 133 | // And the url will be "data:text/html,chromewebdata" now. 134 | // 135 | // It will also lead to back() issue as follows: 136 | // "about:blank"(at first) > LoadHtml > Back > Forward(fail to load) > 137 | // Back > the loading issue. 138 | // 139 | // However setHtml() will lead to some navigation problems. 140 | webview_->setHtml("

Hello everyone!

", QUrl("tests://LoadHtml/")); 141 | } 142 | 143 | void MainWindow::SetupUi() { 144 | webview_ = new QCefWebView(this); 145 | connect(webview_, SIGNAL(titleChanged(const QString&)), 146 | this, SLOT(onTitleChanged(const QString&))); 147 | connect(webview_, SIGNAL(urlChanged(const QUrl&)), 148 | this, SLOT(onUrlChanged(const QUrl&))); 149 | connect(webview_, SIGNAL(loadStarted()), 150 | this, SLOT(onLoadStarted())); 151 | connect(webview_, SIGNAL(loadFinished(bool)), 152 | this, SLOT(onLoadFinished(bool))); 153 | connect(webview_, SIGNAL(navStateChanged(bool, bool)), 154 | this, SLOT(onNavStateChanged(bool, bool))); 155 | connect(webview_, SIGNAL(jsMessage(const QString&, const QVariantList&)), 156 | this, SLOT(onJsMessage(const QString&, const QVariantList&))); 157 | 158 | ui_->verticalLayout->addWidget(webview_); 159 | } -------------------------------------------------------------------------------- /qcef3_1650/mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include "cefclient/qcefwebview.h" 7 | 8 | namespace Ui { 9 | class MainWindow; 10 | } 11 | 12 | class MainWindow : public QMainWindow { 13 | Q_OBJECT 14 | 15 | public: 16 | MainWindow(QWidget *parent = 0, Qt::WFlags flags = 0); 17 | ~MainWindow(); 18 | 19 | protected: 20 | virtual void closeEvent(QCloseEvent*); 21 | 22 | private slots: 23 | void onTitleChanged(const QString& title); 24 | void onUrlChanged(const QUrl& url); 25 | void onLoadStarted(); 26 | void onLoadFinished(bool ok); 27 | void onNavStateChanged(bool canGoBack, bool canGoForward); 28 | void onJsMessage(const QString& name, const QVariantList& args); 29 | 30 | void on_backButton_clicked(); 31 | void on_forwardButton_clicked(); 32 | void on_reloadButton_clicked(); 33 | void on_stopButton_clicked(); 34 | 35 | void on_lineEdit_returnPressed(); 36 | 37 | void on_actionExit_triggered(); 38 | void on_actionAbout_triggered(); 39 | void on_actionSendMessage_triggered(); 40 | void on_actionLoadHtml_triggered(); 41 | 42 | private: 43 | void SetupUi(); 44 | 45 | Ui::MainWindow *ui_; 46 | QCefWebView* webview_; 47 | 48 | Q_DISABLE_COPY(MainWindow) 49 | }; 50 | 51 | #endif // MAINWINDOW_H 52 | -------------------------------------------------------------------------------- /qcef3_1650/mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 800 10 | 600 11 | 12 | 13 | 14 | cefclient 15 | 16 | 17 | 18 | 19 | 0 20 | 21 | 22 | 0 23 | 24 | 25 | 0 26 | 27 | 28 | 0 29 | 30 | 31 | 0 32 | 33 | 34 | 35 | 36 | 0 37 | 38 | 39 | 40 | 41 | false 42 | 43 | 44 | Back 45 | 46 | 47 | 48 | 49 | 50 | 51 | false 52 | 53 | 54 | Forward 55 | 56 | 57 | 58 | 59 | 60 | 61 | false 62 | 63 | 64 | 65 | 66 | 67 | 68 | false 69 | 70 | 71 | Reload 72 | 73 | 74 | 75 | 76 | 77 | 78 | false 79 | 80 | 81 | Stop 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 0 93 | 0 94 | 800 95 | 23 96 | 97 | 98 | 99 | 100 | File 101 | 102 | 103 | 104 | 105 | 106 | Help 107 | 108 | 109 | 110 | 111 | 112 | true 113 | 114 | 115 | Tests 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | About ... 128 | 129 | 130 | 131 | 132 | Exit 133 | 134 | 135 | 136 | 137 | true 138 | 139 | 140 | SendMessage 141 | 142 | 143 | 144 | 145 | LoadHtml 146 | 147 | 148 | 149 | 150 | 151 | 152 | -------------------------------------------------------------------------------- /qcef3_1650/move.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | set SolutionDir=%1 3 | set Configuration=%2 4 | if "%SolutionDir%"=="" ( 5 | echo Missing SolutionDir 6 | goto END 7 | ) 8 | if "%Configuration%"=="" ( 9 | echo Missing Configuration 10 | goto END 11 | ) 12 | echo SolutionDir=%SolutionDir% 13 | echo Configuration=%Configuration% 14 | 15 | echo d|xcopy %SolutionDir%%Configuration% %SolutionDir%out\%Configuration% /e /d /exclude:%SolutionDir%exclude.list 16 | echo n|copy /-y %SolutionDir%Resources\cef.pak %SolutionDir%out\%Configuration% 17 | echo n|copy /-y %SolutionDir%Resources\devtools_resources.pak %SolutionDir%out\%Configuration% 18 | mkdir %SolutionDir%out\%Configuration%\locales 19 | echo n|copy /-y %SolutionDir%Resources\locales\en-US.pak %SolutionDir%out\%Configuration%\locales 20 | :END 21 | rem @pause>nul -------------------------------------------------------------------------------- /qcef3_1650/qcef3_1650.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cefclient", "cefclient.vcxproj", "{43CC1856-8F29-41E5-89ED-0CE19DFF8350}" 5 | ProjectSection(ProjectDependencies) = postProject 6 | {CE92BEB6-74FC-404A-817B-A2E50C4BCAEA} = {CE92BEB6-74FC-404A-817B-A2E50C4BCAEA} 7 | {E513F4F2-BE71-4EA8-A577-623B221B278F} = {E513F4F2-BE71-4EA8-A577-623B221B278F} 8 | EndProjectSection 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcef_dll", "libcef_dll.vcxproj", "{E513F4F2-BE71-4EA8-A577-623B221B278F}" 11 | EndProject 12 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cefclient_process", "cefclient_process.vcxproj", "{CE92BEB6-74FC-404A-817B-A2E50C4BCAEA}" 13 | ProjectSection(ProjectDependencies) = postProject 14 | {E513F4F2-BE71-4EA8-A577-623B221B278F} = {E513F4F2-BE71-4EA8-A577-623B221B278F} 15 | EndProjectSection 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Win32 = Debug|Win32 20 | Release|Win32 = Release|Win32 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {43CC1856-8F29-41E5-89ED-0CE19DFF8350}.Debug|Win32.ActiveCfg = Debug|Win32 24 | {43CC1856-8F29-41E5-89ED-0CE19DFF8350}.Debug|Win32.Build.0 = Debug|Win32 25 | {43CC1856-8F29-41E5-89ED-0CE19DFF8350}.Release|Win32.ActiveCfg = Release|Win32 26 | {43CC1856-8F29-41E5-89ED-0CE19DFF8350}.Release|Win32.Build.0 = Release|Win32 27 | {E513F4F2-BE71-4EA8-A577-623B221B278F}.Debug|Win32.ActiveCfg = Debug|Win32 28 | {E513F4F2-BE71-4EA8-A577-623B221B278F}.Debug|Win32.Build.0 = Debug|Win32 29 | {E513F4F2-BE71-4EA8-A577-623B221B278F}.Release|Win32.ActiveCfg = Release|Win32 30 | {E513F4F2-BE71-4EA8-A577-623B221B278F}.Release|Win32.Build.0 = Release|Win32 31 | {CE92BEB6-74FC-404A-817B-A2E50C4BCAEA}.Debug|Win32.ActiveCfg = Debug|Win32 32 | {CE92BEB6-74FC-404A-817B-A2E50C4BCAEA}.Debug|Win32.Build.0 = Debug|Win32 33 | {CE92BEB6-74FC-404A-817B-A2E50C4BCAEA}.Release|Win32.ActiveCfg = Release|Win32 34 | {CE92BEB6-74FC-404A-817B-A2E50C4BCAEA}.Release|Win32.Build.0 = Release|Win32 35 | EndGlobalSection 36 | GlobalSection(SolutionProperties) = preSolution 37 | HideSolutionNode = FALSE 38 | EndGlobalSection 39 | EndGlobal 40 | -------------------------------------------------------------------------------- /qcef3_1650/www/SendMessage.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SendMessage 6 | 22 | 23 | 24 |
25 |

SendMessage

26 | 27 |
28 | 29 |
30 |
31 | 45 | 46 | 47 | --------------------------------------------------------------------------------