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

Side by Side Diff: chrome/browser/search/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: Revert no-op CSS change. 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
« no previous file with comments | « chrome/browser/resources/local_omnibox_popup/local_omnibox_popup.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/search/local_omnibox_popup_source.h" 5 #include "chrome/browser/search/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 kPageIconFilename[] = "images/page_icon.png";
22 const char kPageIcon2xFilename[] = "images/2x/page_icon.png";
23 const char kSearchIconFilename[] = "images/search_icon.png";
24 const char kSearchIcon2xFilename[] = "images/2x/search_icon.png";
21 25
22 } // namespace 26 } // namespace
23 27
24 LocalOmniboxPopupSource::LocalOmniboxPopupSource() { 28 LocalOmniboxPopupSource::LocalOmniboxPopupSource() {
25 } 29 }
26 30
27 LocalOmniboxPopupSource::~LocalOmniboxPopupSource() { 31 LocalOmniboxPopupSource::~LocalOmniboxPopupSource() {
28 } 32 }
29 33
30 std::string LocalOmniboxPopupSource::GetSource() { 34 std::string LocalOmniboxPopupSource::GetSource() {
31 return chrome::kChromeSearchLocalOmniboxPopupHost; 35 return chrome::kChromeSearchLocalOmniboxPopupHost;
32 } 36 }
33 37
34 void LocalOmniboxPopupSource::StartDataRequest( 38 void LocalOmniboxPopupSource::StartDataRequest(
35 const std::string& path, 39 const std::string& path,
36 bool is_incognito, 40 bool is_incognito,
37 const content::URLDataSource::GotDataCallback& callback) { 41 const content::URLDataSource::GotDataCallback& callback) {
38 int identifier = -1; 42 int identifier = -1;
39 if (path == kHTMLFilename) { 43 if (path == kHTMLFilename) {
40 identifier = IDR_LOCAL_OMNIBOX_POPUP_HTML; 44 identifier = IDR_LOCAL_OMNIBOX_POPUP_HTML;
41 } else if (path == kJsFilename) { 45 } else if (path == kJsFilename) {
42 identifier = IDR_LOCAL_OMNIBOX_POPUP_JS; 46 identifier = IDR_LOCAL_OMNIBOX_POPUP_JS;
43 } else if (path == kCSSFilename) { 47 } else if (path == kCSSFilename) {
44 identifier = IDR_LOCAL_OMNIBOX_POPUP_CSS; 48 identifier = IDR_LOCAL_OMNIBOX_POPUP_CSS;
49 } else if (path == kPageIconFilename) {
50 identifier = IDR_LOCAL_OMNIBOX_POPUP_IMAGES_PAGE_ICON_PNG;
51 } else if (path == kPageIcon2xFilename) {
52 identifier = IDR_LOCAL_OMNIBOX_POPUP_IMAGES_2X_PAGE_ICON_PNG;
53 } else if (path == kSearchIconFilename) {
54 identifier = IDR_LOCAL_OMNIBOX_POPUP_IMAGES_SEARCH_ICON_PNG;
55 } else if (path == kSearchIcon2xFilename) {
56 identifier = IDR_LOCAL_OMNIBOX_POPUP_IMAGES_2X_SEARCH_ICON_PNG;
45 } else { 57 } else {
46 callback.Run(NULL); 58 callback.Run(NULL);
47 return; 59 return;
48 } 60 }
49 61
50 scoped_refptr<base::RefCountedStaticMemory> response( 62 scoped_refptr<base::RefCountedStaticMemory> response(
51 content::GetContentClient()->GetDataResourceBytes(identifier)); 63 content::GetContentClient()->GetDataResourceBytes(identifier));
52 callback.Run(response); 64 callback.Run(response);
53 } 65 }
54 66
55 std::string LocalOmniboxPopupSource::GetMimeType( 67 std::string LocalOmniboxPopupSource::GetMimeType(
56 const std::string& path) const { 68 const std::string& path) const {
57 if (path == kHTMLFilename) 69 if (path == kHTMLFilename)
58 return "text/html"; 70 return "text/html";
59 if (path == kJsFilename) 71 if (path == kJsFilename)
60 return "application/javascript"; 72 return "application/javascript";
61 if (path == kCSSFilename) 73 if (path == kCSSFilename)
62 return "text/css"; 74 return "text/css";
75 if (path == kPageIconFilename || path == kPageIcon2xFilename ||
76 path == kSearchIconFilename || path == kSearchIcon2xFilename)
77 return "image/png";
63 return ""; 78 return "";
64 } 79 }
65 80
66 bool LocalOmniboxPopupSource::ShouldServiceRequest( 81 bool LocalOmniboxPopupSource::ShouldServiceRequest(
67 const net::URLRequest* request) const { 82 const net::URLRequest* request) const {
68 DCHECK(request->url().host() == chrome::kChromeSearchLocalOmniboxPopupHost); 83 DCHECK(request->url().host() == chrome::kChromeSearchLocalOmniboxPopupHost);
69 84
70 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { 85 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) {
71 DCHECK(StartsWithASCII(request->url().path(), "/", true)); 86 DCHECK(StartsWithASCII(request->url().path(), "/", true));
72 std::string filename = request->url().path().substr(1); 87 std::string filename = request->url().path().substr(1);
73 return filename == kHTMLFilename || filename == kJsFilename || 88 return filename == kHTMLFilename || filename == kJsFilename ||
74 filename == kCSSFilename; 89 filename == kCSSFilename || filename == kPageIconFilename ||
90 filename == kPageIcon2xFilename || filename == kSearchIconFilename ||
91 filename == kSearchIcon2xFilename;
75 } 92 }
76 return false; 93 return false;
77 } 94 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/local_omnibox_popup/local_omnibox_popup.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698