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

Side by Side Diff: chrome/browser/ui/webui/options2/options_ui2.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/ui/webui/options2/options_ui2.h" 5 #include "chrome/browser/ui/webui/options2/options_ui2.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 #include "content/public/browser/web_contents_delegate.h" 51 #include "content/public/browser/web_contents_delegate.h"
52 #include "content/public/browser/web_ui.h" 52 #include "content/public/browser/web_ui.h"
53 #include "grit/chromium_strings.h" 53 #include "grit/chromium_strings.h"
54 #include "grit/generated_resources.h" 54 #include "grit/generated_resources.h"
55 #include "grit/locale_settings.h" 55 #include "grit/locale_settings.h"
56 #include "grit/options2_resources.h" 56 #include "grit/options2_resources.h"
57 #include "grit/theme_resources.h" 57 #include "grit/theme_resources.h"
58 #include "grit/theme_resources_standard.h" 58 #include "grit/theme_resources_standard.h"
59 #include "net/base/escape.h" 59 #include "net/base/escape.h"
60 #include "ui/base/resource/resource_bundle.h" 60 #include "ui/base/resource/resource_bundle.h"
61 #include "ui/base/resource/resource_handle.h"
61 62
62 #if defined(OS_CHROMEOS) 63 #if defined(OS_CHROMEOS)
63 #include "chrome/browser/chromeos/system/pointer_device_observer.h" 64 #include "chrome/browser/chromeos/system/pointer_device_observer.h"
64 #include "chrome/browser/ui/webui/options2/chromeos/accounts_options_handler2.h" 65 #include "chrome/browser/ui/webui/options2/chromeos/accounts_options_handler2.h"
65 #include "chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.h " 66 #include "chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler2.h "
66 #include "chrome/browser/ui/webui/options2/chromeos/change_picture_options_handl er2.h" 67 #include "chrome/browser/ui/webui/options2/chromeos/change_picture_options_handl er2.h"
67 #include "chrome/browser/ui/webui/options2/chromeos/core_chromeos_options_handle r2.h" 68 #include "chrome/browser/ui/webui/options2/chromeos/core_chromeos_options_handle r2.h"
68 #include "chrome/browser/ui/webui/options2/chromeos/cros_language_options_handle r2.h" 69 #include "chrome/browser/ui/webui/options2/chromeos/cros_language_options_handle r2.h"
69 #include "chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.h" 70 #include "chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.h"
70 #include "chrome/browser/ui/webui/options2/chromeos/keyboard_handler2.h" 71 #include "chrome/browser/ui/webui/options2/chromeos/keyboard_handler2.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 SetFontAndTextDirection(localized_strings_.get()); 142 SetFontAndTextDirection(localized_strings_.get());
142 143
143 if (path == kLocalizedStringsFile) { 144 if (path == kLocalizedStringsFile) {
144 // Return dynamically-generated strings from memory. 145 // Return dynamically-generated strings from memory.
145 std::string strings_js; 146 std::string strings_js;
146 jstemplate_builder::AppendJsonJS(localized_strings_.get(), &strings_js); 147 jstemplate_builder::AppendJsonJS(localized_strings_.get(), &strings_js);
147 response_bytes = base::RefCountedString::TakeString(&strings_js); 148 response_bytes = base::RefCountedString::TakeString(&strings_js);
148 } else if (path == kOptionsBundleJsFile) { 149 } else if (path == kOptionsBundleJsFile) {
149 // Return (and cache) the options javascript code. 150 // Return (and cache) the options javascript code.
150 response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 151 response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
151 IDR_OPTIONS2_BUNDLE_JS); 152 IDR_OPTIONS2_BUNDLE_JS, ui::ResourceHandle::kScaleFactorNone);
152 } else { 153 } else {
153 // Return (and cache) the main options html page as the default. 154 // Return (and cache) the main options html page as the default.
154 response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( 155 response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes(
155 IDR_OPTIONS2_HTML); 156 IDR_OPTIONS2_HTML, ui::ResourceHandle::kScaleFactorNone);
156 } 157 }
157 158
158 SendResponse(request_id, response_bytes); 159 SendResponse(request_id, response_bytes);
159 } 160 }
160 161
161 std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const { 162 std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const {
162 if (path == kLocalizedStringsFile || path == kOptionsBundleJsFile) 163 if (path == kLocalizedStringsFile || path == kOptionsBundleJsFile)
163 return "application/javascript"; 164 return "application/javascript";
164 165
165 return "text/html"; 166 return "text/html";
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 entry->SetString("title", match.description); 348 entry->SetString("title", match.description);
348 entry->SetString("displayURL", match.contents); 349 entry->SetString("displayURL", match.contents);
349 entry->SetString("url", match.destination_url.spec()); 350 entry->SetString("url", match.destination_url.spec());
350 suggestions->Append(entry); 351 suggestions->Append(entry);
351 } 352 }
352 } 353 }
353 354
354 // static 355 // static
355 base::RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { 356 base::RefCountedMemory* OptionsUI::GetFaviconResourceBytes() {
356 return ResourceBundle::GetSharedInstance(). 357 return ResourceBundle::GetSharedInstance().
357 LoadDataResourceBytes(IDR_SETTINGS_FAVICON); 358 LoadDataResourceBytes(IDR_SETTINGS_FAVICON,
359 ui::ResourceHandle::kScaleFactor100x);
358 } 360 }
359 361
360 void OptionsUI::InitializeHandlers() { 362 void OptionsUI::InitializeHandlers() {
361 Profile* profile = Profile::FromWebUI(web_ui()); 363 Profile* profile = Profile::FromWebUI(web_ui());
362 DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession()); 364 DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession());
363 365
364 // A new web page DOM has been brought up in an existing renderer, causing 366 // A new web page DOM has been brought up in an existing renderer, causing
365 // this method to be called twice. If that happens, ignore the second call. 367 // this method to be called twice. If that happens, ignore the second call.
366 if (!initialized_handlers_) { 368 if (!initialized_handlers_) {
367 for (size_t i = 0; i < handlers_.size(); ++i) 369 for (size_t i = 0; i < handlers_.size(); ++i)
(...skipping 22 matching lines...) Expand all
390 // Add only if handler's service is enabled. 392 // Add only if handler's service is enabled.
391 if (handler->IsEnabled()) { 393 if (handler->IsEnabled()) {
392 // Add handler to the list and also pass the ownership. 394 // Add handler to the list and also pass the ownership.
393 web_ui()->AddMessageHandler(handler.release()); 395 web_ui()->AddMessageHandler(handler.release());
394 handler_raw->GetLocalizedValues(localized_strings); 396 handler_raw->GetLocalizedValues(localized_strings);
395 handlers_.push_back(handler_raw); 397 handlers_.push_back(handler_raw);
396 } 398 }
397 } 399 }
398 400
399 } // namespace options2 401 } // namespace options2
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698