OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/utility/chrome_content_utility_client.h" | 5 #include "chrome/utility/chrome_content_utility_client.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 #include "third_party/skia/include/core/SkBitmap.h" | 39 #include "third_party/skia/include/core/SkBitmap.h" |
40 #include "third_party/zlib/google/zip.h" | 40 #include "third_party/zlib/google/zip.h" |
41 #include "ui/base/ui_base_switches.h" | 41 #include "ui/base/ui_base_switches.h" |
42 #include "ui/gfx/codec/jpeg_codec.h" | 42 #include "ui/gfx/codec/jpeg_codec.h" |
43 #include "ui/gfx/rect.h" | 43 #include "ui/gfx/rect.h" |
44 #include "ui/gfx/size.h" | 44 #include "ui/gfx/size.h" |
45 | 45 |
46 #if defined(OS_WIN) | 46 #if defined(OS_WIN) |
47 #include "base/win/iat_patch_function.h" | 47 #include "base/win/iat_patch_function.h" |
48 #include "base/win/scoped_handle.h" | 48 #include "base/win/scoped_handle.h" |
| 49 #include "chrome/browser/extensions/api/networking_private/networking_private_cr
ypto.h" |
49 #include "chrome/utility/media_galleries/itunes_pref_parser_win.h" | 50 #include "chrome/utility/media_galleries/itunes_pref_parser_win.h" |
| 51 #include "components/wifi/wifi_service.h" |
50 #include "printing/emf_win.h" | 52 #include "printing/emf_win.h" |
51 #include "ui/gfx/gdi_util.h" | 53 #include "ui/gfx/gdi_util.h" |
52 #endif // defined(OS_WIN) | 54 #endif // defined(OS_WIN) |
53 | 55 |
54 #if defined(OS_MACOSX) | 56 #if defined(OS_MACOSX) |
55 #include "chrome/utility/media_galleries/iphoto_library_parser.h" | 57 #include "chrome/utility/media_galleries/iphoto_library_parser.h" |
56 #endif // defined(OS_MACOSX) | 58 #endif // defined(OS_MACOSX) |
57 | 59 |
58 #if defined(OS_WIN) || defined(OS_MACOSX) | 60 #if defined(OS_WIN) || defined(OS_MACOSX) |
59 #include "chrome/utility/media_galleries/iapps_xml_utils.h" | 61 #include "chrome/utility/media_galleries/iapps_xml_utils.h" |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 392 |
391 #if defined(OS_WIN) || defined(OS_MACOSX) | 393 #if defined(OS_WIN) || defined(OS_MACOSX) |
392 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesLibraryXmlFile, | 394 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParseITunesLibraryXmlFile, |
393 OnParseITunesLibraryXmlFile) | 395 OnParseITunesLibraryXmlFile) |
394 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParsePicasaPMPDatabase, | 396 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_ParsePicasaPMPDatabase, |
395 OnParsePicasaPMPDatabase) | 397 OnParsePicasaPMPDatabase) |
396 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_IndexPicasaAlbumsContents, | 398 IPC_MESSAGE_HANDLER(ChromeUtilityMsg_IndexPicasaAlbumsContents, |
397 OnIndexPicasaAlbumsContents) | 399 OnIndexPicasaAlbumsContents) |
398 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 400 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
399 | 401 |
| 402 #if defined(OS_WIN) |
| 403 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_GetAndEncryptWiFiCredentials, |
| 404 OnGetAndEncryptWiFiCredentials) |
| 405 #endif // defined(OS_WIN) |
| 406 |
400 IPC_MESSAGE_UNHANDLED(handled = false) | 407 IPC_MESSAGE_UNHANDLED(handled = false) |
401 IPC_END_MESSAGE_MAP() | 408 IPC_END_MESSAGE_MAP() |
402 | 409 |
403 for (Handlers::iterator it = handlers_.begin(); | 410 for (Handlers::iterator it = handlers_.begin(); |
404 !handled && it != handlers_.end(); ++it) { | 411 !handled && it != handlers_.end(); ++it) { |
405 handled = (*it)->OnMessageReceived(message); | 412 handled = (*it)->OnMessageReceived(message); |
406 } | 413 } |
407 | 414 |
408 return handled; | 415 return handled; |
409 } | 416 } |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
892 const std::vector<picasa::FolderINIContents>& folders_inis) { | 899 const std::vector<picasa::FolderINIContents>& folders_inis) { |
893 picasa::PicasaAlbumsIndexer indexer(album_uids); | 900 picasa::PicasaAlbumsIndexer indexer(album_uids); |
894 indexer.ParseFolderINI(folders_inis); | 901 indexer.ParseFolderINI(folders_inis); |
895 | 902 |
896 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( | 903 Send(new ChromeUtilityHostMsg_IndexPicasaAlbumsContents_Finished( |
897 indexer.albums_images())); | 904 indexer.albums_images())); |
898 ReleaseProcessIfNeeded(); | 905 ReleaseProcessIfNeeded(); |
899 } | 906 } |
900 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 907 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
901 | 908 |
| 909 #if defined(OS_WIN) |
| 910 void ChromeContentUtilityClient::OnGetAndEncryptWiFiCredentials( |
| 911 const std::string& network_guid, |
| 912 const std::string& public_key) { |
| 913 scoped_ptr<wifi::WiFiService> wifi_service(wifi::WiFiService::Create()); |
| 914 wifi_service->Initialize(NULL); |
| 915 |
| 916 std::string key_data; |
| 917 std::string error; |
| 918 wifi_service->GetKeyFromSystem(network_guid, &key_data, &error); |
| 919 |
| 920 std::string base64_encoded_ciphertext; |
| 921 if (error.empty() && !key_data.empty()) { |
| 922 NetworkingPrivateCrypto crypto; |
| 923 std::string ciphertext; |
| 924 bool encrypted = |
| 925 crypto.EncryptByteString(public_key, key_data, &ciphertext); |
| 926 if (encrypted) { |
| 927 base::Base64Encode(ciphertext, &base64_encoded_ciphertext); |
| 928 } else { |
| 929 error = "Error.EncryptByteString"; |
| 930 } |
| 931 } |
| 932 |
| 933 Send(new ChromeUtilityHostMsg_GotEncryptedWiFiCredentials( |
| 934 base64_encoded_ciphertext, error)); |
| 935 } |
| 936 #endif // defined(OS_WIN) |
| 937 |
902 } // namespace chrome | 938 } // namespace chrome |
OLD | NEW |