From 3655b9bfb050f54676e122f7263d68071f86dcb3 Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Wed, 30 Mar 2011 16:13:14 +0000 Subject: Move web_ui_util.* to chrome/ from content/ this is not even a refactor, just a move. All references to this file are in chrome/ BUG=77092 TEST=compile Review URL: http://codereview.chromium.org/6698073 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79838 0039d316-1c4b-4281-b951-d872f2087c98 --- .../chromeos/notifications/system_notification.cc | 2 +- .../printing/cloud_print/cloud_print_setup_flow.cc | 1 - chrome/browser/remoting/setup_flow_login_step.cc | 1 - chrome/browser/sync/sync_setup_flow.cc | 1 - chrome/browser/ui/webui/constrained_html_ui.cc | 1 - chrome/browser/ui/webui/html_dialog_ui.cc | 1 - chrome/browser/ui/webui/ntp_login_handler.cc | 1 - .../ui/webui/options/autofill_options_handler.cc | 2 +- .../options/chromeos/accounts_options_handler.cc | 1 - .../options/chromeos/internet_options_handler.cc | 2 +- .../ui/webui/options/personal_options_handler.cc | 1 - chrome/browser/ui/webui/web_ui_util.cc | 42 ++++++++++++++++++++++ chrome/browser/ui/webui/web_ui_util.h | 29 +++++++++++++++ chrome/chrome_browser.gypi | 2 ++ content/browser/webui/web_ui_util.cc | 42 ---------------------- content/browser/webui/web_ui_util.h | 29 --------------- content/content_browser.gypi | 2 -- 17 files changed, 76 insertions(+), 84 deletions(-) create mode 100644 chrome/browser/ui/webui/web_ui_util.cc create mode 100644 chrome/browser/ui/webui/web_ui_util.h delete mode 100644 content/browser/webui/web_ui_util.cc delete mode 100644 content/browser/webui/web_ui_util.h diff --git a/chrome/browser/chromeos/notifications/system_notification.cc b/chrome/browser/chromeos/notifications/system_notification.cc index 2e5ab14..fa7427d 100644 --- a/chrome/browser/chromeos/notifications/system_notification.cc +++ b/chrome/browser/chromeos/notifications/system_notification.cc @@ -9,7 +9,7 @@ #include "chrome/browser/chromeos/notifications/system_notification_factory.h" #include "chrome/browser/notifications/notification.h" #include "chrome/browser/notifications/notification_ui_manager.h" -#include "content/browser/webui/web_ui_util.h" +#include "chrome/browser/ui/webui/web_ui_util.h" namespace chromeos { diff --git a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc index 1dd7c06..536c436 100644 --- a/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc +++ b/chrome/browser/printing/cloud_print/cloud_print_setup_flow.cc @@ -31,7 +31,6 @@ #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" -#include "content/browser/webui/web_ui_util.h" #include "grit/chromium_strings.h" #include "grit/locale_settings.h" #include "ui/base/l10n/l10n_font_util.h" diff --git a/chrome/browser/remoting/setup_flow_login_step.cc b/chrome/browser/remoting/setup_flow_login_step.cc index 7c786b7..d69afe2 100644 --- a/chrome/browser/remoting/setup_flow_login_step.cc +++ b/chrome/browser/remoting/setup_flow_login_step.cc @@ -13,7 +13,6 @@ #include "chrome/browser/remoting/setup_flow_get_status_step.h" #include "chrome/common/net/gaia/gaia_constants.h" #include "chrome/common/net/gaia/google_service_auth_error.h" -#include "content/browser/webui/web_ui_util.h" namespace remoting { diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc index 5d20ee7..6bfbe6f 100644 --- a/chrome/browser/sync/sync_setup_flow.cc +++ b/chrome/browser/sync/sync_setup_flow.cc @@ -22,7 +22,6 @@ #include "chrome/common/pref_names.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" -#include "content/browser/webui/web_ui_util.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" #include "ui/base/l10n/l10n_font_util.h" diff --git a/chrome/browser/ui/webui/constrained_html_ui.cc b/chrome/browser/ui/webui/constrained_html_ui.cc index 81740d7..2bae21f 100644 --- a/chrome/browser/ui/webui/constrained_html_ui.cc +++ b/chrome/browser/ui/webui/constrained_html_ui.cc @@ -10,7 +10,6 @@ #include "chrome/common/bindings_policy.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" -#include "content/browser/webui/web_ui_util.h" static base::LazyInstance > g_constrained_html_ui_property_accessor(base::LINKER_INITIALIZED); diff --git a/chrome/browser/ui/webui/html_dialog_ui.cc b/chrome/browser/ui/webui/html_dialog_ui.cc index 7194663..80872aa 100644 --- a/chrome/browser/ui/webui/html_dialog_ui.cc +++ b/chrome/browser/ui/webui/html_dialog_ui.cc @@ -10,7 +10,6 @@ #include "chrome/common/bindings_policy.h" #include "content/browser/renderer_host/render_view_host.h" #include "content/browser/tab_contents/tab_contents.h" -#include "content/browser/webui/web_ui_util.h" static base::LazyInstance > g_html_dialog_ui_property_accessor(base::LINKER_INITIALIZED); diff --git a/chrome/browser/ui/webui/ntp_login_handler.cc b/chrome/browser/ui/webui/ntp_login_handler.cc index 1d6a13c..b107630 100644 --- a/chrome/browser/ui/webui/ntp_login_handler.cc +++ b/chrome/browser/ui/webui/ntp_login_handler.cc @@ -13,7 +13,6 @@ #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/sync_setup_flow.h" #include "chrome/common/pref_names.h" -#include "content/browser/webui/web_ui_util.h" #include "content/common/notification_details.h" NTPLoginHandler::NTPLoginHandler() { diff --git a/chrome/browser/ui/webui/options/autofill_options_handler.cc b/chrome/browser/ui/webui/options/autofill_options_handler.cc index 5bb1c2d..6d5287d 100644 --- a/chrome/browser/ui/webui/options/autofill_options_handler.cc +++ b/chrome/browser/ui/webui/options/autofill_options_handler.cc @@ -15,8 +15,8 @@ #include "chrome/browser/autofill/autofill_profile.h" #include "chrome/browser/autofill/credit_card.h" #include "chrome/browser/profiles/profile.h" +#include "chrome/browser/ui/webui/web_ui_util.h" #include "chrome/common/guid.h" -#include "content/browser/webui/web_ui_util.h" #include "grit/generated_resources.h" #include "grit/webkit_resources.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/browser/ui/webui/options/chromeos/accounts_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/accounts_options_handler.cc index 1979728..90670c6 100644 --- a/chrome/browser/ui/webui/options/chromeos/accounts_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/accounts_options_handler.cc @@ -16,7 +16,6 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/ui/webui/options/options_managed_banner_handler.h" #include "chrome/common/url_constants.h" -#include "content/browser/webui/web_ui_util.h" #include "grit/generated_resources.h" #include "ui/base/l10n/l10n_util.h" diff --git a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc index 570952c..6185c06 100644 --- a/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc +++ b/chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc @@ -29,9 +29,9 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/window.h" +#include "chrome/browser/ui/webui/web_ui_util.h" #include "chrome/common/pref_names.h" #include "chrome/common/time_format.h" -#include "content/browser/webui/web_ui_util.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" diff --git a/chrome/browser/ui/webui/options/personal_options_handler.cc b/chrome/browser/ui/webui/options/personal_options_handler.cc index 4aa1283..69d3524 100644 --- a/chrome/browser/ui/webui/options/personal_options_handler.cc +++ b/chrome/browser/ui/webui/options/personal_options_handler.cc @@ -40,7 +40,6 @@ #if defined(OS_CHROMEOS) #include "chrome/browser/chromeos/login/user_manager.h" -#include "content/browser/webui/web_ui_util.h" #include "third_party/skia/include/core/SkBitmap.h" #endif // defined(OS_CHROMEOS) #if defined(TOOLKIT_GTK) diff --git a/chrome/browser/ui/webui/web_ui_util.cc b/chrome/browser/ui/webui/web_ui_util.cc new file mode 100644 index 0000000..ee854ac --- /dev/null +++ b/chrome/browser/ui/webui/web_ui_util.cc @@ -0,0 +1,42 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/ui/webui/web_ui_util.h" + +#include + +#include "base/base64.h" +#include "ui/base/resource/resource_bundle.h" +#include "ui/gfx/codec/png_codec.h" + +namespace web_ui_util { + +std::string GetImageDataUrl(const SkBitmap& bitmap) { + std::vector output; + gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &output); + std::string str_url; + str_url.insert(str_url.end(), output.begin(), output.end()); + + base::Base64Encode(str_url, &str_url); + str_url.insert(0, "data:image/png;base64,"); + return str_url; +} + +std::string GetImageDataUrlFromResource(int res) { + // Load resource icon and covert to base64 encoded data url + RefCountedStaticMemory* icon_data = + ResourceBundle::GetSharedInstance().LoadDataResourceBytes(res); + if (!icon_data) + return std::string(); + scoped_refptr raw_icon(icon_data); + std::string str_url; + str_url.insert(str_url.end(), + raw_icon->front(), + raw_icon->front() + raw_icon->size()); + base::Base64Encode(str_url, &str_url); + str_url.insert(0, "data:image/png;base64,"); + return str_url; +} + +} // namespace web_ui_util diff --git a/chrome/browser/ui/webui/web_ui_util.h b/chrome/browser/ui/webui/web_ui_util.h new file mode 100644 index 0000000..2a7743f --- /dev/null +++ b/chrome/browser/ui/webui/web_ui_util.h @@ -0,0 +1,29 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_BROWSER_UI_WEBUI_WEB_UI_UTIL_H_ +#define CHROME_BROWSER_UI_WEBUI_WEB_UI_UTIL_H_ +#pragma once + +#include + +class SkBitmap; + +namespace web_ui_util { + +// Convenience routine to convert SkBitmap object to data url +// so that it can be used in WebUI. +std::string GetImageDataUrl(const SkBitmap& bitmap); + +// Convenience routine to get data url that corresponds to given +// resource_id as an image. This function does not check if the +// resource for the |resource_id| is an image, therefore it is the +// caller's responsibility to make sure the resource is indeed an +// image. Returns empty string if a resource does not exist for given +// |resource_id|. +std::string GetImageDataUrlFromResource(int resource_id); + +} // namespace web_ui_util + +#endif // CHROME_BROWSER_UI_WEBUI_WEB_UI_UTIL_H_ diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 4accb82..19417b5 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -3261,6 +3261,8 @@ 'browser/ui/webui/thumbnail_source.h', 'browser/ui/webui/value_helper.cc', 'browser/ui/webui/value_helper.h', + 'browser/ui/webui/web_ui_util.cc', + 'browser/ui/webui/web_ui_util.h', 'browser/ui/window_sizer.cc', 'browser/ui/window_sizer.h', 'browser/ui/window_sizer_linux.cc', diff --git a/content/browser/webui/web_ui_util.cc b/content/browser/webui/web_ui_util.cc deleted file mode 100644 index 470df32..0000000 --- a/content/browser/webui/web_ui_util.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "content/browser/webui/web_ui_util.h" - -#include - -#include "base/base64.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/codec/png_codec.h" - -namespace web_ui_util { - -std::string GetImageDataUrl(const SkBitmap& bitmap) { - std::vector output; - gfx::PNGCodec::EncodeBGRASkBitmap(bitmap, false, &output); - std::string str_url; - str_url.insert(str_url.end(), output.begin(), output.end()); - - base::Base64Encode(str_url, &str_url); - str_url.insert(0, "data:image/png;base64,"); - return str_url; -} - -std::string GetImageDataUrlFromResource(int res) { - // Load resource icon and covert to base64 encoded data url - RefCountedStaticMemory* icon_data = - ResourceBundle::GetSharedInstance().LoadDataResourceBytes(res); - if (!icon_data) - return std::string(); - scoped_refptr raw_icon(icon_data); - std::string str_url; - str_url.insert(str_url.end(), - raw_icon->front(), - raw_icon->front() + raw_icon->size()); - base::Base64Encode(str_url, &str_url); - str_url.insert(0, "data:image/png;base64,"); - return str_url; -} - -} // namespace web_ui_util diff --git a/content/browser/webui/web_ui_util.h b/content/browser/webui/web_ui_util.h deleted file mode 100644 index 368aa5d..0000000 --- a/content/browser/webui/web_ui_util.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CONTENT_BROWSER_WEBUI_WEB_UI_UTIL_H_ -#define CONTENT_BROWSER_WEBUI_WEB_UI_UTIL_H_ -#pragma once - -#include - -class SkBitmap; - -namespace web_ui_util { - -// Convenience routine to convert SkBitmap object to data url -// so that it can be used in WebUI. -std::string GetImageDataUrl(const SkBitmap& bitmap); - -// Convenience routine to get data url that corresponds to given -// resource_id as an image. This function does not check if the -// resource for the |resource_id| is an image, therefore it is the -// caller's responsibility to make sure the resource is indeed an -// image. Returns empty string if a resource does not exist for given -// |resource_id|. -std::string GetImageDataUrlFromResource(int resource_id); - -} // namespace web_ui_util - -#endif // CONTENT_BROWSER_WEBUI_WEB_UI_UTIL_H_ diff --git a/content/content_browser.gypi b/content/content_browser.gypi index 445344c..7895d74 100644 --- a/content/content_browser.gypi +++ b/content/content_browser.gypi @@ -308,8 +308,6 @@ 'browser/webui/web_ui.h', 'browser/webui/web_ui_factory.cc', 'browser/webui/web_ui_factory.h', - 'browser/webui/web_ui_util.cc', - 'browser/webui/web_ui_util.h', 'browser/worker_host/message_port_service.cc', 'browser/worker_host/message_port_service.h', 'browser/worker_host/worker_document_set.cc', -- cgit v1.1