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