1424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Copyright 2013 The Chromium Authors. All rights reserved.
2424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// found in the LICENSE file.
4424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "chrome/browser/chromeos/file_manager/open_with_browser.h"
6424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
7424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "base/bind.h"
8424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "base/command_line.h"
9424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "base/logging.h"
10424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "base/path_service.h"
11424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "base/threading/sequenced_worker_pool.h"
12d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)#include "chrome/browser/browser_process.h"
13424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/browser/chromeos/drive/file_system_util.h"
14424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
15424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/browser/plugins/plugin_prefs.h"
16424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/browser/profiles/profile.h"
17424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/browser/profiles/profile_manager.h"
18424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/browser/ui/browser.h"
19424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/browser/ui/browser_tabstrip.h"
20424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/browser/ui/browser_window.h"
210f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)#include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
22424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/browser/ui/simple_message_box.h"
23424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/common/chrome_paths.h"
24424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chrome/common/chrome_switches.h"
25424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "chromeos/chromeos_switches.h"
26424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "content/public/browser/browser_thread.h"
27424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "content/public/browser/plugin_service.h"
28424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "content/public/common/pepper_plugin_info.h"
29424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "content/public/common/webplugininfo.h"
30424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "net/base/net_util.h"
31424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
32424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)using content::BrowserThread;
33424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)using content::PluginService;
34424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
35424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace file_manager {
36424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace util {
37424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace {
38424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
39424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)const base::FilePath::CharType kPdfExtension[] = FILE_PATH_LITERAL(".pdf");
40424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)const base::FilePath::CharType kSwfExtension[] = FILE_PATH_LITERAL(".swf");
41424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
42424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// List of file extensions viewable in the browser.
43424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)const base::FilePath::CharType* kFileExtensionsViewableInBrowser[] = {
44424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#if defined(GOOGLE_CHROME_BUILD)
45424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".pdf"),
46424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".swf"),
47424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#endif
48424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".bmp"),
49a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)  FILE_PATH_LITERAL(".ico"),
50424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".jpg"),
51424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".jpeg"),
52424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".png"),
53424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".webp"),
54424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".gif"),
55424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".txt"),
56424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".html"),
57424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".htm"),
58424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".mhtml"),
59424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".mht"),
60424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  FILE_PATH_LITERAL(".svg"),
61424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)};
62424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
63424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Returns true if |file_path| is viewable in the browser (ex. HTML file).
64424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)bool IsViewableInBrowser(const base::FilePath& file_path) {
65424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  for (size_t i = 0; i < arraysize(kFileExtensionsViewableInBrowser); i++) {
66424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    if (file_path.MatchesExtension(kFileExtensionsViewableInBrowser[i]))
67424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      return true;
68424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  }
69424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  return false;
70424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}
71424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
72424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)bool IsPepperPluginEnabled(Profile* profile,
73424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)                           const base::FilePath& plugin_path) {
74424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  DCHECK(profile);
75424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
76424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  content::PepperPluginInfo* pepper_info =
77424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      PluginService::GetInstance()->GetRegisteredPpapiPluginInfo(plugin_path);
78424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  if (!pepper_info)
79424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    return false;
80424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
81424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  scoped_refptr<PluginPrefs> plugin_prefs = PluginPrefs::GetForProfile(profile);
82424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  if (!plugin_prefs.get())
83424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    return false;
84424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
85424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  return plugin_prefs->IsPluginEnabled(pepper_info->ToWebPluginInfo());
86424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}
87424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
88424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)bool IsPdfPluginEnabled(Profile* profile) {
89424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  DCHECK(profile);
90424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
91424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  base::FilePath plugin_path;
92424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  PathService::Get(chrome::FILE_PDF_PLUGIN, &plugin_path);
93424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  return IsPepperPluginEnabled(profile, plugin_path);
94424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}
95424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
96424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)bool IsFlashPluginEnabled(Profile* profile) {
97424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  DCHECK(profile);
98424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
99424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  base::FilePath plugin_path(
100424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      CommandLine::ForCurrentProcess()->GetSwitchValueNative(
101424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)          switches::kPpapiFlashPath));
102424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  if (plugin_path.empty())
103424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    PathService::Get(chrome::FILE_PEPPER_FLASH_PLUGIN, &plugin_path);
104424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  return IsPepperPluginEnabled(profile, plugin_path);
105424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}
106424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
107424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)void OpenNewTab(Profile* profile, const GURL& url) {
108424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
109d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
110d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // Check the validity of the pointer so that the closure from
111d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  // base::Bind(&OpenNewTab, profile) can be passed between threads.
112d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)  if (!g_browser_process->profile_manager()->IsValidProfile(profile))
113d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)    return;
114d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)
1150f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)  chrome::ScopedTabbedBrowserDisplayer displayer(
116424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      profile, chrome::HOST_DESKTOP_TYPE_ASH);
1170f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)  chrome::AddSelectedTabWithURL(displayer.browser(), url,
1180f1bc08d4cfcc34181b0b5cbf065c40f687bf740Torne (Richard Coles)      content::PAGE_TRANSITION_LINK);
119424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}
120424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
121424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Reads the alternate URL from a GDoc file. When it fails, returns a file URL
122424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// for |file_path| as fallback.
123424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// Note that an alternate url is a URL to open a hosted document.
124424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)GURL ReadUrlFromGDocOnBlockingPool(const base::FilePath& file_path) {
125424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  GURL url = drive::util::ReadUrlFromGDocFile(file_path);
126424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  if (url.is_empty())
127424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    url = net::FilePathToFileURL(file_path);
128424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  return url;
129424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}
130424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
131424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}  // namespace
132424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
133424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)bool OpenFileWithBrowser(Profile* profile, const base::FilePath& file_path) {
134424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
135424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  DCHECK(profile);
136424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
137424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // For things supported natively by the browser, we should open it
138424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // in a tab.
139424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  if (IsViewableInBrowser(file_path) ||
140424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      ShouldBeOpenedWithPlugin(profile, file_path.Extension())) {
141424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    GURL page_url = net::FilePathToFileURL(file_path);
142424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    // Override drive resource to point to internal handler instead of file URL.
143424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    if (drive::util::IsUnderDriveMountPoint(file_path)) {
144424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      page_url = drive::util::FilePathToDriveURL(
145424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)          drive::util::ExtractDrivePath(file_path));
146424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    }
147424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    OpenNewTab(profile, page_url);
148424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    return true;
149424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  }
150424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
151424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  if (drive::util::HasGDocFileExtension(file_path)) {
152424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    if (drive::util::IsUnderDriveMountPoint(file_path)) {
153424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      // The file is on Google Docs. Open with drive URL.
154424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      GURL url = drive::util::FilePathToDriveURL(
155424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)          drive::util::ExtractDrivePath(file_path));
156424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      OpenNewTab(profile, url);
157424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    } else {
158424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      // The file is local (downloaded from an attachment or otherwise copied).
159424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      // Parse the file to extract the Docs url and open this url.
160424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      base::PostTaskAndReplyWithResult(
161424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)          BrowserThread::GetBlockingPool(),
162424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)          FROM_HERE,
163424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)          base::Bind(&ReadUrlFromGDocOnBlockingPool, file_path),
164d0247b1b59f9c528cb6df88b4f2b9afaf80d181eTorne (Richard Coles)          base::Bind(&OpenNewTab, profile));
165424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    }
166424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    return true;
167424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  }
168424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
169424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  // Failed to open the file of unknown type.
170424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  LOG(WARNING) << "Unknown file type: " << file_path.value();
171424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  return false;
172424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}
173424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
174424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)// If a bundled plugin is enabled, we should open pdf/swf files in a tab.
175424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)bool ShouldBeOpenedWithPlugin(
176424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    Profile* profile,
177424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    const base::FilePath::StringType& file_extension) {
178424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  DCHECK(profile);
179424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
180424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  const base::FilePath file_path =
181424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)      base::FilePath::FromUTF8Unsafe("dummy").AddExtension(file_extension);
182424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  if (file_path.MatchesExtension(kPdfExtension))
183424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    return IsPdfPluginEnabled(profile);
184424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  if (file_path.MatchesExtension(kSwfExtension))
185424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)    return IsFlashPluginEnabled(profile);
186424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)  return false;
187424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}
188424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)
189424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}  // namespace util
190424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)}  // namespace file_manager
191