OLD | NEW |
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 #include "content/public/browser/web_contents.h" | 50 #include "content/public/browser/web_contents.h" |
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/layout.h" |
60 #include "ui/base/resource/resource_bundle.h" | 61 #include "ui/base/resource/resource_bundle.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" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 | 140 |
140 if (path == kLocalizedStringsFile) { | 141 if (path == kLocalizedStringsFile) { |
141 // Return dynamically-generated strings from memory. | 142 // Return dynamically-generated strings from memory. |
142 jstemplate_builder::UseVersion2 version; | 143 jstemplate_builder::UseVersion2 version; |
143 std::string strings_js; | 144 std::string strings_js; |
144 jstemplate_builder::AppendJsonJS(localized_strings_.get(), &strings_js); | 145 jstemplate_builder::AppendJsonJS(localized_strings_.get(), &strings_js); |
145 response_bytes = base::RefCountedString::TakeString(&strings_js); | 146 response_bytes = base::RefCountedString::TakeString(&strings_js); |
146 } else if (path == kOptionsBundleJsFile) { | 147 } else if (path == kOptionsBundleJsFile) { |
147 // Return (and cache) the options javascript code. | 148 // Return (and cache) the options javascript code. |
148 response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | 149 response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
149 IDR_OPTIONS2_BUNDLE_JS); | 150 IDR_OPTIONS2_BUNDLE_JS, ui::SCALE_FACTOR_NONE); |
150 } else { | 151 } else { |
151 // Return (and cache) the main options html page as the default. | 152 // Return (and cache) the main options html page as the default. |
152 response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( | 153 response_bytes = ResourceBundle::GetSharedInstance().LoadDataResourceBytes( |
153 IDR_OPTIONS2_HTML); | 154 IDR_OPTIONS2_HTML, ui::SCALE_FACTOR_NONE); |
154 } | 155 } |
155 | 156 |
156 SendResponse(request_id, response_bytes); | 157 SendResponse(request_id, response_bytes); |
157 } | 158 } |
158 | 159 |
159 std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const { | 160 std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const { |
160 if (path == kLocalizedStringsFile || path == kOptionsBundleJsFile) | 161 if (path == kLocalizedStringsFile || path == kOptionsBundleJsFile) |
161 return "application/javascript"; | 162 return "application/javascript"; |
162 | 163 |
163 return "text/html"; | 164 return "text/html"; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 entry->SetString("title", match.description); | 340 entry->SetString("title", match.description); |
340 entry->SetString("displayURL", match.contents); | 341 entry->SetString("displayURL", match.contents); |
341 entry->SetString("url", match.destination_url.spec()); | 342 entry->SetString("url", match.destination_url.spec()); |
342 suggestions->Append(entry); | 343 suggestions->Append(entry); |
343 } | 344 } |
344 } | 345 } |
345 | 346 |
346 // static | 347 // static |
347 base::RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { | 348 base::RefCountedMemory* OptionsUI::GetFaviconResourceBytes() { |
348 return ResourceBundle::GetSharedInstance(). | 349 return ResourceBundle::GetSharedInstance(). |
349 LoadDataResourceBytes(IDR_SETTINGS_FAVICON); | 350 LoadDataResourceBytes(IDR_SETTINGS_FAVICON, |
| 351 ui::SCALE_FACTOR_100P); |
350 } | 352 } |
351 | 353 |
352 void OptionsUI::InitializeHandlers() { | 354 void OptionsUI::InitializeHandlers() { |
353 Profile* profile = Profile::FromWebUI(web_ui()); | 355 Profile* profile = Profile::FromWebUI(web_ui()); |
354 DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession()); | 356 DCHECK(!profile->IsOffTheRecord() || Profile::IsGuestSession()); |
355 | 357 |
356 // A new web page DOM has been brought up in an existing renderer, causing | 358 // A new web page DOM has been brought up in an existing renderer, causing |
357 // this method to be called twice. If that happens, ignore the second call. | 359 // this method to be called twice. If that happens, ignore the second call. |
358 if (!initialized_handlers_) { | 360 if (!initialized_handlers_) { |
359 for (size_t i = 0; i < handlers_.size(); ++i) | 361 for (size_t i = 0; i < handlers_.size(); ++i) |
(...skipping 22 matching lines...) Expand all Loading... |
382 // Add only if handler's service is enabled. | 384 // Add only if handler's service is enabled. |
383 if (handler->IsEnabled()) { | 385 if (handler->IsEnabled()) { |
384 // Add handler to the list and also pass the ownership. | 386 // Add handler to the list and also pass the ownership. |
385 web_ui()->AddMessageHandler(handler.release()); | 387 web_ui()->AddMessageHandler(handler.release()); |
386 handler_raw->GetLocalizedValues(localized_strings); | 388 handler_raw->GetLocalizedValues(localized_strings); |
387 handlers_.push_back(handler_raw); | 389 handlers_.push_back(handler_raw); |
388 } | 390 } |
389 } | 391 } |
390 | 392 |
391 } // namespace options2 | 393 } // namespace options2 |
OLD | NEW |