Chromium Code Reviews| 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_ui.h" | 5 #include "chrome/browser/ui/webui/options/options_ui.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" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/memory/ref_counted_memory.h" | 12 #include "base/memory/ref_counted_memory.h" |
| 13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "base/string_piece.h" | 15 #include "base/string_piece.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/threading/thread.h" | 17 #include "base/threading/thread.h" |
| 18 #include "base/time.h" | 18 #include "base/time.h" |
| 19 #include "base/values.h" | 19 #include "base/values.h" |
| 20 #include "chrome/browser/autocomplete/autocomplete_match.h" | 20 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 21 #include "chrome/browser/autocomplete/autocomplete_result.h" | 21 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 22 #include "chrome/browser/browser_about_handler.h" | 22 #include "chrome/browser/browser_about_handler.h" |
| 23 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 25 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 25 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 26 #include "chrome/browser/ui/webui/options2/autofill_options_handler.h" | 26 #include "chrome/browser/ui/webui/options/autofill_options_handler.h" |
| 27 #include "chrome/browser/ui/webui/options2/browser_options_handler.h" | 27 #include "chrome/browser/ui/webui/options/browser_options_handler.h" |
| 28 #include "chrome/browser/ui/webui/options2/clear_browser_data_handler.h" | 28 #include "chrome/browser/ui/webui/options/clear_browser_data_handler.h" |
| 29 #include "chrome/browser/ui/webui/options2/content_settings_handler.h" | 29 #include "chrome/browser/ui/webui/options/content_settings_handler.h" |
| 30 #include "chrome/browser/ui/webui/options2/cookies_view_handler.h" | 30 #include "chrome/browser/ui/webui/options/cookies_view_handler.h" |
| 31 #include "chrome/browser/ui/webui/options2/core_options_handler.h" | 31 #include "chrome/browser/ui/webui/options/core_options_handler.h" |
| 32 #include "chrome/browser/ui/webui/options2/font_settings_handler.h" | 32 #include "chrome/browser/ui/webui/options/font_settings_handler.h" |
| 33 #include "chrome/browser/ui/webui/options2/handler_options_handler.h" | 33 #include "chrome/browser/ui/webui/options/handler_options_handler.h" |
| 34 #include "chrome/browser/ui/webui/options2/home_page_overlay_handler.h" | 34 #include "chrome/browser/ui/webui/options/home_page_overlay_handler.h" |
| 35 #include "chrome/browser/ui/webui/options2/import_data_handler.h" | 35 #include "chrome/browser/ui/webui/options/import_data_handler.h" |
| 36 #include "chrome/browser/ui/webui/options2/language_options_handler.h" | 36 #include "chrome/browser/ui/webui/options/language_options_handler.h" |
| 37 #include "chrome/browser/ui/webui/options2/manage_profile_handler.h" | 37 #include "chrome/browser/ui/webui/options/manage_profile_handler.h" |
| 38 #include "chrome/browser/ui/webui/options2/media_galleries_handler.h" | 38 #include "chrome/browser/ui/webui/options/media_galleries_handler.h" |
| 39 #include "chrome/browser/ui/webui/options2/options_sync_setup_handler.h" | 39 #include "chrome/browser/ui/webui/options/options_sync_setup_handler.h" |
| 40 #include "chrome/browser/ui/webui/options2/password_manager_handler.h" | 40 #include "chrome/browser/ui/webui/options/password_manager_handler.h" |
| 41 #include "chrome/browser/ui/webui/options2/search_engine_manager_handler.h" | 41 #include "chrome/browser/ui/webui/options/search_engine_manager_handler.h" |
| 42 #include "chrome/browser/ui/webui/options2/startup_pages_handler.h" | 42 #include "chrome/browser/ui/webui/options/startup_pages_handler.h" |
| 43 #include "chrome/browser/ui/webui/options2/web_intents_settings_handler.h" | 43 #include "chrome/browser/ui/webui/options/web_intents_settings_handler.h" |
| 44 #include "chrome/browser/ui/webui/theme_source.h" | 44 #include "chrome/browser/ui/webui/theme_source.h" |
| 45 #include "chrome/common/jstemplate_builder.h" | 45 #include "chrome/common/jstemplate_builder.h" |
| 46 #include "chrome/common/time_format.h" | 46 #include "chrome/common/time_format.h" |
| 47 #include "chrome/common/url_constants.h" | 47 #include "chrome/common/url_constants.h" |
| 48 #include "content/public/browser/browser_thread.h" | 48 #include "content/public/browser/browser_thread.h" |
| 49 #include "content/public/browser/notification_types.h" | 49 #include "content/public/browser/notification_types.h" |
| 50 #include "content/public/browser/render_view_host.h" | 50 #include "content/public/browser/render_view_host.h" |
| 51 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
| 52 #include "content/public/browser/web_contents_delegate.h" | 52 #include "content/public/browser/web_contents_delegate.h" |
| 53 #include "content/public/browser/web_ui.h" | 53 #include "content/public/browser/web_ui.h" |
| 54 #include "grit/chromium_strings.h" | 54 #include "grit/chromium_strings.h" |
| 55 #include "grit/generated_resources.h" | 55 #include "grit/generated_resources.h" |
| 56 #include "grit/locale_settings.h" | 56 #include "grit/locale_settings.h" |
| 57 #include "grit/options2_resources.h" | 57 #include "grit/options_resources.h" |
| 58 #include "grit/theme_resources.h" | 58 #include "grit/theme_resources.h" |
| 59 #include "net/base/escape.h" | 59 #include "net/base/escape.h" |
| 60 #include "ui/base/layout.h" | 60 #include "ui/base/layout.h" |
| 61 #include "ui/base/resource/resource_bundle.h" | 61 #include "ui/base/resource/resource_bundle.h" |
| 62 | 62 |
| 63 #if defined(OS_CHROMEOS) | 63 #if defined(OS_CHROMEOS) |
| 64 #include "chrome/browser/chromeos/system/pointer_device_observer.h" | 64 #include "chrome/browser/chromeos/system/pointer_device_observer.h" |
| 65 #include "chrome/browser/ui/webui/options2/chromeos/accounts_options_handler.h" | 65 #include "chrome/browser/ui/webui/options/chromeos/accounts_options_handler.h" |
| 66 #include "chrome/browser/ui/webui/options2/chromeos/bluetooth_options_handler.h" | 66 #include "chrome/browser/ui/webui/options/chromeos/bluetooth_options_handler.h" |
| 67 #include "chrome/browser/ui/webui/options2/chromeos/change_picture_options_handl er.h" | 67 #include "chrome/browser/ui/webui/options/chromeos/change_picture_options_handle r.h" |
| 68 #include "chrome/browser/ui/webui/options2/chromeos/core_chromeos_options_handle r.h" | 68 #include "chrome/browser/ui/webui/options/chromeos/core_chromeos_options_handler .h" |
| 69 #include "chrome/browser/ui/webui/options2/chromeos/cros_language_options_handle r.h" | 69 #include "chrome/browser/ui/webui/options/chromeos/cros_language_options_handler .h" |
| 70 #include "chrome/browser/ui/webui/options2/chromeos/display_options_handler.h" | 70 #include "chrome/browser/ui/webui/options/chromeos/display_options_handler.h" |
| 71 #include "chrome/browser/ui/webui/options2/chromeos/internet_options_handler.h" | 71 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler.h" |
| 72 #include "chrome/browser/ui/webui/options2/chromeos/keyboard_handler.h" | 72 #include "chrome/browser/ui/webui/options/chromeos/keyboard_handler.h" |
| 73 #include "chrome/browser/ui/webui/options2/chromeos/language_chewing_handler.h" | 73 #include "chrome/browser/ui/webui/options/chromeos/language_chewing_handler.h" |
| 74 #include "chrome/browser/ui/webui/options2/chromeos/language_hangul_handler.h" | 74 #include "chrome/browser/ui/webui/options/chromeos/language_hangul_handler.h" |
| 75 #include "chrome/browser/ui/webui/options2/chromeos/language_mozc_handler.h" | 75 #include "chrome/browser/ui/webui/options/chromeos/language_mozc_handler.h" |
| 76 #include "chrome/browser/ui/webui/options2/chromeos/language_pinyin_handler.h" | 76 #include "chrome/browser/ui/webui/options/chromeos/language_pinyin_handler.h" |
| 77 #include "chrome/browser/ui/webui/options2/chromeos/pointer_handler.h" | 77 #include "chrome/browser/ui/webui/options/chromeos/pointer_handler.h" |
| 78 #include "chrome/browser/ui/webui/options2/chromeos/proxy_handler.h" | 78 #include "chrome/browser/ui/webui/options/chromeos/proxy_handler.h" |
| 79 #include "chrome/browser/ui/webui/options2/chromeos/stats_options_handler.h" | 79 #include "chrome/browser/ui/webui/options/chromeos/stats_options_handler.h" |
| 80 #include "chrome/browser/ui/webui/options2/chromeos/user_image_source.h" | 80 #include "chrome/browser/ui/webui/options/chromeos/user_image_source.h" |
| 81 #include "chrome/browser/ui/webui/options2/chromeos/wallpaper_thumbnail_source.h " | 81 #include "chrome/browser/ui/webui/options/chromeos/wallpaper_thumbnail_source.h" |
| 82 #endif | 82 #endif |
| 83 | 83 |
| 84 #if defined(OS_CHROMEOS) && defined(USE_ASH) | 84 #if defined(OS_CHROMEOS) && defined(USE_ASH) |
| 85 #include "chrome/browser/ui/webui/options2/chromeos/set_wallpaper_options_handle r.h" | 85 #include "chrome/browser/ui/webui/options/chromeos/set_wallpaper_options_handler .h" |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 #if defined(USE_NSS) | 88 #if defined(USE_NSS) |
| 89 #include "chrome/browser/ui/webui/options2/certificate_manager_handler.h" | 89 #include "chrome/browser/ui/webui/options/certificate_manager_handler.h" |
| 90 #endif | 90 #endif |
| 91 | 91 |
| 92 using content::RenderViewHost; | 92 using content::RenderViewHost; |
| 93 | 93 |
| 94 namespace { | 94 namespace { |
| 95 | 95 |
| 96 const char kLocalizedStringsFile[] = "strings.js"; | 96 const char kLocalizedStringsFile[] = "strings.js"; |
| 97 const char kOptionsBundleJsFile[] = "options_bundle.js"; | 97 const char kOptionsBundleJsFile[] = "options_bundle.js"; |
| 98 | 98 |
| 99 } // namespace | 99 } // namespace |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 | 141 |
| 142 if (path == kLocalizedStringsFile) { | 142 if (path == kLocalizedStringsFile) { |
| 143 // Return dynamically-generated strings from memory. | 143 // Return dynamically-generated strings from memory. |
| 144 jstemplate_builder::UseVersion2 version; | 144 jstemplate_builder::UseVersion2 version; |
| 145 std::string strings_js; | 145 std::string strings_js; |
| 146 jstemplate_builder::AppendJsonJS(localized_strings_.get(), &strings_js); | 146 jstemplate_builder::AppendJsonJS(localized_strings_.get(), &strings_js); |
| 147 response_bytes = base::RefCountedString::TakeString(&strings_js); | 147 response_bytes = base::RefCountedString::TakeString(&strings_js); |
| 148 } else if (path == kOptionsBundleJsFile) { | 148 } else if (path == kOptionsBundleJsFile) { |
| 149 // Return (and cache) the options javascript code. | 149 // Return (and cache) the options javascript code. |
| 150 response_bytes = ui::ResourceBundle::GetSharedInstance(). | 150 response_bytes = ui::ResourceBundle::GetSharedInstance(). |
| 151 LoadDataResourceBytes(IDR_OPTIONS2_BUNDLE_JS, ui::SCALE_FACTOR_NONE); | 151 LoadDataResourceBytes(IDR_OPTIONS_BUNDLE_JS, ui::SCALE_FACTOR_NONE); |
| 152 } else { | 152 } else { |
| 153 // Return (and cache) the main options html page as the default. | 153 // Return (and cache) the main options html page as the default. |
| 154 response_bytes = ui::ResourceBundle::GetSharedInstance(). | 154 response_bytes = ui::ResourceBundle::GetSharedInstance(). |
| 155 LoadDataResourceBytes(IDR_OPTIONS2_HTML, ui::SCALE_FACTOR_NONE); | 155 LoadDataResourceBytes(IDR_OPTIONS_HTML, ui::SCALE_FACTOR_NONE); |
|
csilv
2012/08/18 20:07:38
I will assume that because of these changes and li
| |
| 156 } | 156 } |
| 157 | 157 |
| 158 SendResponse(request_id, response_bytes); | 158 SendResponse(request_id, response_bytes); |
| 159 } | 159 } |
| 160 | 160 |
| 161 std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const { | 161 std::string OptionsUIHTMLSource::GetMimeType(const std::string& path) const { |
| 162 if (path == kLocalizedStringsFile || path == kOptionsBundleJsFile) | 162 if (path == kLocalizedStringsFile || path == kOptionsBundleJsFile) |
| 163 return "application/javascript"; | 163 return "application/javascript"; |
| 164 | 164 |
| 165 return "text/html"; | 165 return "text/html"; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 387 // Add only if handler's service is enabled. | 387 // Add only if handler's service is enabled. |
| 388 if (handler->IsEnabled()) { | 388 if (handler->IsEnabled()) { |
| 389 // Add handler to the list and also pass the ownership. | 389 // Add handler to the list and also pass the ownership. |
| 390 web_ui()->AddMessageHandler(handler.release()); | 390 web_ui()->AddMessageHandler(handler.release()); |
| 391 handler_raw->GetLocalizedValues(localized_strings); | 391 handler_raw->GetLocalizedValues(localized_strings); |
| 392 handlers_.push_back(handler_raw); | 392 handlers_.push_back(handler_raw); |
| 393 } | 393 } |
| 394 } | 394 } |
| 395 | 395 |
| 396 } // namespace options | 396 } // namespace options |
| OLD | NEW |