| 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/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| 11 #include "build/build_config.h" |
| 11 #include "chrome/browser/search/local_files_ntp_source.h" | 12 #include "chrome/browser/search/local_files_ntp_source.h" |
| 12 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 14 #include "content/public/browser/user_metrics.h" | 15 #include "content/public/browser/user_metrics.h" |
| 15 #include "grit/browser_resources.h" | 16 #include "grit/browser_resources.h" |
| 16 #include "net/base/url_util.h" | 17 #include "net/base/url_util.h" |
| 17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 43 } | 44 } |
| 44 | 45 |
| 45 void MostVisitedIframeSource::StartDataRequest( | 46 void MostVisitedIframeSource::StartDataRequest( |
| 46 const std::string& path_and_query, | 47 const std::string& path_and_query, |
| 47 int render_process_id, | 48 int render_process_id, |
| 48 int render_frame_id, | 49 int render_frame_id, |
| 49 const content::URLDataSource::GotDataCallback& callback) { | 50 const content::URLDataSource::GotDataCallback& callback) { |
| 50 GURL url(chrome::kChromeSearchMostVisitedUrl + path_and_query); | 51 GURL url(chrome::kChromeSearchMostVisitedUrl + path_and_query); |
| 51 std::string path(url.path()); | 52 std::string path(url.path()); |
| 52 | 53 |
| 53 #if !defined(GOOGLE_CHROME_BUILD) | 54 #if !defined(GOOGLE_CHROME_BUILD) && !defined(OS_IOS) |
| 54 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 55 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 55 if (command_line->HasSwitch(switches::kLocalNtpReload)) { | 56 if (command_line->HasSwitch(switches::kLocalNtpReload)) { |
| 56 std::string rel_path = "most_visited_" + path.substr(1); | 57 std::string rel_path = "most_visited_" + path.substr(1); |
| 57 if (path == kSingleJSPath) { | 58 if (path == kSingleJSPath) { |
| 58 std::string origin; | 59 std::string origin; |
| 59 if (!GetOrigin(render_process_id, render_frame_id, &origin)) { | 60 if (!GetOrigin(render_process_id, render_frame_id, &origin)) { |
| 60 callback.Run(NULL); | 61 callback.Run(NULL); |
| 61 return; | 62 return; |
| 62 } | 63 } |
| 63 local_ntp::SendLocalFileResourceWithOrigin(rel_path, origin, callback); | 64 local_ntp::SendLocalFileResourceWithOrigin(rel_path, origin, callback); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 99 } |
| 99 } | 100 } |
| 100 | 101 |
| 101 bool MostVisitedIframeSource::ServesPath(const std::string& path) const { | 102 bool MostVisitedIframeSource::ServesPath(const std::string& path) const { |
| 102 return path == kTitleHTMLPath || path == kTitleCSSPath || | 103 return path == kTitleHTMLPath || path == kTitleCSSPath || |
| 103 path == kTitleJSPath || path == kThumbnailHTMLPath || | 104 path == kTitleJSPath || path == kThumbnailHTMLPath || |
| 104 path == kThumbnailCSSPath || path == kThumbnailJSPath || | 105 path == kThumbnailCSSPath || path == kThumbnailJSPath || |
| 105 path == kSingleHTMLPath || path == kSingleCSSPath || | 106 path == kSingleHTMLPath || path == kSingleCSSPath || |
| 106 path == kSingleJSPath || path == kUtilJSPath || path == kCommonCSSPath; | 107 path == kSingleJSPath || path == kUtilJSPath || path == kCommonCSSPath; |
| 107 } | 108 } |
| OLD | NEW |