Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: chrome/common/chrome_paths.cc

Issue 7087014: Support automatic javascript test registry in gtest when creating WebUI tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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/common/chrome_paths.h" 5 #include "chrome/common/chrome_paths.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/singleton.h"
10 #include "base/path_service.h" 11 #include "base/path_service.h"
11 #include "base/string_util.h" 12 #include "base/string_util.h"
12 #include "base/sys_info.h" 13 #include "base/sys_info.h"
13 #include "chrome/common/chrome_constants.h" 14 #include "chrome/common/chrome_constants.h"
14 #include "chrome/common/chrome_paths_internal.h" 15 #include "chrome/common/chrome_paths_internal.h"
15 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
16 17
17 #if defined(OS_MACOSX) 18 #if defined(OS_MACOSX)
18 #include "base/mac/mac_util.h" 19 #include "base/mac/mac_util.h"
19 #endif 20 #endif
20 21
22 namespace chrome {
23
24 bool PathProvider(int key, FilePath* result);
25
26 } // namespace chrome
27
21 namespace { 28 namespace {
22 29
23 // File name of the internal Flash plugin on different platforms. 30 // File name of the internal Flash plugin on different platforms.
24 const FilePath::CharType kInternalFlashPluginFileName[] = 31 const FilePath::CharType kInternalFlashPluginFileName[] =
25 #if defined(OS_MACOSX) 32 #if defined(OS_MACOSX)
26 FILE_PATH_LITERAL("Flash Player Plugin for Chrome.plugin"); 33 FILE_PATH_LITERAL("Flash Player Plugin for Chrome.plugin");
27 #elif defined(OS_WIN) 34 #elif defined(OS_WIN)
28 FILE_PATH_LITERAL("gcswf32.dll"); 35 FILE_PATH_LITERAL("gcswf32.dll");
29 #else // OS_LINUX, etc. 36 #else // OS_LINUX, etc.
30 FILE_PATH_LITERAL("libgcflashplayer.so"); 37 FILE_PATH_LITERAL("libgcflashplayer.so");
(...skipping 13 matching lines...) Expand all
44 const FilePath::CharType kInternalNaClPluginFileName[] = 51 const FilePath::CharType kInternalNaClPluginFileName[] =
45 #if defined(OS_WIN) 52 #if defined(OS_WIN)
46 FILE_PATH_LITERAL("ppGoogleNaClPluginChrome.dll"); 53 FILE_PATH_LITERAL("ppGoogleNaClPluginChrome.dll");
47 #elif defined(OS_MACOSX) 54 #elif defined(OS_MACOSX)
48 // TODO(noelallen) Please verify this extention name is correct. 55 // TODO(noelallen) Please verify this extention name is correct.
49 FILE_PATH_LITERAL("ppGoogleNaClPluginChrome.plugin"); 56 FILE_PATH_LITERAL("ppGoogleNaClPluginChrome.plugin");
50 #else // Linux and Chrome OS 57 #else // Linux and Chrome OS
51 FILE_PATH_LITERAL("libppGoogleNaClPluginChrome.so"); 58 FILE_PATH_LITERAL("libppGoogleNaClPluginChrome.so");
52 #endif 59 #endif
53 60
61 // web_ui_browsertest needs this service at linker initialization time so we
62 // provide ability to register and unregister base on Singleton
63 // construction/destruction.
64 class RegistryHelper {
65 public:
66 RegistryHelper() {
67 PathService::RegisterProvider(&chrome::PathProvider,
68 chrome::PATH_START, chrome::PATH_END);
69 }
70
71 ~RegistryHelper() {
72 PathService::UnregisterProvider(&chrome::PathProvider);
73 }
74
75 static RegistryHelper* GetInstance() {
76 return Singleton<RegistryHelper>::get();
77 }
78
79 private:
80 DISALLOW_COPY_AND_ASSIGN(RegistryHelper);
81 };
82
54 } // namespace 83 } // namespace
55 84
56 namespace chrome { 85 namespace chrome {
57 86
58 // Gets the path for internal plugins. 87 // Gets the path for internal plugins.
59 bool GetInternalPluginsDirectory(FilePath* result) { 88 bool GetInternalPluginsDirectory(FilePath* result) {
60 #if defined(OS_MACOSX) 89 #if defined(OS_MACOSX)
61 // If called from Chrome, get internal plugins from a subdirectory of the 90 // If called from Chrome, get internal plugins from a subdirectory of the
62 // framework. 91 // framework.
63 if (base::mac::AmIBundled()) { 92 if (base::mac::AmIBundled()) {
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 !file_util::CreateDirectory(cur)) 345 !file_util::CreateDirectory(cur))
317 return false; 346 return false;
318 347
319 *result = cur; 348 *result = cur;
320 return true; 349 return true;
321 } 350 }
322 351
323 // This cannot be done as a static initializer sadly since Visual Studio will 352 // This cannot be done as a static initializer sadly since Visual Studio will
324 // eliminate this object file if there is no direct entry point into it. 353 // eliminate this object file if there is no direct entry point into it.
325 void RegisterPathProvider() { 354 void RegisterPathProvider() {
326 PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); 355 RegistryHelper::GetInstance();
327 } 356 }
328 357
329 } // namespace chrome 358 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698