| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/search/local_ntp_source.h" | 5 #include "chrome/browser/search/local_ntp_source.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| 11 #include "content/public/common/content_client.h" | |
| 12 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
| 13 #include "grit/browser_resources.h" | 12 #include "grit/browser_resources.h" |
| 14 #include "grit/ui_resources.h" | 13 #include "grit/ui_resources.h" |
| 15 #include "net/url_request/url_request.h" | 14 #include "net/url_request/url_request.h" |
| 15 #include "ui/base/resource/resource_bundle.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 const char kHtmlFilename[] = "local-ntp.html"; | 19 const char kHtmlFilename[] = "local-ntp.html"; |
| 20 const char kJSFilename[] = "local-ntp.js"; | 20 const char kJSFilename[] = "local-ntp.js"; |
| 21 const char kCssFilename[] = "local-ntp.css"; | 21 const char kCssFilename[] = "local-ntp.css"; |
| 22 const char kCloseBarFilename[] = "images/close_2.png"; | 22 const char kCloseBarFilename[] = "images/close_2.png"; |
| 23 const char kCloseBarHoverFilename[] = "images/close_2_hover.png"; | 23 const char kCloseBarHoverFilename[] = "images/close_2_hover.png"; |
| 24 const char kCloseBarActiveFilename[] = "images/close_2_active.png"; | 24 const char kCloseBarActiveFilename[] = "images/close_2_active.png"; |
| 25 | 25 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 51 } else if (path == kCloseBarHoverFilename) { | 51 } else if (path == kCloseBarHoverFilename) { |
| 52 identifier = IDR_CLOSE_2_H; | 52 identifier = IDR_CLOSE_2_H; |
| 53 } else if (path == kCloseBarActiveFilename) { | 53 } else if (path == kCloseBarActiveFilename) { |
| 54 identifier = IDR_CLOSE_2_P; | 54 identifier = IDR_CLOSE_2_P; |
| 55 } else { | 55 } else { |
| 56 callback.Run(NULL); | 56 callback.Run(NULL); |
| 57 return; | 57 return; |
| 58 } | 58 } |
| 59 | 59 |
| 60 scoped_refptr<base::RefCountedStaticMemory> response( | 60 scoped_refptr<base::RefCountedStaticMemory> response( |
| 61 content::GetContentClient()->GetDataResourceBytes(identifier)); | 61 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(identifier)); |
| 62 callback.Run(response); | 62 callback.Run(response); |
| 63 } | 63 } |
| 64 | 64 |
| 65 std::string LocalNtpSource::GetMimeType( | 65 std::string LocalNtpSource::GetMimeType( |
| 66 const std::string& path) const { | 66 const std::string& path) const { |
| 67 if (path == kHtmlFilename) | 67 if (path == kHtmlFilename) |
| 68 return "text/html"; | 68 return "text/html"; |
| 69 if (path == kJSFilename) | 69 if (path == kJSFilename) |
| 70 return "application/javascript"; | 70 return "application/javascript"; |
| 71 if (path == kCssFilename) | 71 if (path == kCssFilename) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 84 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { | 84 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { |
| 85 DCHECK(StartsWithASCII(request->url().path(), "/", true)); | 85 DCHECK(StartsWithASCII(request->url().path(), "/", true)); |
| 86 std::string filename = request->url().path().substr(1); | 86 std::string filename = request->url().path().substr(1); |
| 87 return filename == kHtmlFilename || filename == kJSFilename || | 87 return filename == kHtmlFilename || filename == kJSFilename || |
| 88 filename == kCssFilename || filename == kCloseBarFilename || | 88 filename == kCssFilename || filename == kCloseBarFilename || |
| 89 filename == kCloseBarHoverFilename || | 89 filename == kCloseBarHoverFilename || |
| 90 filename == kCloseBarActiveFilename; | 90 filename == kCloseBarActiveFilename; |
| 91 } | 91 } |
| 92 return false; | 92 return false; |
| 93 } | 93 } |
| OLD | NEW |