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

Side by Side Diff: chrome/browser/notifications/desktop_notification_service.cc

Issue 10387010: Select theme resources from ResourceBundle at requested scale factor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Convert ptr to bool for win compile. Created 8 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/notifications/desktop_notification_service.h" 5 #include "chrome/browser/notifications/desktop_notification_service.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "base/threading/thread.h" 8 #include "base/threading/thread.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 23 matching lines...) Expand all
34 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
35 #include "content/public/common/show_desktop_notification_params.h" 35 #include "content/public/common/show_desktop_notification_params.h"
36 #include "grit/browser_resources.h" 36 #include "grit/browser_resources.h"
37 #include "grit/chromium_strings.h" 37 #include "grit/chromium_strings.h"
38 #include "grit/generated_resources.h" 38 #include "grit/generated_resources.h"
39 #include "grit/theme_resources_standard.h" 39 #include "grit/theme_resources_standard.h"
40 #include "net/base/escape.h" 40 #include "net/base/escape.h"
41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" 41 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h"
42 #include "ui/base/l10n/l10n_util.h" 42 #include "ui/base/l10n/l10n_util.h"
43 #include "ui/base/resource/resource_bundle.h" 43 #include "ui/base/resource/resource_bundle.h"
44 #include "ui/base/resource/resource_handle.h"
44 45
45 using content::BrowserThread; 46 using content::BrowserThread;
46 using content::RenderViewHost; 47 using content::RenderViewHost;
47 using content::WebContents; 48 using content::WebContents;
48 using WebKit::WebNotificationPresenter; 49 using WebKit::WebNotificationPresenter;
49 using WebKit::WebTextDirection; 50 using WebKit::WebTextDirection;
50 using WebKit::WebSecurityOrigin; 51 using WebKit::WebSecurityOrigin;
51 52
52 const ContentSetting kDefaultSetting = CONTENT_SETTING_ASK; 53 const ContentSetting kDefaultSetting = CONTENT_SETTING_ASK;
53 54
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 "rtl" : "ltr"); 198 "rtl" : "ltr");
198 199
199 return CreateDataUrl(resource, subst); 200 return CreateDataUrl(resource, subst);
200 } 201 }
201 202
202 // static 203 // static
203 string16 DesktopNotificationService::CreateDataUrl( 204 string16 DesktopNotificationService::CreateDataUrl(
204 int resource, const std::vector<std::string>& subst) { 205 int resource, const std::vector<std::string>& subst) {
205 const base::StringPiece template_html( 206 const base::StringPiece template_html(
206 ResourceBundle::GetSharedInstance().GetRawDataResource( 207 ResourceBundle::GetSharedInstance().GetRawDataResource(
207 resource)); 208 resource, ui::ResourceHandle::kScaleFactorNone));
208 209
209 if (template_html.empty()) { 210 if (template_html.empty()) {
210 NOTREACHED() << "unable to load template. ID: " << resource; 211 NOTREACHED() << "unable to load template. ID: " << resource;
211 return string16(); 212 return string16();
212 } 213 }
213 214
214 std::string data = ReplaceStringPlaceholders(template_html, subst, NULL); 215 std::string data = ReplaceStringPlaceholders(template_html, subst, NULL);
215 return UTF8ToUTF16("data:text/html;charset=utf-8," + 216 return UTF8ToUTF16("data:text/html;charset=utf-8," +
216 net::EscapeQueryParamValue(data, false)); 217 net::EscapeQueryParamValue(data, false));
217 } 218 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 449
449 if (setting == CONTENT_SETTING_ALLOW) 450 if (setting == CONTENT_SETTING_ALLOW)
450 return WebKit::WebNotificationPresenter::PermissionAllowed; 451 return WebKit::WebNotificationPresenter::PermissionAllowed;
451 if (setting == CONTENT_SETTING_BLOCK) 452 if (setting == CONTENT_SETTING_BLOCK)
452 return WebKit::WebNotificationPresenter::PermissionDenied; 453 return WebKit::WebNotificationPresenter::PermissionDenied;
453 if (setting == CONTENT_SETTING_ASK) 454 if (setting == CONTENT_SETTING_ASK)
454 return WebKit::WebNotificationPresenter::PermissionNotAllowed; 455 return WebKit::WebNotificationPresenter::PermissionNotAllowed;
455 NOTREACHED() << "Invalid notifications settings value: " << setting; 456 NOTREACHED() << "Invalid notifications settings value: " << setting;
456 return WebKit::WebNotificationPresenter::PermissionNotAllowed; 457 return WebKit::WebNotificationPresenter::PermissionNotAllowed;
457 } 458 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698