Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Side by Side Diff: chrome/browser/instant/local_omnibox_popup_source.cc

Issue 12720004: InstantExtended: local omnibox popup fixes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/instant/local_omnibox_popup_source.h" 5 #include "chrome/browser/instant/local_omnibox_popup_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" 11 #include "content/public/common/content_client.h"
12 #include "googleurl/src/gurl.h" 12 #include "googleurl/src/gurl.h"
13 #include "grit/browser_resources.h" 13 #include "grit/browser_resources.h"
14 #include "net/url_request/url_request.h" 14 #include "net/url_request/url_request.h"
15 15
16 namespace { 16 namespace {
17 17
18 const char kHTMLFilename[] = "local-omnibox-popup.html"; 18 const char kHTMLFilename[] = "local-omnibox-popup.html";
19 const char kJsFilename[] = "local-omnibox-popup.js"; 19 const char kJsFilename[] = "local-omnibox-popup.js";
20 const char kCSSFilename[] = "local-omnibox-popup.css"; 20 const char kCSSFilename[] = "local-omnibox-popup.css";
21 const char kIconFilename[] = "images/page_icon.png";
22 const char kIcon2xFilename[] = "images/page_icon.png";
Jered 2013/03/15 17:05:06 Should these file names be the same?
samarth 2013/03/15 21:58:27 Oops, yeah fixed.
21 23
22 } // namespace 24 } // namespace
23 25
24 LocalOmniboxPopupSource::LocalOmniboxPopupSource() { 26 LocalOmniboxPopupSource::LocalOmniboxPopupSource() {
25 } 27 }
26 28
27 LocalOmniboxPopupSource::~LocalOmniboxPopupSource() { 29 LocalOmniboxPopupSource::~LocalOmniboxPopupSource() {
28 } 30 }
29 31
30 std::string LocalOmniboxPopupSource::GetSource() { 32 std::string LocalOmniboxPopupSource::GetSource() {
31 return chrome::kChromeSearchLocalOmniboxPopupHost; 33 return chrome::kChromeSearchLocalOmniboxPopupHost;
32 } 34 }
33 35
34 void LocalOmniboxPopupSource::StartDataRequest( 36 void LocalOmniboxPopupSource::StartDataRequest(
35 const std::string& path, 37 const std::string& path,
36 bool is_incognito, 38 bool is_incognito,
37 const content::URLDataSource::GotDataCallback& callback) { 39 const content::URLDataSource::GotDataCallback& callback) {
38 int identifier = -1; 40 int identifier = -1;
39 if (path == kHTMLFilename) { 41 if (path == kHTMLFilename) {
40 identifier = IDR_LOCAL_OMNIBOX_POPUP_HTML; 42 identifier = IDR_LOCAL_OMNIBOX_POPUP_HTML;
41 } else if (path == kJsFilename) { 43 } else if (path == kJsFilename) {
42 identifier = IDR_LOCAL_OMNIBOX_POPUP_JS; 44 identifier = IDR_LOCAL_OMNIBOX_POPUP_JS;
43 } else if (path == kCSSFilename) { 45 } else if (path == kCSSFilename) {
44 identifier = IDR_LOCAL_OMNIBOX_POPUP_CSS; 46 identifier = IDR_LOCAL_OMNIBOX_POPUP_CSS;
47 } else if (path == kIconFilename) {
48 identifier = IDR_LOCAL_OMNIBOX_POPUP_IMAGES_PAGE_ICON_PNG;
49 } else if (path == kIcon2xFilename) {
50 identifier = IDR_LOCAL_OMNIBOX_POPUP_IMAGES_2X_PAGE_ICON_PNG;
45 } else { 51 } else {
46 callback.Run(NULL); 52 callback.Run(NULL);
47 return; 53 return;
48 } 54 }
49 55
50 scoped_refptr<base::RefCountedStaticMemory> response( 56 scoped_refptr<base::RefCountedStaticMemory> response(
51 content::GetContentClient()->GetDataResourceBytes(identifier)); 57 content::GetContentClient()->GetDataResourceBytes(identifier));
52 callback.Run(response); 58 callback.Run(response);
53 } 59 }
54 60
55 std::string LocalOmniboxPopupSource::GetMimeType( 61 std::string LocalOmniboxPopupSource::GetMimeType(
56 const std::string& path) const { 62 const std::string& path) const {
57 if (path == kHTMLFilename) 63 if (path == kHTMLFilename)
58 return "text/html"; 64 return "text/html";
59 if (path == kJsFilename) 65 if (path == kJsFilename)
60 return "application/javascript"; 66 return "application/javascript";
61 if (path == kCSSFilename) 67 if (path == kCSSFilename)
62 return "text/css"; 68 return "text/css";
69 if (path == kIconFilename || path == kIcon2xFilename)
70 return "image/png";
63 return ""; 71 return "";
64 } 72 }
65 73
66 bool LocalOmniboxPopupSource::ShouldServiceRequest( 74 bool LocalOmniboxPopupSource::ShouldServiceRequest(
67 const net::URLRequest* request) const { 75 const net::URLRequest* request) const {
68 DCHECK(request->url().host() == chrome::kChromeSearchLocalOmniboxPopupHost); 76 DCHECK(request->url().host() == chrome::kChromeSearchLocalOmniboxPopupHost);
69 77
70 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { 78 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) {
71 DCHECK(StartsWithASCII(request->url().path(), "/", true)); 79 DCHECK(StartsWithASCII(request->url().path(), "/", true));
72 std::string filename = request->url().path().substr(1); 80 std::string filename = request->url().path().substr(1);
73 return filename == kHTMLFilename || filename == kJsFilename || 81 return filename == kHTMLFilename || filename == kJsFilename ||
74 filename == kCSSFilename; 82 filename == kCSSFilename || filename == kIconFilename ||
83 filename == kIcon2xFilename;
75 } 84 }
76 return false; 85 return false;
77 } 86 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698