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

Side by Side Diff: chrome/browser/extensions/file_manager_util.cc

Issue 7465017: Adding UMA stats support for file open events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/browser/extensions/file_manager_util.h" 4 #include "chrome/browser/extensions/file_manager_util.h"
5 5
6 #include "base/json/json_writer.h" 6 #include "base/json/json_writer.h"
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h"
8 #include "base/string_util.h" 9 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "chrome/browser/chromeos/media/media_player.h" 12 #include "chrome/browser/chromeos/media/media_player.h"
12 #include "chrome/browser/platform_util.h" 13 #include "chrome/browser/platform_util.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
16 #include "content/browser/browser_thread.h" 17 #include "content/browser/browser_thread.h"
17 #include "content/browser/user_metrics.h" 18 #include "content/browser/user_metrics.h"
(...skipping 25 matching lines...) Expand all
43 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS) 44 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_PROPRIETARY_CODECS)
44 ".3gp", ".avi", ".mp3", ".mp4", ".m4v", ".mov", ".m4a", 45 ".3gp", ".avi", ".mp3", ".mp4", ".m4v", ".mov", ".m4a",
45 #endif 46 #endif
46 ".flac", ".ogm", ".ogv", ".ogx", ".ogg", ".oga", ".wav", ".webm", 47 ".flac", ".ogm", ".ogv", ".ogx", ".ogg", ".oga", ".wav", ".webm",
47 /* TODO(zelidrag): Add unsupported ones as we enable them: 48 /* TODO(zelidrag): Add unsupported ones as we enable them:
48 ".mkv", ".divx", ".xvid", ".wmv", ".asf", ".mpeg", ".mpg", 49 ".mkv", ".divx", ".xvid", ".wmv", ".asf", ".mpeg", ".mpg",
49 ".wma", ".aiff", 50 ".wma", ".aiff",
50 */ 51 */
51 }; 52 };
52 53
54 // List of all extensions we want to be shown in histogram that keep track of
55 // files that were unsuccessfully tried to be opened.
56 // The list has to be synced with histogram values.
57 const char* kUMATrackingExtensions[] = {
58 "other", ".doc", ".docx", ".odt", ".rtf", ".pdf", ".ppt", ".pptx", ".odp",
59 ".xls", ".xlsx", ".ods", ".csv", ".odf", ".rar", ".asf", ".wma", ".wmv",
60 ".mov", ".mpg", ".log"
61 };
62
53 bool IsSupportedBrowserExtension(const char* ext) { 63 bool IsSupportedBrowserExtension(const char* ext) {
54 for (size_t i = 0; i < arraysize(kBrowserSupportedExtensions); i++) { 64 for (size_t i = 0; i < arraysize(kBrowserSupportedExtensions); i++) {
55 if (base::strcasecmp(ext, kBrowserSupportedExtensions[i]) == 0) { 65 if (base::strcasecmp(ext, kBrowserSupportedExtensions[i]) == 0) {
56 return true; 66 return true;
57 } 67 }
58 } 68 }
59 return false; 69 return false;
60 } 70 }
61 71
62 bool IsSupportedAVExtension(const char* ext) { 72 bool IsSupportedAVExtension(const char* ext) {
63 for (size_t i = 0; i < arraysize(kAVExtensions); i++) { 73 for (size_t i = 0; i < arraysize(kAVExtensions); i++) {
64 if (base::strcasecmp(ext, kAVExtensions[i]) == 0) { 74 if (base::strcasecmp(ext, kAVExtensions[i]) == 0) {
65 return true; 75 return true;
66 } 76 }
67 } 77 }
68 return false; 78 return false;
69 } 79 }
70 80
71 // static 81 // static
72 GURL FileManagerUtil::GetFileBrowserExtensionUrl() { 82 GURL FileManagerUtil::GetFileBrowserExtensionUrl() {
73 return GURL(kFileBrowserExtensionUrl); 83 return GURL(kFileBrowserExtensionUrl);
74 } 84 }
75 85
86 // Returns index |ext| has in the |array|. If there is no |ext| in |array|, last
87 // element's index is return (last element should have irrelevant value).
88 int UMAExtensionIndex(const char *ext,
89 const char** array,
90 size_t array_size) {
91 for (size_t i = 0; i < array_size; i++) {
92 if (base::strcasecmp(ext, array[i]) == 0) {
93 return i;
94 }
95 }
96 return 0;
97 }
98
76 // static 99 // static
77 GURL FileManagerUtil::GetFileBrowserUrl() { 100 GURL FileManagerUtil::GetFileBrowserUrl() {
78 return GURL(kBaseFileBrowserUrl); 101 return GURL(kBaseFileBrowserUrl);
79 } 102 }
80 103
81 // static 104 // static
82 GURL FileManagerUtil::GetMediaPlayerUrl() { 105 GURL FileManagerUtil::GetMediaPlayerUrl() {
83 return GURL(kMediaPlayerUrl); 106 return GURL(kMediaPlayerUrl);
84 } 107 }
85 108
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 if (!browser) 199 if (!browser)
177 return; 200 return;
178 MediaPlayer* mediaplayer = MediaPlayer::GetInstance(); 201 MediaPlayer* mediaplayer = MediaPlayer::GetInstance();
179 if (enqueue) 202 if (enqueue)
180 mediaplayer->EnqueueMediaFile(browser->profile(), full_path, NULL); 203 mediaplayer->EnqueueMediaFile(browser->profile(), full_path, NULL);
181 else 204 else
182 mediaplayer->ForcePlayMediaFile(browser->profile(), full_path, NULL); 205 mediaplayer->ForcePlayMediaFile(browser->profile(), full_path, NULL);
183 return; 206 return;
184 } 207 }
185 208
186 // Unknown file type. Show an error message. 209 // Unknown file type. Record UMA and show an error message.
210 size_t extension_index = UMAExtensionIndex(ext.data(),
211 kUMATrackingExtensions,
212 arraysize(kUMATrackingExtensions));
213 UMA_HISTOGRAM_ENUMERATION("FileBrowser.OpeningFileType",
214 extension_index,
215 arraysize(kUMATrackingExtensions) - 1);
216
187 BrowserThread::PostTask( 217 BrowserThread::PostTask(
188 BrowserThread::UI, FROM_HERE, 218 BrowserThread::UI, FROM_HERE,
189 NewRunnableFunction( 219 NewRunnableFunction(
190 &platform_util::SimpleErrorBox, 220 &platform_util::SimpleErrorBox,
191 static_cast<gfx::NativeWindow>(NULL), 221 static_cast<gfx::NativeWindow>(NULL),
192 l10n_util::GetStringUTF16(IDS_FILEBROWSER_ERROR_TITLE), 222 l10n_util::GetStringUTF16(IDS_FILEBROWSER_ERROR_TITLE),
193 l10n_util::GetStringFUTF16(IDS_FILEBROWSER_ERROR_UNKNOWN_FILE_TYPE, 223 l10n_util::GetStringFUTF16(IDS_FILEBROWSER_ERROR_UNKNOWN_FILE_TYPE,
194 UTF8ToUTF16(full_path.BaseName().value())) 224 UTF8ToUTF16(full_path.BaseName().value()))
195 )); 225 ));
196 } 226 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 case SelectFileDialog::SELECT_OPEN_MULTI_FILE: 296 case SelectFileDialog::SELECT_OPEN_MULTI_FILE:
267 type_str = "open-multi-file"; 297 type_str = "open-multi-file";
268 break; 298 break;
269 299
270 default: 300 default:
271 NOTREACHED(); 301 NOTREACHED();
272 } 302 }
273 303
274 return type_str; 304 return type_str;
275 } 305 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698