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

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

Issue 22629012: file_manager: Remove FileBrowser.OpeningFileType histogram (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 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) 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 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h" 4 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h"
5 5
6 #include "ash/shell.h" 6 #include "ash/shell.h"
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const char kSwfExtension[] = ".swf"; 93 const char kSwfExtension[] = ".swf";
94 // List of file extension we can open in tab. 94 // List of file extension we can open in tab.
95 const char* kBrowserSupportedExtensions[] = { 95 const char* kBrowserSupportedExtensions[] = {
96 #if defined(GOOGLE_CHROME_BUILD) 96 #if defined(GOOGLE_CHROME_BUILD)
97 ".pdf", ".swf", 97 ".pdf", ".swf",
98 #endif 98 #endif
99 ".bmp", ".jpg", ".jpeg", ".png", ".webp", ".gif", ".txt", ".html", ".htm", 99 ".bmp", ".jpg", ".jpeg", ".png", ".webp", ".gif", ".txt", ".html", ".htm",
100 ".mhtml", ".mht", ".svg" 100 ".mhtml", ".mht", ".svg"
101 }; 101 };
102 102
103 // List of all extensions we want to be shown in histogram that keep track of
104 // files that were unsuccessfully tried to be opened.
105 // The list has to be synced with histogram values.
106 const char* kUMATrackingExtensions[] = {
107 "other", ".doc", ".docx", ".odt", ".rtf", ".pdf", ".ppt", ".pptx", ".odp",
108 ".xls", ".xlsx", ".ods", ".csv", ".odf", ".rar", ".asf", ".wma", ".wmv",
109 ".mov", ".mpg", ".log"
110 };
111
112 // Returns a file manager URL for the given |path|. 103 // Returns a file manager URL for the given |path|.
113 GURL GetFileManagerUrl(const char* path) { 104 GURL GetFileManagerUrl(const char* path) {
114 return GURL(std::string("chrome-extension://") + kFileBrowserDomain + path); 105 return GURL(std::string("chrome-extension://") + kFileBrowserDomain + path);
115 } 106 }
116 107
117 bool IsSupportedBrowserExtension(const char* file_extension) { 108 bool IsSupportedBrowserExtension(const char* file_extension) {
118 for (size_t i = 0; i < arraysize(kBrowserSupportedExtensions); i++) { 109 for (size_t i = 0; i < arraysize(kBrowserSupportedExtensions); i++) {
119 if (base::strcasecmp(file_extension, kBrowserSupportedExtensions[i]) == 0) { 110 if (base::strcasecmp(file_extension, kBrowserSupportedExtensions[i]) == 0) {
120 return true; 111 return true;
121 } 112 }
(...skipping 27 matching lines...) Expand all
149 140
150 bool IsFlashPluginEnabled(Profile* profile) { 141 bool IsFlashPluginEnabled(Profile* profile) {
151 base::FilePath plugin_path( 142 base::FilePath plugin_path(
152 CommandLine::ForCurrentProcess()->GetSwitchValueNative( 143 CommandLine::ForCurrentProcess()->GetSwitchValueNative(
153 switches::kPpapiFlashPath)); 144 switches::kPpapiFlashPath));
154 if (plugin_path.empty()) 145 if (plugin_path.empty())
155 PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &plugin_path); 146 PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &plugin_path);
156 return IsPepperPluginEnabled(profile, plugin_path); 147 return IsPepperPluginEnabled(profile, plugin_path);
157 } 148 }
158 149
159 // Returns index |ext| has in the |array|. If there is no |ext| in |array|, last
160 // element's index is return (last element should have irrelevant value).
161 int UMAExtensionIndex(const char *file_extension,
162 const char** array,
163 size_t array_size) {
164 for (size_t i = 0; i < array_size; i++) {
165 if (base::strcasecmp(file_extension, array[i]) == 0) {
166 return i;
167 }
168 }
169 return 0;
170 }
171
172 // Convert numeric dialog type to a string. 150 // Convert numeric dialog type to a string.
173 std::string GetDialogTypeAsString( 151 std::string GetDialogTypeAsString(
174 ui::SelectFileDialog::Type dialog_type) { 152 ui::SelectFileDialog::Type dialog_type) {
175 std::string type_str; 153 std::string type_str;
176 switch (dialog_type) { 154 switch (dialog_type) {
177 case ui::SelectFileDialog::SELECT_NONE: 155 case ui::SelectFileDialog::SELECT_NONE:
178 type_str = "full-page"; 156 type_str = "full-page";
179 break; 157 break;
180 158
181 case ui::SelectFileDialog::SELECT_FOLDER: 159 case ui::SelectFileDialog::SELECT_FOLDER:
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
803 return false; 781 return false;
804 integration_service->file_system()->GetFileByPath( 782 integration_service->file_system()->GetFileByPath(
805 drive::util::ExtractDrivePath(path), 783 drive::util::ExtractDrivePath(path),
806 base::Bind(&OnCRXDownloadCallback, browser)); 784 base::Bind(&OnCRXDownloadCallback, browser));
807 } else { 785 } else {
808 InstallCRX(browser, path); 786 InstallCRX(browser, path);
809 } 787 }
810 return true; 788 return true;
811 } 789 }
812 790
813 // Unknown file type. Record UMA and show an error message. 791 // Failed to open the file of unknown type.
814 size_t extension_index = UMAExtensionIndex(file_extension.data(), 792 LOG(WARNING) << "Unknown file type: " << path.value();
815 kUMATrackingExtensions,
816 arraysize(kUMATrackingExtensions));
817 UMA_HISTOGRAM_ENUMERATION("FileBrowser.OpeningFileType",
818 extension_index,
819 arraysize(kUMATrackingExtensions) - 1);
820 return false; 793 return false;
821 } 794 }
822 795
823 // If a bundled plugin is enabled, we should open pdf/swf files in a tab. 796 // If a bundled plugin is enabled, we should open pdf/swf files in a tab.
824 bool ShouldBeOpenedWithPlugin(Profile* profile, const char* file_extension) { 797 bool ShouldBeOpenedWithPlugin(Profile* profile, const char* file_extension) {
825 if (LowerCaseEqualsASCII(file_extension, kPdfExtension)) 798 if (LowerCaseEqualsASCII(file_extension, kPdfExtension))
826 return IsPdfPluginEnabled(profile); 799 return IsPdfPluginEnabled(profile);
827 if (LowerCaseEqualsASCII(file_extension, kSwfExtension)) 800 if (LowerCaseEqualsASCII(file_extension, kSwfExtension))
828 return IsFlashPluginEnabled(profile); 801 return IsFlashPluginEnabled(profile);
829 return false; 802 return false;
(...skipping 14 matching lines...) Expand all
844 // determined, then indicate that it has the empty mime-type. This will 817 // determined, then indicate that it has the empty mime-type. This will
845 // only be matched if the Web Intents accepts "*" or "*/*". 818 // only be matched if the Web Intents accepts "*" or "*/*".
846 return ""; 819 return "";
847 } else { 820 } else {
848 return mime_type; 821 return mime_type;
849 } 822 }
850 } 823 }
851 824
852 } // namespace util 825 } // namespace util
853 } // namespace file_manager 826 } // namespace file_manager
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