| 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/most_visited_iframe_source.h" | 5 #include "chrome/browser/search/most_visited_iframe_source.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 std::string MostVisitedIframeSource::GetSource() const { | 43 std::string MostVisitedIframeSource::GetSource() const { |
| 44 return chrome::kChromeSearchMostVisitedHost; | 44 return chrome::kChromeSearchMostVisitedHost; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void MostVisitedIframeSource::StartDataRequest( | 47 void MostVisitedIframeSource::StartDataRequest( |
| 48 const std::string& path_and_query, | 48 const std::string& path_and_query, |
| 49 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, | 49 const content::ResourceRequestInfo::WebContentsGetter& wc_getter, |
| 50 const content::URLDataSource::GotDataCallback& callback) { | 50 const content::URLDataSource::GotDataCallback& callback) { |
| 51 GURL url(chrome::kChromeSearchMostVisitedUrl + path_and_query); | 51 GURL url(chrome::kChromeSearchMostVisitedUrl + path_and_query); |
| 52 std::string path(url.path()); | 52 base::StringPiece path(url.path()); |
| 53 | 53 |
| 54 #if !defined(GOOGLE_CHROME_BUILD) | 54 #if !defined(GOOGLE_CHROME_BUILD) |
| 55 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 55 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 56 if (command_line->HasSwitch(switches::kLocalNtpReload)) { | 56 if (command_line->HasSwitch(switches::kLocalNtpReload)) { |
| 57 std::string rel_path = "most_visited_" + path.substr(1); | 57 std::string rel_path = "most_visited_" + path.substr(1).as_string(); |
| 58 if (path == kSingleJSPath) { | 58 if (path == kSingleJSPath) { |
| 59 std::string origin; | 59 std::string origin; |
| 60 if (!GetOrigin(wc_getter, &origin)) { | 60 if (!GetOrigin(wc_getter, &origin)) { |
| 61 callback.Run(nullptr); | 61 callback.Run(nullptr); |
| 62 return; | 62 return; |
| 63 } | 63 } |
| 64 local_ntp::SendLocalFileResourceWithOrigin(rel_path, origin, callback); | 64 local_ntp::SendLocalFileResourceWithOrigin(rel_path, origin, callback); |
| 65 } else { | 65 } else { |
| 66 local_ntp::SendLocalFileResource(rel_path, callback); | 66 local_ntp::SendLocalFileResource(rel_path, callback); |
| 67 } | 67 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 96 } | 96 } |
| 97 } | 97 } |
| 98 | 98 |
| 99 bool MostVisitedIframeSource::ServesPath(const std::string& path) const { | 99 bool MostVisitedIframeSource::ServesPath(const std::string& path) const { |
| 100 return path == kTitleHTMLPath || path == kTitleCSSPath || | 100 return path == kTitleHTMLPath || path == kTitleCSSPath || |
| 101 path == kTitleJSPath || path == kThumbnailHTMLPath || | 101 path == kTitleJSPath || path == kThumbnailHTMLPath || |
| 102 path == kThumbnailCSSPath || path == kThumbnailJSPath || | 102 path == kThumbnailCSSPath || path == kThumbnailJSPath || |
| 103 path == kSingleHTMLPath || path == kSingleCSSPath || | 103 path == kSingleHTMLPath || path == kSingleCSSPath || |
| 104 path == kSingleJSPath || path == kUtilJSPath || path == kCommonCSSPath; | 104 path == kSingleJSPath || path == kUtilJSPath || path == kCommonCSSPath; |
| 105 } | 105 } |
| OLD | NEW |