OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/chromeos/gview_request_interceptor.h" | 5 #include "chrome/browser/chromeos/gview_request_interceptor.h" |
6 | 6 |
7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/singleton.h" | 9 #include "base/singleton.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 std::string mime_type; | 60 std::string mime_type; |
61 request->GetMimeType(&mime_type); | 61 request->GetMimeType(&mime_type); |
62 // If the local PDF viewing plug-in is installed and enabled, don't | 62 // If the local PDF viewing plug-in is installed and enabled, don't |
63 // redirect PDF files to Google Document Viewer. | 63 // redirect PDF files to Google Document Viewer. |
64 if (mime_type == kPdfMimeType) { | 64 if (mime_type == kPdfMimeType) { |
65 FilePath pdf_path; | 65 FilePath pdf_path; |
66 webkit::npapi::WebPluginInfo info; | 66 webkit::npapi::WebPluginInfo info; |
67 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); | 67 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); |
68 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( | 68 if (webkit::npapi::PluginList::Singleton()->GetPluginInfoByPath( |
69 pdf_path, &info) && | 69 pdf_path, &info) && |
70 info.enabled) | 70 webkit::npapi::IsPluginEnabled(info)) |
71 return NULL; | 71 return NULL; |
72 } | 72 } |
73 // If supported, build the URL to the Google Document Viewer | 73 // If supported, build the URL to the Google Document Viewer |
74 // including the origial document's URL, then create a new job that | 74 // including the origial document's URL, then create a new job that |
75 // will redirect the browser to this new URL. | 75 // will redirect the browser to this new URL. |
76 if (supported_mime_types_.count(mime_type) > 0) { | 76 if (supported_mime_types_.count(mime_type) > 0) { |
77 std::string url(kGViewUrlPrefix); | 77 std::string url(kGViewUrlPrefix); |
78 url += EscapePath(request->url().spec()); | 78 url += EscapePath(request->url().spec()); |
79 return new net::URLRequestRedirectJob(request, GURL(url)); | 79 return new net::URLRequestRedirectJob(request, GURL(url)); |
80 } | 80 } |
81 return NULL; | 81 return NULL; |
82 } | 82 } |
83 | 83 |
84 GViewRequestInterceptor* GViewRequestInterceptor::GetInstance() { | 84 GViewRequestInterceptor* GViewRequestInterceptor::GetInstance() { |
85 return Singleton<GViewRequestInterceptor>::get(); | 85 return Singleton<GViewRequestInterceptor>::get(); |
86 } | 86 } |
87 | 87 |
88 } // namespace chromeos | 88 } // namespace chromeos |
OLD | NEW |