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

Side by Side Diff: chrome/browser/search/local_ntp_source.cc

Issue 13905008: Merge local_omnibox_popup into local_ntp. Render the Google logo and fakebox if Google is the sear… (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 8 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/search/local_ntp_source.h" 5 #include "chrome/browser/search/local_ntp_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 "googleurl/src/gurl.h" 11 #include "googleurl/src/gurl.h"
12 #include "grit/browser_resources.h" 12 #include "grit/browser_resources.h"
13 #include "grit/theme_resources.h"
13 #include "grit/ui_resources.h" 14 #include "grit/ui_resources.h"
14 #include "net/url_request/url_request.h" 15 #include "net/url_request/url_request.h"
15 #include "ui/base/resource/resource_bundle.h" 16 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/base/theme_provider.h"
16 18
17 namespace { 19 namespace {
18 20
19 const char kHtmlFilename[] = "local-ntp.html"; 21 const char kHtmlFilename[] = "local-ntp.html";
20 const char kJSFilename[] = "local-ntp.js"; 22 const char kJSFilename[] = "local-ntp.js";
21 const char kCssFilename[] = "local-ntp.css"; 23 const char kCssFilename[] = "local-ntp.css";
22 const char kCloseBarFilename[] = "images/close_2.png"; 24 const char kCloseBarFilename[] = "images/close_2.png";
23 const char kCloseBarHoverFilename[] = "images/close_2_hover.png"; 25 const char kCloseBarHoverFilename[] = "images/close_2_hover.png";
24 const char kCloseBarActiveFilename[] = "images/close_2_active.png"; 26 const char kCloseBarActiveFilename[] = "images/close_2_active.png";
27 const char kPageIconFilename[] = "images/page_icon.png";
28 const char kPageIcon2xFilename[] = "images/2x/page_icon.png";
29 const char kSearchIconFilename[] = "images/search_icon.png";
30 const char kSearchIcon2xFilename[] = "images/2x/search_icon.png";
31 // TODO(jeremycho): Add 2x images.
32 const char kGoogleLogoFilename[] = "images/google_logo.png";
33 const char kWhiteGoogleLogoFilename[] = "images/white_google_logo.png";
25 34
26 } // namespace 35 } // namespace
27 36
28 LocalNtpSource::LocalNtpSource() { 37 LocalNtpSource::LocalNtpSource() {
29 } 38 }
30 39
31 LocalNtpSource::~LocalNtpSource() { 40 LocalNtpSource::~LocalNtpSource() {
32 } 41 }
33 42
34 std::string LocalNtpSource::GetSource() { 43 std::string LocalNtpSource::GetSource() {
(...skipping 10 matching lines...) Expand all
45 } else if (path == kJSFilename) { 54 } else if (path == kJSFilename) {
46 identifier = IDR_LOCAL_NTP_JS; 55 identifier = IDR_LOCAL_NTP_JS;
47 } else if (path == kCssFilename) { 56 } else if (path == kCssFilename) {
48 identifier = IDR_LOCAL_NTP_CSS; 57 identifier = IDR_LOCAL_NTP_CSS;
49 } else if (path == kCloseBarFilename) { 58 } else if (path == kCloseBarFilename) {
50 identifier = IDR_CLOSE_2; 59 identifier = IDR_CLOSE_2;
51 } else if (path == kCloseBarHoverFilename) { 60 } else if (path == kCloseBarHoverFilename) {
52 identifier = IDR_CLOSE_2_H; 61 identifier = IDR_CLOSE_2_H;
53 } else if (path == kCloseBarActiveFilename) { 62 } else if (path == kCloseBarActiveFilename) {
54 identifier = IDR_CLOSE_2_P; 63 identifier = IDR_CLOSE_2_P;
64 } else if (path == kPageIconFilename) {
65 identifier = IDR_LOCAL_OMNIBOX_POPUP_IMAGES_PAGE_ICON_PNG;
66 } else if (path == kPageIcon2xFilename) {
67 identifier = IDR_LOCAL_OMNIBOX_POPUP_IMAGES_2X_PAGE_ICON_PNG;
68 } else if (path == kSearchIconFilename) {
69 identifier = IDR_LOCAL_OMNIBOX_POPUP_IMAGES_SEARCH_ICON_PNG;
70 } else if (path == kSearchIcon2xFilename) {
71 identifier = IDR_LOCAL_OMNIBOX_POPUP_IMAGES_2X_SEARCH_ICON_PNG;
72 } else if (path == kGoogleLogoFilename) {
73 identifier = IDR_NEWTAB_GOOGLE_LOGO;
74 } else if (path == kWhiteGoogleLogoFilename) {
75 identifier = IDR_NEWTAB_WHITE_GOOGLE_LOGO;
55 } else { 76 } else {
56 callback.Run(NULL); 77 callback.Run(NULL);
57 return; 78 return;
58 } 79 }
59 80
60 scoped_refptr<base::RefCountedStaticMemory> response( 81 scoped_refptr<base::RefCountedStaticMemory> response(
61 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(identifier)); 82 ResourceBundle::GetSharedInstance().LoadDataResourceBytes(identifier));
62 callback.Run(response); 83 callback.Run(response);
63 } 84 }
64 85
65 std::string LocalNtpSource::GetMimeType( 86 std::string LocalNtpSource::GetMimeType(
66 const std::string& path) const { 87 const std::string& path) const {
67 if (path == kHtmlFilename) 88 if (path == kHtmlFilename)
68 return "text/html"; 89 return "text/html";
69 if (path == kJSFilename) 90 if (path == kJSFilename)
70 return "application/javascript"; 91 return "application/javascript";
71 if (path == kCssFilename) 92 if (path == kCssFilename)
72 return "text/css"; 93 return "text/css";
73 if (path == kCloseBarFilename || path == kCloseBarHoverFilename || 94 if (path == kCloseBarFilename || path == kCloseBarHoverFilename ||
74 path == kCloseBarActiveFilename) { 95 path == kCloseBarActiveFilename || path == kPageIconFilename ||
96 path == kPageIcon2xFilename || path == kSearchIconFilename ||
97 path == kSearchIcon2xFilename || path == kGoogleLogoFilename ||
98 path == kWhiteGoogleLogoFilename) {
75 return "image/png"; 99 return "image/png";
76 } 100 }
77 return std::string(); 101 return std::string();
78 } 102 }
79 103
80 bool LocalNtpSource::ShouldServiceRequest( 104 bool LocalNtpSource::ShouldServiceRequest(
81 const net::URLRequest* request) const { 105 const net::URLRequest* request) const {
82 DCHECK(request->url().host() == chrome::kChromeSearchLocalNtpHost); 106 DCHECK(request->url().host() == chrome::kChromeSearchLocalNtpHost);
83 107
84 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) { 108 if (request->url().SchemeIs(chrome::kChromeSearchScheme)) {
85 DCHECK(StartsWithASCII(request->url().path(), "/", true)); 109 DCHECK(StartsWithASCII(request->url().path(), "/", true));
86 std::string filename = request->url().path().substr(1); 110 std::string filename = request->url().path().substr(1);
87 return filename == kHtmlFilename || filename == kJSFilename || 111 return filename == kHtmlFilename || filename == kJSFilename ||
88 filename == kCssFilename || filename == kCloseBarFilename || 112 filename == kCssFilename || filename == kCloseBarFilename ||
89 filename == kCloseBarHoverFilename || 113 filename == kCloseBarHoverFilename ||
90 filename == kCloseBarActiveFilename; 114 filename == kCloseBarActiveFilename ||
115 filename == kPageIconFilename || filename == kPageIcon2xFilename ||
116 filename == kSearchIconFilename ||
117 filename == kSearchIcon2xFilename ||
118 filename == kGoogleLogoFilename ||
119 filename == kWhiteGoogleLogoFilename;
samarth 2013/04/15 19:01:34 This was fine when we had a couple of files but it
jeremycho 2013/04/16 01:42:37 Done.
91 } 120 }
92 return false; 121 return false;
93 } 122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698