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/browser/media_galleries/media_galleries_test_util.h" | 5 #include "chrome/browser/media_galleries/media_galleries_test_util.h" |
6 | 6 |
7 #if defined(OS_WIN) | |
8 #include <windows.h> | |
9 #endif | |
10 | |
7 #include "base/base_paths.h" | 11 #include "base/base_paths.h" |
8 #include "base/file_util.h" | 12 #include "base/file_util.h" |
9 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
10 #include "base/path_service.h" | 14 #include "base/path_service.h" |
11 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
12 #include "chrome/browser/extensions/extension_prefs.h" | 16 #include "chrome/browser/extensions/extension_prefs.h" |
13 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
14 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
19 #include "chrome/browser/media_galleries/fileapi/picasa_finder.h" | |
15 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/common/chrome_paths.h" | 21 #include "chrome/common/chrome_paths.h" |
17 #include "chrome/common/extensions/extension.h" | 22 #include "chrome/common/extensions/extension.h" |
18 #include "extensions/common/manifest_constants.h" | 23 #include "extensions/common/manifest_constants.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
20 | 25 |
26 #if defined(OS_WIN) | |
27 #include "base/test/test_reg_util_win.h" | |
28 #include "base/win/registry.h" | |
29 #endif | |
30 | |
21 scoped_refptr<extensions::Extension> AddMediaGalleriesApp( | 31 scoped_refptr<extensions::Extension> AddMediaGalleriesApp( |
22 const std::string& name, | 32 const std::string& name, |
23 const std::vector<std::string>& media_galleries_permissions, | 33 const std::vector<std::string>& media_galleries_permissions, |
24 Profile* profile) { | 34 Profile* profile) { |
25 scoped_ptr<DictionaryValue> manifest(new DictionaryValue); | 35 scoped_ptr<DictionaryValue> manifest(new DictionaryValue); |
26 manifest->SetString(extensions::manifest_keys::kName, name); | 36 manifest->SetString(extensions::manifest_keys::kName, name); |
27 manifest->SetString(extensions::manifest_keys::kVersion, "0.1"); | 37 manifest->SetString(extensions::manifest_keys::kVersion, "0.1"); |
28 manifest->SetInteger(extensions::manifest_keys::kManifestVersion, 2); | 38 manifest->SetInteger(extensions::manifest_keys::kManifestVersion, 2); |
29 ListValue* background_script_list = new ListValue; | 39 ListValue* background_script_list = new ListValue; |
30 background_script_list->Append(Value::CreateStringValue("background.js")); | 40 background_script_list->Append(Value::CreateStringValue("background.js")); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 base::FilePath EnsureMediaDirectoriesExists::GetFakeAppDataPath() const { | 88 base::FilePath EnsureMediaDirectoriesExists::GetFakeAppDataPath() const { |
79 DCHECK(fake_dir_.IsValid()); | 89 DCHECK(fake_dir_.IsValid()); |
80 return fake_dir_.path().AppendASCII("appdata"); | 90 return fake_dir_.path().AppendASCII("appdata"); |
81 } | 91 } |
82 | 92 |
83 #if defined(OS_WIN) | 93 #if defined(OS_WIN) |
84 base::FilePath EnsureMediaDirectoriesExists::GetFakeLocalAppDataPath() const { | 94 base::FilePath EnsureMediaDirectoriesExists::GetFakeLocalAppDataPath() const { |
85 DCHECK(fake_dir_.IsValid()); | 95 DCHECK(fake_dir_.IsValid()); |
86 return fake_dir_.path().AppendASCII("localappdata"); | 96 return fake_dir_.path().AppendASCII("localappdata"); |
87 } | 97 } |
98 | |
99 void EnsureMediaDirectoriesExists::WriteCustomPicasaAppDataPathToRegistry( | |
100 const base::FilePath& path) { | |
101 base::win::RegKey key; | |
102 base::win::RegKey(HKEY_CURRENT_USER, picasa::kPicasaRegistryPath, | |
103 KEY_SET_VALUE) | |
104 .WriteValue(picasa::kPicasaRegistryAppDataKey, path.value().c_str()); | |
vandebo (ex-Chrome)
2013/10/02 15:32:46
nit: wrapping
tommycli
2013/10/02 16:44:39
Done.
| |
105 } | |
88 #endif | 106 #endif |
89 | 107 |
90 #if defined(OS_WIN) || defined(OS_MACOSX) | 108 #if defined(OS_WIN) || defined(OS_MACOSX) |
91 base::FilePath | 109 base::FilePath |
92 EnsureMediaDirectoriesExists::GetFakePicasaFoldersRootPath() const { | 110 EnsureMediaDirectoriesExists::GetFakePicasaFoldersRootPath() const { |
93 DCHECK(fake_dir_.IsValid()); | 111 DCHECK(fake_dir_.IsValid()); |
94 return fake_dir_.path().AppendASCII("picasa_folders"); | 112 return fake_dir_.path().AppendASCII("picasa_folders"); |
95 } | 113 } |
96 #endif | 114 #endif |
97 | 115 |
98 void EnsureMediaDirectoriesExists::Init() { | 116 void EnsureMediaDirectoriesExists::Init() { |
99 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) | 117 #if defined(OS_CHROMEOS) || defined(OS_ANDROID) |
100 return; | 118 return; |
101 #else | 119 #else |
102 | 120 |
103 ASSERT_TRUE(fake_dir_.CreateUniqueTempDir()); | 121 ASSERT_TRUE(fake_dir_.CreateUniqueTempDir()); |
104 | 122 |
105 #if defined(OS_WIN) || defined(OS_MACOSX) | 123 #if defined(OS_WIN) || defined(OS_MACOSX) |
106 // This is to control whether or not tests think iTunes and Picasa are | 124 // This is to control whether or not tests think iTunes and Picasa are |
107 // installed. | 125 // installed. |
108 app_data_override_.reset(new base::ScopedPathOverride( | 126 app_data_override_.reset(new base::ScopedPathOverride( |
109 base::DIR_APP_DATA, GetFakeAppDataPath())); | 127 base::DIR_APP_DATA, GetFakeAppDataPath())); |
110 #if defined(OS_WIN) | 128 #if defined(OS_WIN) |
111 // Picasa on Windows is in the DIR_LOCAL_APP_DATA directory. | 129 // Picasa on Windows is by default in the DIR_LOCAL_APP_DATA directory. |
112 local_app_data_override_.reset(new base::ScopedPathOverride( | 130 local_app_data_override_.reset(new base::ScopedPathOverride( |
113 base::DIR_LOCAL_APP_DATA, GetFakeLocalAppDataPath())); | 131 base::DIR_LOCAL_APP_DATA, GetFakeLocalAppDataPath())); |
132 // Picasa also looks in the registry for an alternate path. | |
133 registry_override_.OverrideRegistry(HKEY_CURRENT_USER, L"hkcu_picasa"); | |
114 #endif | 134 #endif |
115 #endif | 135 #endif |
116 | 136 |
117 music_override_.reset(new base::ScopedPathOverride( | 137 music_override_.reset(new base::ScopedPathOverride( |
118 chrome::DIR_USER_MUSIC, fake_dir_.path().AppendASCII("music"))); | 138 chrome::DIR_USER_MUSIC, fake_dir_.path().AppendASCII("music"))); |
119 pictures_override_.reset(new base::ScopedPathOverride( | 139 pictures_override_.reset(new base::ScopedPathOverride( |
120 chrome::DIR_USER_PICTURES, fake_dir_.path().AppendASCII("pictures"))); | 140 chrome::DIR_USER_PICTURES, fake_dir_.path().AppendASCII("pictures"))); |
121 video_override_.reset(new base::ScopedPathOverride( | 141 video_override_.reset(new base::ScopedPathOverride( |
122 chrome::DIR_USER_VIDEOS, fake_dir_.path().AppendASCII("videos"))); | 142 chrome::DIR_USER_VIDEOS, fake_dir_.path().AppendASCII("videos"))); |
123 num_galleries_ = 3; | 143 num_galleries_ = 3; |
124 #endif | 144 #endif |
125 } | 145 } |
OLD | NEW |