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
3 // found in the LICENSE file.
5 #include "chrome/browser/search/suggestion_iframe_source.h"
7 #include "chrome/common/url_constants.h"
8 #include "grit/browser_resources.h"
12 const char kLoaderHtmlPath
[] = "/loader.html";
13 const char kLoaderJSPath
[] = "/loader.js";
14 const char kResultHtmlPath
[] = "/result.html";
15 const char kResultJSPath
[] = "/result.js";
19 SuggestionIframeSource::SuggestionIframeSource() {
22 SuggestionIframeSource::~SuggestionIframeSource() {
25 std::string
SuggestionIframeSource::GetSource() const {
26 return chrome::kChromeSearchSuggestionHost
;
29 void SuggestionIframeSource::StartDataRequest(
30 const std::string
& path
,
31 int render_process_id
,
33 const content::URLDataSource::GotDataCallback
& callback
) {
34 // path has no leading '/' and includes any query string. Since we don't
35 // expect a query string for requests to this source, just add back the '/'.
36 std::string full_path
= "/" + path
;
37 if (full_path
== kLoaderHtmlPath
) {
38 SendResource(IDR_OMNIBOX_RESULT_LOADER_HTML
, callback
);
39 } else if (full_path
== kLoaderJSPath
) {
40 SendJSWithOrigin(IDR_OMNIBOX_RESULT_LOADER_JS
, render_process_id
,
41 render_view_id
, callback
);
42 } else if (full_path
== kResultHtmlPath
) {
43 SendResource(IDR_OMNIBOX_RESULT_HTML
, callback
);
44 } else if (full_path
== kResultJSPath
) {
45 SendJSWithOrigin(IDR_OMNIBOX_RESULT_JS
, render_process_id
, render_view_id
,
52 bool SuggestionIframeSource::ServesPath(const std::string
& path
) const {
53 return path
== kLoaderHtmlPath
|| path
== kLoaderJSPath
||
54 path
== kResultHtmlPath
|| path
== kResultJSPath
;