Extend virtual context MakeCurrent fastpath to offscreen surfaces.
[chromium-blink-merge.git] / chrome / plugin / chrome_content_plugin_client.cc
blobd92ff309fa97816166f8a0d52e871c0bb3b14446
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/plugin/chrome_content_plugin_client.h"
7 #if defined(ENABLE_REMOTING)
8 #include "base/path_service.h"
9 #include "base/file_path.h"
10 #include "content/public/common/content_paths.h"
11 #include "media/base/media.h"
12 #if defined(OS_WIN)
13 #include "base/logging.h"
14 #include "base/native_library.h"
15 #elif defined(OS_POSIX) && !defined(OS_MACOSX) && defined(USE_NSS)
16 #include "crypto/nss_util.h"
17 #endif
18 #endif
20 #if defined(OS_MACOSX)
21 #include "base/mac/mac_util.h"
22 #include "base/mac/scoped_cftyperef.h"
23 #include "base/sys_string_conversions.h"
24 #include "grit/chromium_strings.h"
25 #include "ui/base/l10n/l10n_util.h"
26 #endif
28 namespace chrome {
30 void ChromeContentPluginClient::PreSandboxInitialization() {
31 #if defined(ENABLE_REMOTING)
33 // Load crypto libraries for the Chromoting client plugin.
34 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(USE_NSS)
35 // On platforms where we use system NSS libraries, the .so's must be loaded
36 // before the sandbox is initialized.
37 crypto::ForceNSSNoDBInit();
38 crypto::EnsureNSSInit();
39 #elif defined(OS_WIN)
40 // crypt32.dll is used to decode X509 certificates for Chromoting.
41 std::string error;
42 if (base::LoadNativeLibrary(FilePath(L"crypt32.dll"), &error) == NULL)
43 LOG(ERROR) << "Failed to load crypto32.dll: " << error;
44 #endif // defined(OS_WIN)
46 // Load media libraries for the Chromoting client plugin.
47 FilePath media_path;
48 PathService::Get(content::DIR_MEDIA_LIBS, &media_path);
49 if (!media_path.empty())
50 media::InitializeMediaLibrary(media_path);
52 #endif // defined(ENABLE_REMOTING)
55 void ChromeContentPluginClient::PluginProcessStarted(
56 const string16& plugin_name) {
57 #if defined(OS_MACOSX)
58 base::mac::ScopedCFTypeRef<CFStringRef> cf_plugin_name(
59 base::SysUTF16ToCFStringRef(plugin_name));
60 base::mac::ScopedCFTypeRef<CFStringRef> app_name(
61 base::SysUTF16ToCFStringRef(
62 l10n_util::GetStringUTF16(IDS_SHORT_PLUGIN_APP_NAME)));
63 base::mac::ScopedCFTypeRef<CFStringRef> process_name(
64 CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ (%@)"),
65 cf_plugin_name.get(), app_name.get()));
66 base::mac::SetProcessName(process_name);
67 #endif
70 } // namespace chrome