diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 02:23:31 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-06 02:23:31 +0000 |
commit | 3712621396b5ffa5572bc5c0728a63efe9f7476e (patch) | |
tree | a55fc85f01bafbe1ae86e43c5f1ce9638db5b621 /chrome | |
parent | af9a8c86fc50e8d789bf795347302e6c94ad6854 (diff) | |
download | chromium_src-3712621396b5ffa5572bc5c0728a63efe9f7476e.zip chromium_src-3712621396b5ffa5572bc5c0728a63efe9f7476e.tar.gz chromium_src-3712621396b5ffa5572bc5c0728a63efe9f7476e.tar.bz2 |
Move: drag_drop_types, favicon_size, icon_util, insets, path, message_box_flags, os_exchange_data to src/app
http://crbug.com/11387
Review URL: http://codereview.chromium.org/115012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15371 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
91 files changed, 131 insertions, 2627 deletions
diff --git a/chrome/browser/app_modal_dialog_gtk.cc b/chrome/browser/app_modal_dialog_gtk.cc index 99ea2f5..1ffbd39 100644 --- a/chrome/browser/app_modal_dialog_gtk.cc +++ b/chrome/browser/app_modal_dialog_gtk.cc @@ -7,11 +7,11 @@ #include <gtk/gtk.h> #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "base/logging.h" #include "base/string_util.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" -#include "chrome/common/message_box_flags.h" #include "grit/generated_resources.h" namespace { diff --git a/chrome/browser/app_modal_dialog_mac.mm b/chrome/browser/app_modal_dialog_mac.mm index 6df038f..26c1dcf 100644 --- a/chrome/browser/app_modal_dialog_mac.mm +++ b/chrome/browser/app_modal_dialog_mac.mm @@ -7,8 +7,8 @@ #import <Cocoa/Cocoa.h> #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "base/sys_string_conversions.h" -#include "chrome/common/message_box_flags.h" #include "grit/generated_resources.h" // Helper object that receives the notification that the dialog/sheet is diff --git a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc index 70df68c..e544f76 100644 --- a/chrome/browser/autocomplete/autocomplete_edit_view_win.cc +++ b/chrome/browser/autocomplete/autocomplete_edit_view_win.cc @@ -9,6 +9,7 @@ #include "app/gfx/chrome_canvas.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" +#include "app/os_exchange_data.h" #include "base/base_drag_source.h" #include "base/base_drop_target.h" #include "base/basictypes.h" @@ -35,7 +36,6 @@ #include "chrome/browser/views/location_bar_view.h" #include "chrome/common/gfx/utils.h" #include "chrome/common/notification_service.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/common/win_util.h" #include "chrome/views/focus/focus_util_win.h" #include "googleurl/src/url_util.h" diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index ec2284f..395e02e 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -4,6 +4,7 @@ #include "chrome/browser/automation/automation_provider.h" +#include "app/message_box_flags.h" #include "base/file_version_info.h" #include "base/message_loop.h" #include "base/path_service.h" @@ -29,7 +30,6 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/common/chrome_paths.h" -#include "chrome/common/message_box_flags.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/platform_util.h" #include "chrome/common/pref_service.h" diff --git a/chrome/browser/bookmarks/bookmark_drag_data.cc b/chrome/browser/bookmarks/bookmark_drag_data.cc index b64562e..4b3bdb6 100644 --- a/chrome/browser/bookmarks/bookmark_drag_data.cc +++ b/chrome/browser/bookmarks/bookmark_drag_data.cc @@ -4,6 +4,12 @@ #include "chrome/browser/bookmarks/bookmark_drag_data.h" +// TODO(port): Port this file. +#if defined(OS_WIN) +#include "app/os_exchange_data.h" +#else +#include "chrome/common/temp_scaffolding_stubs.h" +#endif #include "base/basictypes.h" #include "base/pickle.h" #include "base/string_util.h" @@ -11,12 +17,6 @@ #include "chrome/browser/profile.h" #include "chrome/common/url_constants.h" -// TODO(port): Port this file. -#if defined(OS_WIN) -#include "chrome/common/os_exchange_data.h" -#else -#include "chrome/common/temp_scaffolding_stubs.h" -#endif #if defined(OS_WIN) static CLIPFORMAT clipboard_format = 0; diff --git a/chrome/browser/bookmarks/bookmark_drag_data_unittest.cc b/chrome/browser/bookmarks/bookmark_drag_data_unittest.cc index c952471..1d1e1f2 100644 --- a/chrome/browser/bookmarks/bookmark_drag_data_unittest.cc +++ b/chrome/browser/bookmarks/bookmark_drag_data_unittest.cc @@ -2,10 +2,10 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "app/os_exchange_data.h" #include "base/scoped_ptr.h" #include "chrome/browser/bookmarks/bookmark_drag_data.h" #include "chrome/browser/bookmarks/bookmark_model.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/test/testing_profile.h" #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/browser/bookmarks/bookmark_menu_controller.cc b/chrome/browser/bookmarks/bookmark_menu_controller.cc index 4376c92..7f90a52 100644 --- a/chrome/browser/bookmarks/bookmark_menu_controller.cc +++ b/chrome/browser/bookmarks/bookmark_menu_controller.cc @@ -5,6 +5,7 @@ #include "chrome/browser/bookmarks/bookmark_menu_controller.h" #include "app/l10n_util.h" +#include "app/os_exchange_data.h" #include "app/resource_bundle.h" #include "chrome/browser/bookmarks/bookmark_drag_data.h" #include "chrome/browser/bookmarks/bookmark_utils.h" @@ -12,7 +13,6 @@ #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/page_navigator.h" #include "chrome/browser/views/event_utils.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/common/page_transition_types.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc index 80a9fbd..201b063 100644 --- a/chrome/browser/bookmarks/bookmark_utils.cc +++ b/chrome/browser/bookmarks/bookmark_utils.cc @@ -4,7 +4,14 @@ #include "chrome/browser/bookmarks/bookmark_utils.h" +#include "app/drag_drop_types.h" #include "app/l10n_util.h" +// TODO(port): Port these files. +#if defined(OS_WIN) +#include "app/os_exchange_data.h" +#else +#include "chrome/common/temp_scaffolding_stubs.h" +#endif #include "base/basictypes.h" #include "base/string_util.h" #include "base/time.h" @@ -16,7 +23,6 @@ #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/page_navigator.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/common/drag_drop_types.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" @@ -25,13 +31,6 @@ #include "grit/chromium_strings.h" #include "grit/generated_resources.h" -// TODO(port): Port these files. -#if defined(OS_WIN) -#include "chrome/common/os_exchange_data.h" -#else -#include "chrome/common/temp_scaffolding_stubs.h" -#endif - using base::Time; namespace { diff --git a/chrome/browser/browser_main_win.cc b/chrome/browser/browser_main_win.cc index 2c6e77f..5dc8c26 100644 --- a/chrome/browser/browser_main_win.cc +++ b/chrome/browser/browser_main_win.cc @@ -10,6 +10,7 @@ #include "chrome/browser/browser_main_win.h" #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "base/command_line.h" #include "base/path_service.h" #include "base/win_util.h" @@ -18,7 +19,6 @@ #include "chrome/browser/views/uninstall_dialog.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/env_vars.h" -#include "chrome/common/message_box_flags.h" #include "chrome/common/result_codes.h" #include "chrome/installer/util/helper.h" #include "chrome/installer/util/install_util.h" diff --git a/chrome/browser/download/download_request_dialog_delegate_win.cc b/chrome/browser/download/download_request_dialog_delegate_win.cc index 7df2490..677cab7 100644 --- a/chrome/browser/download/download_request_dialog_delegate_win.cc +++ b/chrome/browser/download/download_request_dialog_delegate_win.cc @@ -5,9 +5,9 @@ #include "chrome/browser/download/download_request_dialog_delegate_win.h" #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "chrome/browser/tab_contents/constrained_window.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/common/message_box_flags.h" #include "chrome/views/controls/message_box_view.h" #include "grit/generated_resources.h" diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index b5269d1..f5589b84 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -10,6 +10,7 @@ #include "app/gfx/chrome_canvas.h" #include "app/l10n_util.h" +#include "app/os_exchange_data.h" #include "app/resource_bundle.h" #include "base/base_drag_source.h" #include "base/file_util.h" @@ -19,7 +20,6 @@ #include "chrome/browser/download/download_item_model.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/drag_utils.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/views/view.h" #include "grit/generated_resources.h" #include "grit/locale_settings.h" diff --git a/chrome/browser/drag_utils.cc b/chrome/browser/drag_utils.cc index a715492..8bb7949 100644 --- a/chrome/browser/drag_utils.cc +++ b/chrome/browser/drag_utils.cc @@ -11,13 +11,13 @@ #include "app/gfx/chrome_canvas.h" #include "app/gfx/chrome_font.h" #include "app/l10n_util.h" +#include "app/os_exchange_data.h" #include "app/resource_bundle.h" #include "base/file_util.h" #include "base/gfx/gdi_util.h" #include "base/gfx/point.h" #include "base/string_util.h" #include "chrome/browser/views/bookmark_bar_view.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/common/win_util.h" #include "chrome/views/controls/button/text_button.h" #include "googleurl/src/gurl.h" diff --git a/chrome/browser/fav_icon_helper.cc b/chrome/browser/fav_icon_helper.cc index fda769c..3cf5af5 100644 --- a/chrome/browser/fav_icon_helper.cc +++ b/chrome/browser/fav_icon_helper.cc @@ -6,6 +6,7 @@ #include "build/build_config.h" +#include "app/gfx/favicon_size.h" #include "base/gfx/png_decoder.h" #include "base/gfx/png_encoder.h" #include "chrome/browser/renderer_host/render_view_host.h" @@ -13,7 +14,6 @@ #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents_delegate.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/common/gfx/favicon_size.h" #include "skia/ext/image_operations.h" FavIconHelper::FavIconHelper(TabContents* tab_contents) diff --git a/chrome/browser/gtk/info_bubble_gtk.cc b/chrome/browser/gtk/info_bubble_gtk.cc index 0fe2b79..d01bd55 100644 --- a/chrome/browser/gtk/info_bubble_gtk.cc +++ b/chrome/browser/gtk/info_bubble_gtk.cc @@ -6,11 +6,11 @@ #include <gtk/gtk.h> +#include "app/gfx/path.h" #include "base/basictypes.h" #include "base/gfx/gtk_util.h" #include "base/gfx/rect.h" #include "base/logging.h" -#include "chrome/common/gfx/path.h" namespace { diff --git a/chrome/browser/gtk/tabs/tab_gtk.cc b/chrome/browser/gtk/tabs/tab_gtk.cc index cb873b0..2215015 100644 --- a/chrome/browser/gtk/tabs/tab_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_gtk.cc @@ -4,11 +4,11 @@ #include "chrome/browser/gtk/tabs/tab_gtk.h" +#include "app/gfx/path.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "chrome/browser/gtk/custom_button.h" #include "chrome/browser/gtk/menu_gtk.h" -#include "chrome/common/gfx/path.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" diff --git a/chrome/browser/icon_loader.cc b/chrome/browser/icon_loader.cc index 5004e5e..99dbe40 100644 --- a/chrome/browser/icon_loader.cc +++ b/chrome/browser/icon_loader.cc @@ -7,6 +7,7 @@ #include <windows.h> #include <shellapi.h> +#include "app/gfx/icon_util.h" #include "base/file_util.h" #include "base/gfx/size.h" #include "base/message_loop.h" @@ -15,7 +16,6 @@ #include "base/task.h" #include "base/thread.h" #include "chrome/browser/browser_process.h" -#include "chrome/common/gfx/icon_util.h" #include "SkBitmap.h" diff --git a/chrome/browser/importer/importer.cc b/chrome/browser/importer/importer.cc index 333ad8c..2209541 100644 --- a/chrome/browser/importer/importer.cc +++ b/chrome/browser/importer/importer.cc @@ -7,6 +7,7 @@ #include <map> #include <set> +#include "app/gfx/favicon_size.h" #include "app/l10n_util.h" #include "base/file_util.h" #include "base/gfx/png_encoder.h" @@ -28,7 +29,6 @@ #include "chrome/browser/shell_integration.h" #include "chrome/browser/tab_contents/site_instance.h" #include "chrome/browser/webdata/web_data_service.h" -#include "chrome/common/gfx/favicon_size.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" diff --git a/chrome/browser/jsmessage_box_handler.cc b/chrome/browser/jsmessage_box_handler.cc index 41edfec..061e469 100644 --- a/chrome/browser/jsmessage_box_handler.cc +++ b/chrome/browser/jsmessage_box_handler.cc @@ -5,13 +5,13 @@ #include "chrome/browser/jsmessage_box_handler.h" #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "build/build_config.h" #include "chrome/browser/app_modal_dialog_queue.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/gfx/text_elider.h" -#include "chrome/common/message_box_flags.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "googleurl/src/gurl.h" diff --git a/chrome/browser/search_engines/template_url.cc b/chrome/browser/search_engines/template_url.cc index 61b8da8..9e9a5c9 100644 --- a/chrome/browser/search_engines/template_url.cc +++ b/chrome/browser/search_engines/template_url.cc @@ -4,6 +4,7 @@ #include "chrome/browser/search_engines/template_url.h" +#include "app/gfx/favicon_size.h" #include "app/l10n_util.h" #include "base/logging.h" #include "base/string_util.h" @@ -11,7 +12,6 @@ #include "chrome/browser/rlz/rlz.h" #include "chrome/browser/google_url_tracker.h" #include "chrome/browser/search_engines/template_url_model.h" -#include "chrome/common/gfx/favicon_size.h" #include "net/base/escape.h" // The TemplateURLRef has any number of terms that need to be replaced. Each of diff --git a/chrome/browser/tab_contents/tab_contents_view_win.cc b/chrome/browser/tab_contents/tab_contents_view_win.cc index 8ea2160..79c3b85 100644 --- a/chrome/browser/tab_contents/tab_contents_view_win.cc +++ b/chrome/browser/tab_contents/tab_contents_view_win.cc @@ -7,6 +7,7 @@ #include <windows.h> #include "app/gfx/chrome_canvas.h" +#include "app/os_exchange_data.h" #include "chrome/browser/bookmarks/bookmark_drag_data.h" #include "chrome/browser/browser.h" // TODO(beng): this dependency is awful. #include "chrome/browser/browser_process.h" @@ -22,7 +23,6 @@ #include "chrome/browser/tab_contents/web_drag_source.h" #include "chrome/browser/tab_contents/web_drop_target.h" #include "chrome/browser/views/sad_tab_view.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/common/url_constants.h" #include "chrome/views/focus/view_storage.h" #include "chrome/views/widget/root_view.h" diff --git a/chrome/browser/tab_contents/web_drop_target.cc b/chrome/browser/tab_contents/web_drop_target.cc index 7f9cbf7..bad7e1d 100644 --- a/chrome/browser/tab_contents/web_drop_target.cc +++ b/chrome/browser/tab_contents/web_drop_target.cc @@ -7,11 +7,11 @@ #include "chrome/browser/tab_contents/web_drop_target.h" +#include "app/os_exchange_data.h" #include "base/clipboard_util.h" #include "base/gfx/point.h" #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/common/os_exchange_data.h" #include "googleurl/src/gurl.h" #include "net/base/net_util.h" #include "webkit/glue/webdropdata.h" diff --git a/chrome/browser/task_manager_resource_providers.cc b/chrome/browser/task_manager_resource_providers.cc index 49c4473..b13ac31 100644 --- a/chrome/browser/task_manager_resource_providers.cc +++ b/chrome/browser/task_manager_resource_providers.cc @@ -4,6 +4,9 @@ #include "chrome/browser/task_manager_resource_providers.h" +#if defined(OS_WIN) +#include "app/gfx/icon_util.h" +#endif // defined(OS_WIN) #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/basictypes.h" @@ -21,9 +24,6 @@ #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/child_process_host.h" #include "chrome/common/notification_service.h" -#if defined(OS_WIN) -#include "chrome/common/gfx/icon_util.h" -#endif // defined(OS_WIN) #include "grit/generated_resources.h" #include "grit/theme_resources.h" diff --git a/chrome/browser/unload_uitest.cc b/chrome/browser/unload_uitest.cc index e4401f7..a44f792 100644 --- a/chrome/browser/unload_uitest.cc +++ b/chrome/browser/unload_uitest.cc @@ -2,11 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "app/message_box_flags.h" #include "base/file_util.h" #include "base/platform_thread.h" #include "chrome/browser/automation/url_request_mock_http_job.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/message_box_flags.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/ui/ui_test.h" diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc index 70efbc9..f7e8aaa 100644 --- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc +++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.cc @@ -7,14 +7,14 @@ #include <dwmapi.h> #include "app/gfx/chrome_canvas.h" +#include "app/gfx/insets.h" +#include "app/gfx/path.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/views/autocomplete/autocomplete_popup_win.h" #include "chrome/common/gfx/color_utils.h" -#include "chrome/common/gfx/insets.h" -#include "chrome/common/gfx/path.h" #include "chrome/common/win_util.h" #include "chrome/views/widget/widget.h" #include "grit/generated_resources.h" diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h index aa40435..4fd599d 100644 --- a/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h +++ b/chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h @@ -10,6 +10,7 @@ #include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/autocomplete/autocomplete_popup_view.h" #include "chrome/views/view.h" +#include "webkit/glue/window_open_disposition.h" class AutocompleteEditModel; class AutocompleteEditViewWin; diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_win.cc b/chrome/browser/views/autocomplete/autocomplete_popup_win.cc index baf9903..469561e 100644 --- a/chrome/browser/views/autocomplete/autocomplete_popup_win.cc +++ b/chrome/browser/views/autocomplete/autocomplete_popup_win.cc @@ -4,10 +4,10 @@ #include "chrome/browser/views/autocomplete/autocomplete_popup_win.h" +#include "app/gfx/insets.h" #include "chrome/browser/autocomplete/autocomplete_edit_view_win.h" #include "chrome/browser/autocomplete/autocomplete_popup_model.h" #include "chrome/browser/views/autocomplete/autocomplete_popup_contents_view.h" -#include "chrome/common/gfx/insets.h" #include "chrome/common/win_util.h" //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/views/blocked_popup_container.cc b/chrome/browser/views/blocked_popup_container.cc index 3d8bf6b..c6db1c6 100644 --- a/chrome/browser/views/blocked_popup_container.cc +++ b/chrome/browser/views/blocked_popup_container.cc @@ -13,13 +13,13 @@ #include <math.h> #include "app/gfx/chrome_canvas.h" +#include "app/gfx/path.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/string_util.h" #include "chrome/browser/extensions/extension_function_dispatcher.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/common/gfx/path.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" #include "chrome/views/background.h" diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index 19dfa90..82e532b 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -8,6 +8,7 @@ #include "app/gfx/chrome_canvas.h" #include "app/l10n_util.h" +#include "app/os_exchange_data.h" #include "app/resource_bundle.h" #include "base/string_util.h" #include "base/base_drag_source.h" @@ -28,7 +29,6 @@ #include "chrome/browser/views/event_utils.h" #include "chrome/common/gfx/text_elider.h" #include "chrome/common/notification_service.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/common/page_transition_types.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" diff --git a/chrome/browser/views/bookmark_folder_tree_view.cc b/chrome/browser/views/bookmark_folder_tree_view.cc index 3e79ffe..7986d8f 100644 --- a/chrome/browser/views/bookmark_folder_tree_view.cc +++ b/chrome/browser/views/bookmark_folder_tree_view.cc @@ -4,13 +4,13 @@ #include "chrome/browser/views/bookmark_folder_tree_view.h" +#include "app/drag_drop_types.h" +#include "app/os_exchange_data.h" #include "base/base_drag_source.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_folder_tree_model.h" #include "chrome/browser/profile.h" -#include "chrome/common/drag_drop_types.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/views/view_constants.h" #include "grit/generated_resources.h" diff --git a/chrome/browser/views/bookmark_menu_button.cc b/chrome/browser/views/bookmark_menu_button.cc index 4ac62e9..e92e5bb 100644 --- a/chrome/browser/views/bookmark_menu_button.cc +++ b/chrome/browser/views/bookmark_menu_button.cc @@ -5,12 +5,12 @@ #include "chrome/browser/views/bookmark_menu_button.h" #include "app/resource_bundle.h" +#include "app/os_exchange_data.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/browser.h" #include "chrome/browser/profile.h" #include "chrome/browser/view_ids.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/views/widget/widget.h" #include "grit/theme_resources.h" diff --git a/chrome/browser/views/bookmark_table_view.cc b/chrome/browser/views/bookmark_table_view.cc index d3da5e8..12d1d9f 100644 --- a/chrome/browser/views/bookmark_table_view.cc +++ b/chrome/browser/views/bookmark_table_view.cc @@ -4,16 +4,16 @@ #include "chrome/browser/views/bookmark_table_view.h" +#include "app/drag_drop_types.h" #include "app/gfx/chrome_canvas.h" #include "app/gfx/chrome_font.h" +#include "app/os_exchange_data.h" #include "app/resource_bundle.h" #include "base/base_drag_source.h" #include "chrome/browser/bookmarks/bookmark_utils.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/bookmarks/bookmark_table_model.h" #include "chrome/browser/profile.h" -#include "chrome/common/drag_drop_types.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/views/view_constants.h" diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index a99eb60..cdcd078 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -6,6 +6,7 @@ #include "app/gfx/chrome_canvas.h" #include "app/gfx/chrome_font.h" +#include "app/gfx/path.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/gfx/rect.h" @@ -19,7 +20,6 @@ #include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/window_sizer.h" #include "chrome/common/chrome_constants.h" -#include "chrome/common/gfx/path.h" #include "chrome/common/gfx/text_elider.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_names.h" diff --git a/chrome/browser/views/external_protocol_dialog.cc b/chrome/browser/views/external_protocol_dialog.cc index 57c9bef..2d60738 100644 --- a/chrome/browser/views/external_protocol_dialog.cc +++ b/chrome/browser/views/external_protocol_dialog.cc @@ -5,6 +5,7 @@ #include "chrome/browser/views/external_protocol_dialog.h" #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "base/histogram.h" #include "base/registry.h" #include "base/string_util.h" @@ -13,7 +14,6 @@ #include "chrome/browser/external_protocol_handler.h" #include "chrome/browser/tab_contents/tab_util.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/common/message_box_flags.h" #include "chrome/views/controls/message_box_view.h" #include "chrome/views/window/window.h" #include "grit/chromium_strings.h" diff --git a/chrome/browser/views/frame/browser_root_view.cc b/chrome/browser/views/frame/browser_root_view.cc index c404b2c..78f6ef0 100644 --- a/chrome/browser/views/frame/browser_root_view.cc +++ b/chrome/browser/views/frame/browser_root_view.cc @@ -4,11 +4,11 @@ #include "chrome/browser/views/frame/browser_root_view.h" +#include "app/drag_drop_types.h" +#include "app/os_exchange_data.h" #include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/frame/browser_frame.h" #include "chrome/browser/views/tabs/tab_strip.h" -#include "chrome/common/drag_drop_types.h" -#include "chrome/common/os_exchange_data.h" BrowserRootView::BrowserRootView(views::Widget* widget) : views::RootView(widget), diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 880f011..fad5dd1 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -4,8 +4,10 @@ #include "chrome/browser/views/frame/browser_view.h" +#include "app/drag_drop_types.h" #include "app/gfx/chrome_canvas.h" #include "app/l10n_util.h" +#include "app/os_exchange_data.h" #include "app/resource_bundle.h" #include "base/command_line.h" #include "base/file_version_info.h" @@ -47,9 +49,7 @@ #include "chrome/browser/tab_contents/tab_contents_view.h" #include "chrome/browser/window_sizer.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/drag_drop_types.h" #include "chrome/common/notification_service.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/common/win_util.h" diff --git a/chrome/browser/views/frame/opaque_browser_frame_view.cc b/chrome/browser/views/frame/opaque_browser_frame_view.cc index 56c1d17..4958b13 100644 --- a/chrome/browser/views/frame/opaque_browser_frame_view.cc +++ b/chrome/browser/views/frame/opaque_browser_frame_view.cc @@ -6,12 +6,12 @@ #include "app/gfx/chrome_canvas.h" #include "app/gfx/chrome_font.h" +#include "app/gfx/path.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "chrome/browser/views/frame/browser_frame.h" #include "chrome/browser/views/frame/browser_view.h" #include "chrome/browser/views/tabs/tab_strip.h" -#include "chrome/common/gfx/path.h" #include "chrome/common/win_util.h" #include "chrome/views/controls/button/image_button.h" #include "chrome/views/widget/root_view.h" diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc index fb048b3..ebe2e93 100644 --- a/chrome/browser/views/hung_renderer_view.cc +++ b/chrome/browser/views/hung_renderer_view.cc @@ -12,7 +12,6 @@ #include "chrome/browser/views/standard_layout.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/common/chrome_constants.h" -#include "chrome/common/gfx/path.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/result_codes.h" #include "chrome/views/grid_layout.h" diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc index 8fe97d8..38e36f75 100644 --- a/chrome/browser/views/info_bubble.cc +++ b/chrome/browser/views/info_bubble.cc @@ -5,11 +5,11 @@ #include "chrome/browser/views/info_bubble.h" #include "app/gfx/chrome_canvas.h" +#include "app/gfx/path.h" #include "app/resource_bundle.h" #include "base/win_util.h" #include "chrome/browser/browser_window.h" #include "chrome/browser/views/frame/browser_view.h" -#include "chrome/common/gfx/path.h" #include "chrome/common/notification_service.h" #include "chrome/common/notification_type.h" #include "chrome/common/win_util.h" diff --git a/chrome/browser/views/jsmessage_box_dialog.cc b/chrome/browser/views/jsmessage_box_dialog.cc index 3375af2..fab95a4 100644 --- a/chrome/browser/views/jsmessage_box_dialog.cc +++ b/chrome/browser/views/jsmessage_box_dialog.cc @@ -5,9 +5,9 @@ #include "chrome/browser/views/jsmessage_box_dialog.h" #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "chrome/browser/app_modal_dialog.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/common/message_box_flags.h" #include "chrome/views/controls/message_box_view.h" #include "chrome/views/window/window.h" #include "grit/generated_resources.h" diff --git a/chrome/browser/views/new_profile_dialog.cc b/chrome/browser/views/new_profile_dialog.cc index b50424a..1c5faa6 100644 --- a/chrome/browser/views/new_profile_dialog.cc +++ b/chrome/browser/views/new_profile_dialog.cc @@ -7,10 +7,10 @@ #include <string> #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "base/logging.h" #include "base/file_util.h" #include "chrome/browser/user_data_manager.h" -#include "chrome/common/message_box_flags.h" #include "chrome/views/controls/message_box_view.h" #include "chrome/views/controls/text_field.h" #include "chrome/views/view.h" diff --git a/chrome/browser/views/options/advanced_page_view.cc b/chrome/browser/views/options/advanced_page_view.cc index cccbf69..5e84ef3e 100644 --- a/chrome/browser/views/options/advanced_page_view.cc +++ b/chrome/browser/views/options/advanced_page_view.cc @@ -5,13 +5,13 @@ #include "chrome/browser/views/options/advanced_page_view.h" #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "base/string_util.h" #include "base/values.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/views/options/advanced_contents_view.h" #include "chrome/browser/views/standard_layout.h" #include "chrome/common/chrome_constants.h" -#include "chrome/common/message_box_flags.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/views/controls/message_box_view.h" diff --git a/chrome/browser/views/repost_form_warning_view.cc b/chrome/browser/views/repost_form_warning_view.cc index a1bd302..13618fd 100644 --- a/chrome/browser/views/repost_form_warning_view.cc +++ b/chrome/browser/views/repost_form_warning_view.cc @@ -5,9 +5,9 @@ #include "chrome/browser/views/repost_form_warning_view.h" #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/tab_contents/navigation_controller.h" -#include "chrome/common/message_box_flags.h" #include "chrome/common/notification_service.h" #include "chrome/views/controls/message_box_view.h" #include "chrome/views/window/window.h" diff --git a/chrome/browser/views/restart_message_box.cc b/chrome/browser/views/restart_message_box.cc index 3624f5c..bffbb82 100644 --- a/chrome/browser/views/restart_message_box.cc +++ b/chrome/browser/views/restart_message_box.cc @@ -5,7 +5,7 @@ #include "chrome/browser/views/restart_message_box.h" #include "app/l10n_util.h" -#include "chrome/common/message_box_flags.h" +#include "app/message_box_flags.h" #include "chrome/views/controls/message_box_view.h" #include "chrome/views/window/window.h" #include "grit/chromium_strings.h" diff --git a/chrome/browser/views/tab_icon_view.cc b/chrome/browser/views/tab_icon_view.cc index 0ae41cc..578c917 100644 --- a/chrome/browser/views/tab_icon_view.cc +++ b/chrome/browser/views/tab_icon_view.cc @@ -8,13 +8,13 @@ #include <shellapi.h> #include "app/gfx/chrome_canvas.h" +#include "app/gfx/favicon_size.h" +#include "app/gfx/icon_util.h" #include "app/resource_bundle.h" #include "base/file_util.h" #include "base/path_service.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/common/gfx/favicon_size.h" -#include "chrome/common/gfx/icon_util.h" #include "grit/theme_resources.h" static bool g_initialized = false; diff --git a/chrome/browser/views/tabs/tab.cc b/chrome/browser/views/tabs/tab.cc index 0ed0368..f2193dc 100644 --- a/chrome/browser/views/tabs/tab.cc +++ b/chrome/browser/views/tabs/tab.cc @@ -5,10 +5,10 @@ #include "chrome/browser/views/tabs/tab.h" #include "app/gfx/chrome_canvas.h" +#include "app/gfx/path.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/gfx/size.h" -#include "chrome/common/gfx/path.h" #include "chrome/views/controls/menu/chrome_menu.h" #include "chrome/views/widget/tooltip_manager.h" #include "chrome/views/widget/widget.h" diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index ec487aa..fce1297 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -4,8 +4,11 @@ #include "chrome/browser/views/tabs/tab_strip.h" +#include "app/drag_drop_types.h" #include "app/gfx/chrome_canvas.h" +#include "app/gfx/path.h" #include "app/l10n_util.h" +#include "app/os_exchange_data.h" #include "app/resource_bundle.h" #include "app/slide_animation.h" #include "base/gfx/size.h" @@ -18,9 +21,6 @@ #include "chrome/browser/views/tabs/dragged_tab_controller.h" #include "chrome/browser/views/tabs/tab.h" #include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/common/drag_drop_types.h" -#include "chrome/common/gfx/path.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/common/pref_names.h" #include "chrome/common/win_util.h" #include "chrome/views/controls/image_view.h" diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index 333cc6c..6d0f02b 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -6,8 +6,10 @@ #include <string> +#include "app/drag_drop_types.h" #include "app/gfx/chrome_canvas.h" #include "app/l10n_util.h" +#include "app/os_exchange_data.h" #include "app/resource_bundle.h" #include "base/command_line.h" #include "base/logging.h" @@ -33,9 +35,7 @@ #include "chrome/browser/view_ids.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/drag_drop_types.h" #include "chrome/common/notification_service.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/common/win_util.h" diff --git a/chrome/browser/views/uninstall_dialog.cc b/chrome/browser/views/uninstall_dialog.cc index 59ff2d5..f9b2c04 100644 --- a/chrome/browser/views/uninstall_dialog.cc +++ b/chrome/browser/views/uninstall_dialog.cc @@ -5,9 +5,9 @@ #include "chrome/browser/views/uninstall_dialog.h" #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "base/message_loop.h" #include "chrome/common/result_codes.h" -#include "chrome/common/message_box_flags.h" #include "chrome/views/controls/message_box_view.h" #include "chrome/views/window/window.h" #include "grit/chromium_strings.h" diff --git a/chrome/browser/views/user_data_dir_dialog.cc b/chrome/browser/views/user_data_dir_dialog.cc index c670ce8..7c30c85 100644 --- a/chrome/browser/views/user_data_dir_dialog.cc +++ b/chrome/browser/views/user_data_dir_dialog.cc @@ -3,9 +3,9 @@ // found in the LICENSE file. #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "base/logging.h" #include "chrome/browser/views/user_data_dir_dialog.h" -#include "chrome/common/message_box_flags.h" #include "chrome/views/controls/message_box_view.h" #include "chrome/views/widget/widget.h" #include "chrome/views/window/window.h" diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 0da07eb..cb98c55 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -127,6 +127,8 @@ # All .cc, .h, and .mm files under app/ except for tests. '../app/animation.cc', '../app/animation.h', + '../app/drag_drop_types.cc', + '../app/drag_drop_types.h', '../app/gfx/chrome_canvas.cc', '../app/gfx/chrome_canvas.h', '../app/gfx/chrome_canvas_linux.cc', @@ -136,11 +138,21 @@ '../app/gfx/chrome_font_mac.mm', '../app/gfx/chrome_font_skia.cc', '../app/gfx/chrome_font_win.cc', + '../app/gfx/favicon_size.h', + '../app/gfx/icon_util.cc', + '../app/gfx/icon_util.h', + '../app/gfx/insets.h', + '../app/gfx/path_gtk.cc', + '../app/gfx/path_win.cc', + '../app/gfx/path.h', '../app/l10n_util.cc', '../app/l10n_util.h', '../app/l10n_util_posix.cc', '../app/l10n_util_win.cc', '../app/l10n_util_win.h', + '../app/message_box_flags.h', + '../app/os_exchange_data.cc', + '../app/os_exchange_data.h', '../app/resource_bundle.cc', '../app/resource_bundle.h', '../app/resource_bundle_win.cc', @@ -162,6 +174,16 @@ '../build/linux/system.gyp:gtk', ], }], + ['OS!="win"', { + 'sources!': [ + '../app/drag_drop_types.cc', + '../app/drag_drop_types.h', + '../app/gfx/icon_util.cc', + '../app/gfx/icon_util.h', + '../app/os_exchange_data.cc', + '../app/os_exchange_data.h', + ], + }], ], }, { @@ -230,13 +252,6 @@ 'common/gfx/color_utils.h', 'common/gfx/emf.cc', 'common/gfx/emf.h', - 'common/gfx/favicon_size.h', - 'common/gfx/icon_util.cc', - 'common/gfx/icon_util.h', - 'common/gfx/insets.h', - 'common/gfx/path_gtk.cc', - 'common/gfx/path_win.cc', - 'common/gfx/path.h', 'common/gfx/text_elider.cc', 'common/gfx/text_elider.h', 'common/gfx/utils.h', @@ -287,8 +302,6 @@ 'common/debug_flags.h', 'common/devtools_messages.h', 'common/devtools_messages_internal.h', - 'common/drag_drop_types.cc', - 'common/drag_drop_types.h', 'common/env_vars.cc', 'common/env_vars.h', 'common/file_descriptor_set_posix.cc', @@ -324,7 +337,6 @@ 'common/logging_chrome.cc', 'common/logging_chrome.h', 'common/main_function_params.h', - 'common/message_box_flags.h', 'common/message_router.cc', 'common/message_router.h', 'common/modal_dialog_event.h', @@ -342,8 +354,6 @@ 'common/notification_service.h', 'common/notification_source.h', 'common/notification_type.h', - 'common/os_exchange_data.cc', - 'common/os_exchange_data.h', 'common/owned_widget_gtk.cc', 'common/owned_widget_gtk.h', 'common/page_action.h', @@ -449,10 +459,7 @@ }, { # else: OS != "win" 'sources!': [ 'common/gfx/emf.cc', - 'common/gfx/icon_util.cc', 'common/classfactory.cc', - 'common/drag_drop_types.cc', - 'common/os_exchange_data.cc', ], }], ], @@ -2498,7 +2505,7 @@ 'common/file_descriptor_set_unittest.cc', '../app/gfx/chrome_font_unittest.cc', 'common/gfx/emf_unittest.cc', - 'common/gfx/icon_util_unittest.cc', + '../app/gfx/icon_util_unittest.cc', 'common/gfx/text_elider_unittest.cc', 'common/important_file_writer_unittest.cc', 'common/ipc_message_unittest.cc', @@ -2510,7 +2517,7 @@ 'common/mru_cache_unittest.cc', 'common/net/url_util_unittest.cc', 'common/notification_service_unittest.cc', - 'common/os_exchange_data_unittest.cc', + '../app/os_exchange_data_unittest.cc', 'common/pref_member_unittest.cc', 'common/pref_service_unittest.cc', 'common/property_bag_unittest.cc', @@ -2627,9 +2634,9 @@ 'browser/window_sizer_unittest.cc', 'common/chrome_plugin_unittest.cc', 'common/gfx/emf_unittest.cc', - 'common/gfx/icon_util_unittest.cc', + '../app/gfx/icon_util_unittest.cc', 'common/net/url_util_unittest.cc', - 'common/os_exchange_data_unittest.cc', + '../app/os_exchange_data_unittest.cc', 'test/browser_with_test_window_test.cc', 'test/browser_with_test_window_test.h', 'views/controls/label_unittest.cc', diff --git a/chrome/common/common.vcproj b/chrome/common/common.vcproj index d359d59..839f6f2 100644 --- a/chrome/common/common.vcproj +++ b/chrome/common/common.vcproj @@ -165,22 +165,6 @@ > </File> <File - RelativePath=".\gfx\favicon_size.h" - > - </File> - <File - RelativePath=".\gfx\icon_util.cc" - > - </File> - <File - RelativePath=".\gfx\icon_util.h" - > - </File> - <File - RelativePath=".\gfx\insets.h" - > - </File> - <File RelativePath=".\gfx\path.h" > </File> @@ -466,14 +450,6 @@ > </File> <File - RelativePath=".\drag_drop_types.cc" - > - </File> - <File - RelativePath=".\drag_drop_types.h" - > - </File> - <File RelativePath=".\env_vars.cc" > </File> @@ -534,10 +510,6 @@ > </File> <File - RelativePath=".\message_box_flags.h" - > - </File> - <File RelativePath=".\message_router.cc" > </File> diff --git a/chrome/common/drag_drop_types.cc b/chrome/common/drag_drop_types.cc deleted file mode 100644 index 17e49a0..0000000 --- a/chrome/common/drag_drop_types.cc +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2006-2008 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/common/drag_drop_types.h" - -#include <oleidl.h> - -int DragDropTypes::DropEffectToDragOperation( - uint32 effect) { - int drag_operation = DRAG_NONE; - if (effect & DROPEFFECT_LINK) - drag_operation |= DRAG_LINK; - if (effect & DROPEFFECT_COPY) - drag_operation |= DRAG_COPY; - if (effect & DROPEFFECT_MOVE) - drag_operation |= DRAG_MOVE; - return drag_operation; -} - -uint32 DragDropTypes::DragOperationToDropEffect(int drag_operation) { - uint32 drop_effect = DROPEFFECT_NONE; - if (drag_operation & DRAG_LINK) - drop_effect |= DROPEFFECT_LINK; - if (drag_operation & DRAG_COPY) - drop_effect |= DROPEFFECT_COPY; - if (drag_operation & DRAG_MOVE) - drop_effect |= DROPEFFECT_MOVE; - return drop_effect; -} diff --git a/chrome/common/drag_drop_types.h b/chrome/common/drag_drop_types.h deleted file mode 100644 index ce2c73b..0000000 --- a/chrome/common/drag_drop_types.h +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2006-2008 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_COMMON_DRAG_DROP_TYPES_H_ -#define CHROME_COMMON_DRAG_DROP_TYPES_H_ - -#include "base/basictypes.h" - -class DragDropTypes { - public: - enum DragOperation { - DRAG_NONE = 0, - DRAG_MOVE = 1 << 0, - DRAG_COPY = 1 << 1, - DRAG_LINK = 1 << 2 - }; - - static uint32 DragOperationToDropEffect(int drag_operation); - static int DropEffectToDragOperation(uint32 effect); -}; - -#endif // CHROME_COMMON_DRAG_DROP_TYPES_H_ diff --git a/chrome/common/gfx/favicon_size.h b/chrome/common/gfx/favicon_size.h deleted file mode 100644 index bf805d3..0000000 --- a/chrome/common/gfx/favicon_size.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2006-2008 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_COMMON_GFX_FAVICON_SIZE_H__ -#define CHROME_COMMON_GFX_FAVICON_SIZE_H__ - -#include "base/compiler_specific.h" - -// Size (along each axis) of the favicon. -const int kFavIconSize = 16; - -// If the width or height is bigger than the favicon size, a new width/height -// is calculated and returned in width/height that maintains the aspect -// ratio of the supplied values. -static void calc_favicon_target_size(int* width, int* height) ALLOW_UNUSED; - -// static -void calc_favicon_target_size(int* width, int* height) { - if (*width > kFavIconSize || *height > kFavIconSize) { - // Too big, resize it maintaining the aspect ratio. - float aspect_ratio = static_cast<float>(*width) / - static_cast<float>(*height); - *height = kFavIconSize; - *width = static_cast<int>(aspect_ratio * *height); - if (*width > kFavIconSize) { - *width = kFavIconSize; - *height = static_cast<int>(*width / aspect_ratio); - } - } -} - -#endif // CHROME_COMMON_GFX_FAVICON_SIZE_H__ diff --git a/chrome/common/gfx/icon_util.cc b/chrome/common/gfx/icon_util.cc deleted file mode 100644 index 520faed..0000000 --- a/chrome/common/gfx/icon_util.cc +++ /dev/null @@ -1,476 +0,0 @@ -// Copyright (c) 2006-2008 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/common/gfx/icon_util.h" -#include "base/file_util.h" -#include "base/gfx/size.h" -#include "base/logging.h" -#include "chrome/common/win_util.h" -#include "skia/ext/image_operations.h" -#include "skia/include/SkBitmap.h" - -// Defining the dimensions for the icon images. We store only one value because -// we always resize to a square image; that is, the value 48 means that we are -// going to resize the given bitmap to a 48 by 48 pixels bitmap. -// -// The icon images appear in the icon file in same order in which their -// corresponding dimensions appear in the |icon_dimensions_| array, so it is -// important to keep this array sorted. Also note that the maximum icon image -// size we can handle is 255 by 255. -const int IconUtil::icon_dimensions_[] = { - 8, // Recommended by the MSDN as a nice to have icon size. - 10, // Used by the Shell (e.g. for shortcuts). - 14, // Recommended by the MSDN as a nice to have icon size. - 16, // Toolbar, Application and Shell icon sizes. - 22, // Recommended by the MSDN as a nice to have icon size. - 24, // Used by the Shell (e.g. for shortcuts). - 32, // Toolbar, Dialog and Wizard icon size. - 40, // Quick Launch. - 48, // Alt+Tab icon size. - 64, // Recommended by the MSDN as a nice to have icon size. - 96, // Recommended by the MSDN as a nice to have icon size. - 128 // Used by the Shell (e.g. for shortcuts). -}; - -HICON IconUtil::CreateHICONFromSkBitmap(const SkBitmap& bitmap) { - // Only 32 bit ARGB bitmaps are supported. We also try to perform as many - // validations as we can on the bitmap. - SkAutoLockPixels bitmap_lock(bitmap); - if ((bitmap.getConfig() != SkBitmap::kARGB_8888_Config) || - (bitmap.width() <= 0) || (bitmap.height() <= 0) || - (bitmap.getPixels() == NULL)) { - return NULL; - } - - // We start by creating a DIB which we'll use later on in order to create - // the HICON. We use BITMAPV5HEADER since the bitmap we are about to convert - // may contain an alpha channel and the V5 header allows us to specify the - // alpha mask for the DIB. - BITMAPV5HEADER bitmap_header; - InitializeBitmapHeader(&bitmap_header, bitmap.width(), bitmap.height()); - void* bits; - HDC hdc = ::GetDC(NULL); - HBITMAP dib; - dib = ::CreateDIBSection(hdc, reinterpret_cast<BITMAPINFO*>(&bitmap_header), - DIB_RGB_COLORS, &bits, NULL, 0); - DCHECK(dib); - ::ReleaseDC(NULL, hdc); - memcpy(bits, bitmap.getPixels(), bitmap.width() * bitmap.height() * 4); - - // Icons are generally created using an AND and XOR masks where the AND - // specifies boolean transparency (the pixel is either opaque or - // transparent) and the XOR mask contains the actual image pixels. However, - // since our bitmap has an alpha channel, the AND monochrome bitmap won't - // actually be used for computing the pixel transparency. Since every icon - // must have an AND mask bitmap, we go ahead and create one so that we can - // associate it with the ICONINFO structure we'll later pass to - // ::CreateIconIndirect(). The monochrome bitmap is created such that all the - // pixels are opaque. - HBITMAP mono_bitmap = ::CreateBitmap(bitmap.width(), bitmap.height(), - 1, 1, NULL); - DCHECK(mono_bitmap); - ICONINFO icon_info; - icon_info.fIcon = TRUE; - icon_info.xHotspot = 0; - icon_info.yHotspot = 0; - icon_info.hbmMask = mono_bitmap; - icon_info.hbmColor = dib; - HICON icon = ::CreateIconIndirect(&icon_info); - ::DeleteObject(dib); - ::DeleteObject(mono_bitmap); - return icon; -} - -SkBitmap* IconUtil::CreateSkBitmapFromHICON(HICON icon, const gfx::Size& s) { - // We start with validating parameters. - ICONINFO icon_info; - if (!icon || !(::GetIconInfo(icon, &icon_info)) || - !icon_info.fIcon || (s.width() <= 0) || (s.height() <= 0)) { - return NULL; - } - - // Allocating memory for the SkBitmap object. We are going to create an ARGB - // bitmap so we should set the configuration appropriately. - SkBitmap* bitmap = new SkBitmap; - DCHECK(bitmap); - bitmap->setConfig(SkBitmap::kARGB_8888_Config, s.width(), s.height()); - bitmap->allocPixels(); - SkAutoLockPixels bitmap_lock(*bitmap); - - // Now we should create a DIB so that we can use ::DrawIconEx in order to - // obtain the icon's image. - BITMAPV5HEADER h; - InitializeBitmapHeader(&h, s.width(), s.height()); - HDC dc = ::GetDC(NULL); - unsigned int* bits; - HBITMAP dib = ::CreateDIBSection(dc, - reinterpret_cast<BITMAPINFO*>(&h), - DIB_RGB_COLORS, - reinterpret_cast<void**>(&bits), - NULL, - 0); - DCHECK(dib); - HDC dib_dc = CreateCompatibleDC(dc); - DCHECK(dib_dc); - ::SelectObject(dib_dc, dib); - - // Windows icons are defined using two different masks. The XOR mask, which - // represents the icon image and an AND mask which is a monochrome bitmap - // which indicates the transparency of each pixel. - // - // To make things more complex, the icon image itself can be an ARGB bitmap - // and therefore contain an alpha channel which specifies the transparency - // for each pixel. Unfortunately, there is no easy way to determine whether - // or not a bitmap has an alpha channel and therefore constructing the bitmap - // for the icon is nothing but straightforward. - // - // The idea is to read the AND mask but use it only if we know for sure that - // the icon image does not have an alpha channel. The only way to tell if the - // bitmap has an alpha channel is by looking through the pixels and checking - // whether there are non-zero alpha bytes. - // - // We start by drawing the AND mask into our DIB. - memset(bits, 0, s.width() * s.height() * 4); - ::DrawIconEx(dib_dc, 0, 0, icon, s.width(), s.height(), 0, NULL, DI_MASK); - - // Capture boolean opacity. We may not use it if we find out the bitmap has - // an alpha channel. - bool* opaque = new bool[s.width() * s.height()]; - DCHECK(opaque); - int x, y; - for (y = 0; y < s.height(); ++y) { - for (x = 0; x < s.width(); ++x) - opaque[(y * s.width()) + x] = !bits[(y * s.width()) + x]; - } - - // Then draw the image itself which is really the XOR mask. - memset(bits, 0, s.width() * s.height() * 4); - ::DrawIconEx(dib_dc, 0, 0, icon, s.width(), s.height(), 0, NULL, DI_NORMAL); - memcpy(bitmap->getPixels(), - static_cast<void*>(bits), - s.width() * s.height() * 4); - - // Finding out whether the bitmap has an alpha channel. - bool bitmap_has_alpha_channel = false; - unsigned int* p = static_cast<unsigned int*>(bitmap->getPixels()); - for (y = 0; y < s.height(); ++y) { - for (x = 0; x < s.width(); ++x) { - if ((*p & 0xff000000) != 0) { - bitmap_has_alpha_channel = true; - break; - } - p++; - } - - if (bitmap_has_alpha_channel) { - break; - } - } - - // If the bitmap does not have an alpha channel, we need to build it using - // the previously captured AND mask. Otherwise, we are done. - if (!bitmap_has_alpha_channel) { - p = static_cast<unsigned int*>(bitmap->getPixels()); - for (y = 0; y < s.height(); ++y) { - for (x = 0; x < s.width(); ++x) { - DCHECK_EQ((*p & 0xff000000), 0); - if (opaque[(y * s.width()) + x]) { - *p |= 0xff000000; - } else { - *p &= 0x00ffffff; - } - p++; - } - } - } - - delete [] opaque; - ::DeleteDC(dib_dc); - ::DeleteObject(dib); - ::ReleaseDC(NULL, dc); - - return bitmap; -} - -bool IconUtil::CreateIconFileFromSkBitmap(const SkBitmap& bitmap, - const std::wstring& icon_file_name) { - // Only 32 bit ARGB bitmaps are supported. We also make sure the bitmap has - // been properly initialized. - SkAutoLockPixels bitmap_lock(bitmap); - if ((bitmap.getConfig() != SkBitmap::kARGB_8888_Config) || - (bitmap.height() <= 0) || (bitmap.width() <= 0) || - (bitmap.getPixels() == NULL)) { - return false; - } - - // We start by creating the file. - win_util::ScopedHandle icon_file(::CreateFile(icon_file_name.c_str(), - GENERIC_WRITE, - 0, - NULL, - CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, - NULL)); - - if (icon_file.Get() == INVALID_HANDLE_VALUE) { - return false; - } - - // Creating a set of bitmaps corresponding to the icon images we'll end up - // storing in the icon file. Each bitmap is created by resizing the given - // bitmap to the desired size. - std::vector<SkBitmap> bitmaps; - CreateResizedBitmapSet(bitmap, &bitmaps); - int bitmap_count = static_cast<int>(bitmaps.size()); - DCHECK_GT(bitmap_count, 0); - - // Computing the total size of the buffer we need in order to store the - // images in the desired icon format. - int buffer_size = ComputeIconFileBufferSize(bitmaps); - unsigned char* buffer = new unsigned char[buffer_size]; - DCHECK_NE(buffer, static_cast<unsigned char*>(NULL)); - memset(buffer, 0, buffer_size); - - // Setting the information in the structures residing within the buffer. - // First, we set the information which doesn't require iterating through the - // bitmap set and then we set the bitmap specific structures. In the latter - // step we also copy the actual bits. - ICONDIR* icon_dir = reinterpret_cast<ICONDIR*>(buffer); - icon_dir->idType = kResourceTypeIcon; - icon_dir->idCount = bitmap_count; - int icon_dir_count = bitmap_count - 1; - int offset = sizeof(ICONDIR) + (sizeof(ICONDIRENTRY) * icon_dir_count); - for (int i = 0; i < bitmap_count; i++) { - ICONIMAGE* image = reinterpret_cast<ICONIMAGE*>(buffer + offset); - DCHECK_LT(offset, buffer_size); - int icon_image_size = 0; - SetSingleIconImageInformation(bitmaps[i], - i, - icon_dir, - image, - offset, - &icon_image_size); - DCHECK_GT(icon_image_size, 0); - offset += icon_image_size; - } - DCHECK_EQ(offset, buffer_size); - - // Finally, writing the data info the file. - DWORD bytes_written; - bool delete_file = false; - if (!WriteFile(icon_file.Get(), buffer, buffer_size, &bytes_written, NULL) || - bytes_written != buffer_size) { - delete_file = true; - } - - ::CloseHandle(icon_file.Take()); - delete [] buffer; - if (delete_file) { - bool success = file_util::Delete(icon_file_name, false); - DCHECK(success); - } - - return !delete_file; -} - -int IconUtil::GetIconDimensionCount() { - return sizeof(icon_dimensions_) / sizeof(icon_dimensions_[0]); -} - -void IconUtil::InitializeBitmapHeader(BITMAPV5HEADER* header, int width, - int height) { - DCHECK(header); - memset(header, 0, sizeof(BITMAPV5HEADER)); - header->bV5Size = sizeof(BITMAPV5HEADER); - - // Note that icons are created using top-down DIBs so we must negate the - // value used for the icon's height. - header->bV5Width = width; - header->bV5Height = -height; - header->bV5Planes = 1; - header->bV5Compression = BI_RGB; - - // Initializing the bitmap format to 32 bit ARGB. - header->bV5BitCount = 32; - header->bV5RedMask = 0x00FF0000; - header->bV5GreenMask = 0x0000FF00; - header->bV5BlueMask = 0x000000FF; - header->bV5AlphaMask = 0xFF000000; - - // Use the system color space. The default value is LCS_CALIBRATED_RGB, which - // causes us to crash if we don't specify the approprite gammas, etc. See - // <http://msdn.microsoft.com/en-us/library/ms536531(VS.85).aspx> and - // <http://b/1283121>. - header->bV5CSType = LCS_WINDOWS_COLOR_SPACE; -} - -void IconUtil::SetSingleIconImageInformation(const SkBitmap& bitmap, - int index, - ICONDIR* icon_dir, - ICONIMAGE* icon_image, - int image_offset, - int* image_byte_count) { - DCHECK_GE(index, 0); - DCHECK_NE(icon_dir, static_cast<ICONDIR*>(NULL)); - DCHECK_NE(icon_image, static_cast<ICONIMAGE*>(NULL)); - DCHECK_GT(image_offset, 0); - DCHECK_NE(image_byte_count, static_cast<int*>(NULL)); - - // We start by computing certain image values we'll use later on. - int xor_mask_size; - int and_mask_size; - int bytes_in_resource; - ComputeBitmapSizeComponents(bitmap, - &xor_mask_size, - &and_mask_size, - &bytes_in_resource); - - icon_dir->idEntries[index].bWidth = static_cast<BYTE>(bitmap.width()); - icon_dir->idEntries[index].bHeight = static_cast<BYTE>(bitmap.height()); - icon_dir->idEntries[index].wPlanes = 1; - icon_dir->idEntries[index].wBitCount = 32; - icon_dir->idEntries[index].dwBytesInRes = bytes_in_resource; - icon_dir->idEntries[index].dwImageOffset = image_offset; - icon_image->icHeader.biSize = sizeof(BITMAPINFOHEADER); - - // The width field in the BITMAPINFOHEADER structure accounts for the height - // of both the AND mask and the XOR mask so we need to multiply the bitmap's - // height by 2. The same does NOT apply to the width field. - icon_image->icHeader.biHeight = bitmap.height() * 2; - icon_image->icHeader.biWidth = bitmap.width(); - icon_image->icHeader.biPlanes = 1; - icon_image->icHeader.biBitCount = 32; - - // We use a helper function for copying to actual bits from the SkBitmap - // object into the appropriate space in the buffer. We use a helper function - // (rather than just copying the bits) because there is no way to specify the - // orientation (bottom-up vs. top-down) of a bitmap residing in a .ico file. - // Thus, if we just copy the bits, we'll end up with a bottom up bitmap in - // the .ico file which will result in the icon being displayed upside down. - // The helper function copies the image into the buffer one scanline at a - // time. - // - // Note that we don't need to initialize the AND mask since the memory - // allocated for the icon data buffer was initialized to zero. The icon we - // create will therefore use an AND mask containing only zeros, which is OK - // because the underlying image has an alpha channel. An AND mask containing - // only zeros essentially means we'll initially treat all the pixels as - // opaque. - unsigned char* image_addr = reinterpret_cast<unsigned char*>(icon_image); - unsigned char* xor_mask_addr = image_addr + sizeof(BITMAPINFOHEADER); - CopySkBitmapBitsIntoIconBuffer(bitmap, xor_mask_addr, xor_mask_size); - *image_byte_count = bytes_in_resource; -} - -void IconUtil::CopySkBitmapBitsIntoIconBuffer(const SkBitmap& bitmap, - unsigned char* buffer, - int buffer_size) { - SkAutoLockPixels bitmap_lock(bitmap); - unsigned char* bitmap_ptr = static_cast<unsigned char*>(bitmap.getPixels()); - int bitmap_size = bitmap.height() * bitmap.width() * 4; - DCHECK_EQ(buffer_size, bitmap_size); - for (int i = 0; i < bitmap_size; i += bitmap.width() * 4) { - memcpy(buffer + bitmap_size - bitmap.width() * 4 - i, - bitmap_ptr + i, - bitmap.width() * 4); - } -} - -void IconUtil::CreateResizedBitmapSet(const SkBitmap& bitmap_to_resize, - std::vector<SkBitmap>* bitmaps) { - DCHECK_NE(bitmaps, static_cast<std::vector<SkBitmap>* >(NULL)); - DCHECK_EQ(static_cast<int>(bitmaps->size()), 0); - - bool inserted_original_bitmap = false; - for (int i = 0; i < GetIconDimensionCount(); i++) { - // If the dimensions of the bitmap we are resizing are the same as the - // current dimensions, then we should insert the bitmap and not a resized - // bitmap. If the bitmap's dimensions are smaller, we insert our bitmap - // first so that the bitmaps we return in the vector are sorted based on - // their dimensions. - if (!inserted_original_bitmap) { - if ((bitmap_to_resize.width() == icon_dimensions_[i]) && - (bitmap_to_resize.height() == icon_dimensions_[i])) { - bitmaps->push_back(bitmap_to_resize); - inserted_original_bitmap = true; - continue; - } - - if ((bitmap_to_resize.width() < icon_dimensions_[i]) && - (bitmap_to_resize.height() < icon_dimensions_[i])) { - bitmaps->push_back(bitmap_to_resize); - inserted_original_bitmap = true; - } - } - bitmaps->push_back(skia::ImageOperations::Resize( - bitmap_to_resize, skia::ImageOperations::RESIZE_LANCZOS3, - icon_dimensions_[i], icon_dimensions_[i])); - } - - if (!inserted_original_bitmap) { - bitmaps->push_back(bitmap_to_resize); - } -} - -int IconUtil::ComputeIconFileBufferSize(const std::vector<SkBitmap>& set) { - // We start by counting the bytes for the structures that don't depend on the - // number of icon images. Note that sizeof(ICONDIR) already accounts for a - // single ICONDIRENTRY structure, which is why we subtract one from the - // number of bitmaps. - int total_buffer_size = 0; - total_buffer_size += sizeof(ICONDIR); - int bitmap_count = static_cast<int>(set.size()); - total_buffer_size += sizeof(ICONDIRENTRY) * (bitmap_count - 1); - int dimension_count = GetIconDimensionCount(); - DCHECK_GE(bitmap_count, dimension_count); - - // Add the bitmap specific structure sizes. - for (int i = 0; i < bitmap_count; i++) { - int xor_mask_size; - int and_mask_size; - int bytes_in_resource; - ComputeBitmapSizeComponents(set[i], - &xor_mask_size, - &and_mask_size, - &bytes_in_resource); - total_buffer_size += bytes_in_resource; - } - return total_buffer_size; -} - -void IconUtil::ComputeBitmapSizeComponents(const SkBitmap& bitmap, - int* xor_mask_size, - int* and_mask_size, - int* bytes_in_resource) { - // The XOR mask size is easy to calculate since we only deal with 32bpp - // images. - *xor_mask_size = bitmap.width() * bitmap.height() * 4; - - // Computing the AND mask is a little trickier since it is a monochrome - // bitmap (regardless of the number of bits per pixels used in the XOR mask). - // There are two things we must make sure we do when computing the AND mask - // size: - // - // 1. Make sure the right number of bytes is allocated for each AND mask - // scan line in case the number of pixels in the image is not divisible by - // 8. For example, in a 15X15 image, 15 / 8 is one byte short of - // containing the number of bits we need in order to describe a single - // image scan line so we need to add a byte. Thus, we need 2 bytes instead - // of 1 for each scan line. - // - // 2. Make sure each scan line in the AND mask is 4 byte aligned (so that the - // total icon image has a 4 byte alignment). In the 15X15 image example - // above, we can not use 2 bytes so we increase it to the next multiple of - // 4 which is 4. - // - // Once we compute the size for a singe AND mask scan line, we multiply that - // number by the image height in order to get the total number of bytes for - // the AND mask. Thus, for a 15X15 image, we need 15 * 4 which is 60 bytes - // for the monochrome bitmap representing the AND mask. - int and_line_length = (bitmap.width() + 7) >> 3; - and_line_length = (and_line_length + 3) & ~3; - *and_mask_size = and_line_length * bitmap.height(); - int masks_size = *xor_mask_size + *and_mask_size; - *bytes_in_resource = masks_size + sizeof(BITMAPINFOHEADER); -} diff --git a/chrome/common/gfx/icon_util.h b/chrome/common/gfx/icon_util.h deleted file mode 100644 index 9066df9..0000000 --- a/chrome/common/gfx/icon_util.h +++ /dev/null @@ -1,193 +0,0 @@ -// Copyright (c) 2006-2008 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_COMMON_ICON_UTIL_H__ -#define CHROME_COMMON_ICON_UTIL_H__ - -#include <windows.h> -#include <string> -#include <vector> -#include "base/basictypes.h" - -namespace gfx { - class Size; -} -class SkBitmap; - -/////////////////////////////////////////////////////////////////////////////// -// -// The IconUtil class contains helper functions for manipulating Windows icons. -// The class interface contains methods for converting an HICON handle into an -// SkBitmap object and vice versa. The class can also create a .ico file given -// a PNG image contained in an SkBitmap object. The following code snippet -// shows an example usage of IconUtil::CreateHICONFromSkBitmap(): -// -// SkBitmap bitmap; -// -// // Fill |bitmap| with valid data -// bitmap.setConfig(...); -// bitmap.allocPixels(); -// -// ... -// -// // Convert the bitmap into a Windows HICON -// HICON icon = IconUtil::CreateHICONFromSkBitmap(bitmap); -// if (icon == NULL) { -// // Handle error -// ... -// } -// -// // Use the icon with a WM_SETICON message -// ::SendMessage(hwnd, WM_SETICON, static_cast<WPARAM>(ICON_BIG), -// reinterpret_cast<LPARAM>(icon)); -// -// // Destroy the icon when we are done -// ::DestroyIcon(icon); -// -/////////////////////////////////////////////////////////////////////////////// -class IconUtil { - public: - // Given an SkBitmap object, the function converts the bitmap to a Windows - // icon and returns the corresponding HICON handle. If the function can not - // convert the bitmap, NULL is returned. - // - // The client is responsible for destroying the icon when it is no longer - // needed by calling ::DestroyIcon(). - static HICON CreateHICONFromSkBitmap(const SkBitmap& bitmap); - - // Given a valid HICON handle representing an icon, this function converts - // the icon into an SkBitmap object containing an ARGB bitmap using the - // dimensions specified in |s|. |s| must specify valid dimensions (both - // width() an height() must be greater than zero). If the function can - // convert the icon to a bitmap (most probably due to an invalid parameter), - // the return value is NULL. - // - // The client owns the returned bitmap object and is responsible for deleting - // it when it is no longer needed. - static SkBitmap* CreateSkBitmapFromHICON(HICON icon, const gfx::Size& s); - - // Given an initialized SkBitmap object and a file name, this function - // creates a .ico file with the given name using the provided bitmap. The - // icon file is created with multiple icon images of varying predefined - // dimensions because Windows uses different image sizes when loading icons, - // depending on where the icon is drawn (ALT+TAB window, desktop shortcut, - // Quick Launch, etc.). |icon_file_name| needs to specify the full path for - // the desired .ico file. - // - // The function returns true on success and false otherwise. - static bool CreateIconFileFromSkBitmap(const SkBitmap& bitmap, - const std::wstring& icon_file_name); - - private: - // The icon format is published in the MSDN but there is no definition of - // the icon file structures in any of the Windows header files so we need to - // define these structure within the class. We must make sure we use 2 byte - // packing so that the structures are layed out properly within the file. -#pragma pack(push) -#pragma pack(2) - - // ICONDIRENTRY contains meta data for an individual icon image within a - // .ico file. - struct ICONDIRENTRY { - BYTE bWidth; - BYTE bHeight; - BYTE bColorCount; - BYTE bReserved; - WORD wPlanes; - WORD wBitCount; - DWORD dwBytesInRes; - DWORD dwImageOffset; - }; - - // ICONDIR Contains information about all the icon images contained within a - // single .ico file. - struct ICONDIR { - WORD idReserved; - WORD idType; - WORD idCount; - ICONDIRENTRY idEntries[1]; - }; - - // Contains the actual icon image. - struct ICONIMAGE { - BITMAPINFOHEADER icHeader; - RGBQUAD icColors[1]; - BYTE icXOR[1]; - BYTE icAND[1]; - }; -#pragma pack(pop) - - // Used for indicating that the .ico contains an icon (rather than a cursor) - // image. This value is set in the |idType| field of the ICONDIR structure. - static const int kResourceTypeIcon = 1; - - // The dimensions of the icon images we insert into the .ico file. - static const int icon_dimensions_[]; - - // Returns how many icon dimensions are defined. - static int GetIconDimensionCount(); - - // A helper function that initializes a BITMAPV5HEADER structure with a set - // of values. - static void InitializeBitmapHeader(BITMAPV5HEADER* header, int width, - int height); - - // Given a single SkBitmap object and pointers to the corresponding icon - // structures within the icon data buffer, this function sets the image - // information (dimensions, color depth, etc.) in the icon structures and - // also copies the underlying icon image into the appropriate location. - // - // The function will set the data pointed to by |image_byte_count| with the - // number of image bytes written to the buffer. Note that the number of bytes - // includes only the image data written into the memory pointed to by - // |icon_image|. - static void SetSingleIconImageInformation(const SkBitmap& bitmap, - int index, - ICONDIR* icon_dir, - ICONIMAGE* icon_image, - int image_offset, - int* image_byte_count); - - // Copies the bits of an SkBitmap object into a buffer holding the bits of - // the corresponding image for an icon within the .ico file. - static void CopySkBitmapBitsIntoIconBuffer(const SkBitmap& bitmap, - unsigned char* buffer, - int buffer_size); - - // Given a single bitmap, this function creates a set of bitmaps with - // specific dimensions by resizing the given bitmap to the appropriate sizes. - static void CreateResizedBitmapSet(const SkBitmap& bitmap_to_resize, - std::vector<SkBitmap>* bitmaps); - - // Given a set of bitmaps with varying dimensions, this function computes - // the amount of memory needed in order to store the bitmaps as image icons - // in a .ico file. - static int ComputeIconFileBufferSize(const std::vector<SkBitmap>& set); - - // A helper function for computing various size components of a given bitmap. - // The different sizes can be used within the various .ico file structures. - // - // |xor_mask_size| - the size, in bytes, of the XOR mask in the ICONIMAGE - // structure. - // |and_mask_size| - the size, in bytes, of the AND mask in the ICONIMAGE - // structure. - // |bytes_in_resource| - the total number of bytes set in the ICONIMAGE - // structure. This value is equal to the sum of the - // bytes in the AND mask and the XOR mask plus the size - // of the BITMAPINFOHEADER structure. Note that since - // only 32bpp are handled by the IconUtil class, the - // icColors field in the ICONIMAGE structure is ignored - // and is not accounted for when computing the - // different size components. - static void ComputeBitmapSizeComponents(const SkBitmap& bitmap, - int* xor_mask_size, - int* and_mask_size, - int* bytes_in_resource); - - // Prevent clients from instantiating objects of that class by declaring the - // ctor/dtor as private. - DISALLOW_IMPLICIT_CONSTRUCTORS(IconUtil); -}; - -#endif // CHROME_COMMON_ICON_UTIL_H__ diff --git a/chrome/common/gfx/icon_util_unittest.cc b/chrome/common/gfx/icon_util_unittest.cc deleted file mode 100644 index 116589d..0000000 --- a/chrome/common/gfx/icon_util_unittest.cc +++ /dev/null @@ -1,264 +0,0 @@ -// Copyright (c) 2006-2008 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 <atlbase.h> -#include <atlapp.h> -#include <atlmisc.h> - -#include "chrome/common/gfx/icon_util.h" -#include "base/gfx/size.h" -#include "base/scoped_ptr.h" -#include "base/file_util.h" -#include "base/path_service.h" -#include "chrome/common/chrome_paths.h" -#include "skia/include/SkBitmap.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace { - - static const wchar_t* const kSmallIconName = L"icon_util\\16_X_16_icon.ico"; - static const wchar_t* const kLargeIconName = L"icon_util\\128_X_128_icon.ico"; - static const wchar_t* const kTempIconFilename = L"temp_test_icon.ico"; - - class IconUtilTest : public testing::Test { - public: - IconUtilTest() { - PathService::Get(chrome::DIR_TEST_DATA, &test_data_directory_); - } - ~IconUtilTest() {} - - static const int kSmallIconWidth = 16; - static const int kSmallIconHeight = 16; - static const int kLargeIconWidth = 128; - static const int kLargeIconHeight = 128; - - // Given a file name for an .ico file and an image dimentions, this - // function loads the icon and returns an HICON handle. - HICON LoadIconFromFile(const std::wstring& filename, - int width, - int height) { - HICON icon = - static_cast<HICON>(LoadImage(NULL, - filename.c_str(), - IMAGE_ICON, - width, - height, - LR_LOADTRANSPARENT | LR_LOADFROMFILE)); - return icon; - } - - protected: - // The root directory for test files. - std::wstring test_data_directory_; - - private: - DISALLOW_EVIL_CONSTRUCTORS(IconUtilTest); - }; -}; - -// The following test case makes sure IconUtil::SkBitmapFromHICON fails -// gracefully when called with invalid input parameters. -TEST_F(IconUtilTest, TestIconToBitmapInvalidParameters) { - std::wstring icon_filename(test_data_directory_); - file_util::AppendToPath(&icon_filename, kSmallIconName); - gfx::Size icon_size(kSmallIconWidth, kSmallIconHeight); - HICON icon = LoadIconFromFile(icon_filename, - icon_size.width(), - icon_size.height()); - ASSERT_TRUE(icon != NULL); - - // Invalid size parameter. - gfx::Size invalid_icon_size(kSmallIconHeight, 0); - EXPECT_EQ(IconUtil::CreateSkBitmapFromHICON(icon, invalid_icon_size), - static_cast<SkBitmap*>(NULL)); - - // Invalid icon. - EXPECT_EQ(IconUtil::CreateSkBitmapFromHICON(NULL, icon_size), - static_cast<SkBitmap*>(NULL)); - - // The following code should succeed. - scoped_ptr<SkBitmap> bitmap; - bitmap.reset(IconUtil::CreateSkBitmapFromHICON(icon, icon_size)); - EXPECT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL)); - ::DestroyIcon(icon); -} - -// The following test case makes sure IconUtil::CreateHICONFromSkBitmap fails -// gracefully when called with invalid input parameters. -TEST_F(IconUtilTest, TestBitmapToIconInvalidParameters) { - HICON icon = NULL; - scoped_ptr<SkBitmap> bitmap; - - // Wrong bitmap format. - bitmap.reset(new SkBitmap); - ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL)); - bitmap->setConfig(SkBitmap::kA8_Config, kSmallIconWidth, kSmallIconHeight); - icon = IconUtil::CreateHICONFromSkBitmap(*bitmap); - EXPECT_EQ(icon, static_cast<HICON>(NULL)); - - // Invalid bitmap size. - bitmap.reset(new SkBitmap); - ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL)); - bitmap->setConfig(SkBitmap::kARGB_8888_Config, 0, 0); - icon = IconUtil::CreateHICONFromSkBitmap(*bitmap); - EXPECT_EQ(icon, static_cast<HICON>(NULL)); - - // Valid bitmap configuration but no pixels allocated. - bitmap.reset(new SkBitmap); - ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL)); - bitmap->setConfig(SkBitmap::kARGB_8888_Config, - kSmallIconWidth, - kSmallIconHeight); - icon = IconUtil::CreateHICONFromSkBitmap(*bitmap); - EXPECT_TRUE(icon == NULL); -} - -// The following test case makes sure IconUtil::CreateIconFileFromSkBitmap -// fails gracefully when called with invalid input parameters. -TEST_F(IconUtilTest, TestCreateIconFileInvalidParameters) { - scoped_ptr<SkBitmap> bitmap; - std::wstring valid_icon_filename(test_data_directory_); - file_util::AppendToPath(&valid_icon_filename, kSmallIconName); - std::wstring invalid_icon_filename(L"C:\\<>?.ico"); - - // Wrong bitmap format. - bitmap.reset(new SkBitmap); - ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL)); - bitmap->setConfig(SkBitmap::kA8_Config, kSmallIconWidth, kSmallIconHeight); - EXPECT_FALSE(IconUtil::CreateIconFileFromSkBitmap(*bitmap, - valid_icon_filename)); - - // Invalid bitmap size. - bitmap.reset(new SkBitmap); - ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL)); - bitmap->setConfig(SkBitmap::kARGB_8888_Config, 0, 0); - EXPECT_FALSE(IconUtil::CreateIconFileFromSkBitmap(*bitmap, - valid_icon_filename)); - - // Bitmap with no allocated pixels. - bitmap.reset(new SkBitmap); - ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL)); - bitmap->setConfig(SkBitmap::kARGB_8888_Config, - kSmallIconWidth, - kSmallIconHeight); - EXPECT_FALSE(IconUtil::CreateIconFileFromSkBitmap(*bitmap, - valid_icon_filename)); - - // Invalid file name. - bitmap->allocPixels(); - // Setting the pixels to black. - memset(bitmap->getPixels(), 0, bitmap->width() * bitmap->height() * 4); - EXPECT_FALSE(IconUtil::CreateIconFileFromSkBitmap(*bitmap, - invalid_icon_filename)); -} - -// This test case makes sure that when we load an icon from disk and convert -// the HICON into a bitmap, the bitmap has the expected format and dimentions. -TEST_F(IconUtilTest, TestCreateSkBitmapFromHICON) { - scoped_ptr<SkBitmap> bitmap; - std::wstring small_icon_filename(test_data_directory_); - file_util::AppendToPath(&small_icon_filename, kSmallIconName); - gfx::Size small_icon_size(kSmallIconWidth, kSmallIconHeight); - HICON small_icon = LoadIconFromFile(small_icon_filename, - small_icon_size.width(), - small_icon_size.height()); - ASSERT_NE(small_icon, static_cast<HICON>(NULL)); - bitmap.reset(IconUtil::CreateSkBitmapFromHICON(small_icon, small_icon_size)); - ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL)); - EXPECT_EQ(bitmap->width(), small_icon_size.width()); - EXPECT_EQ(bitmap->height(), small_icon_size.height()); - EXPECT_EQ(bitmap->config(), SkBitmap::kARGB_8888_Config); - ::DestroyIcon(small_icon); - - std::wstring large_icon_filename(test_data_directory_); - file_util::AppendToPath(&large_icon_filename, kLargeIconName); - gfx::Size large_icon_size(kLargeIconWidth, kLargeIconHeight); - HICON large_icon = LoadIconFromFile(large_icon_filename, - large_icon_size.width(), - large_icon_size.height()); - ASSERT_NE(large_icon, static_cast<HICON>(NULL)); - bitmap.reset(IconUtil::CreateSkBitmapFromHICON(large_icon, large_icon_size)); - ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL)); - EXPECT_EQ(bitmap->width(), large_icon_size.width()); - EXPECT_EQ(bitmap->height(), large_icon_size.height()); - EXPECT_EQ(bitmap->config(), SkBitmap::kARGB_8888_Config); - ::DestroyIcon(large_icon); -} - -// This test case makes sure that when an HICON is created from an SkBitmap, -// the returned handle is valid and refers to an icon with the expected -// dimentions color depth etc. -TEST_F(IconUtilTest, TestBasicCreateHICONFromSkBitmap) { - scoped_ptr<SkBitmap> bitmap; - bitmap.reset(new SkBitmap); - ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL)); - bitmap->setConfig(SkBitmap::kARGB_8888_Config, - kSmallIconWidth, - kSmallIconHeight); - bitmap->allocPixels(); - HICON icon = IconUtil::CreateHICONFromSkBitmap(*bitmap); - EXPECT_NE(icon, static_cast<HICON>(NULL)); - ICONINFO icon_info; - ASSERT_TRUE(::GetIconInfo(icon, &icon_info)); - EXPECT_TRUE(icon_info.fIcon); - - // Now that have the icon information, we should obtain the specification of - // the icon's bitmap and make sure it matches the specification of the - // SkBitmap we started with. - // - // The bitmap handle contained in the icon information is a handle to a - // compatible bitmap so we need to call ::GetDIBits() in order to retrieve - // the bitmap's header information. - BITMAPINFO bitmap_info; - ::ZeroMemory(&bitmap_info, sizeof(BITMAPINFO)); - bitmap_info.bmiHeader.biSize = sizeof(BITMAPINFO); - HDC hdc = ::GetDC(NULL); - int result = ::GetDIBits(hdc, - icon_info.hbmColor, - 0, - kSmallIconWidth, - NULL, - &bitmap_info, - DIB_RGB_COLORS); - ASSERT_GT(result, 0); - EXPECT_EQ(bitmap_info.bmiHeader.biWidth, kSmallIconWidth); - EXPECT_EQ(bitmap_info.bmiHeader.biHeight, kSmallIconHeight); - EXPECT_EQ(bitmap_info.bmiHeader.biPlanes, 1); - EXPECT_EQ(bitmap_info.bmiHeader.biBitCount, 32); - ::ReleaseDC(NULL, hdc); - ::DestroyIcon(icon); -} - -// The following test case makes sure IconUtil::CreateIconFileFromSkBitmap -// creates a valid .ico file given an SkBitmap. -TEST_F(IconUtilTest, TestCreateIconFile) { - scoped_ptr<SkBitmap> bitmap; - std::wstring icon_filename(test_data_directory_); - file_util::AppendToPath(&icon_filename, kTempIconFilename); - - // Allocating the bitmap. - bitmap.reset(new SkBitmap); - ASSERT_NE(bitmap.get(), static_cast<SkBitmap*>(NULL)); - bitmap->setConfig(SkBitmap::kARGB_8888_Config, - kSmallIconWidth, - kSmallIconHeight); - bitmap->allocPixels(); - - // Setting the pixels to black. - memset(bitmap->getPixels(), 0, bitmap->width() * bitmap->height() * 4); - - EXPECT_TRUE(IconUtil::CreateIconFileFromSkBitmap(*bitmap, - icon_filename)); - - // We are currently only testing that it is possible to load an icon from - // the .ico file we just created. We don't really check the additional icon - // images created by IconUtil::CreateIconFileFromSkBitmap. - HICON icon = LoadIconFromFile(icon_filename, - kSmallIconWidth, - kSmallIconHeight); - EXPECT_NE(icon, static_cast<HICON>(NULL)); - if (icon != NULL) { - ::DestroyIcon(icon); - } -} diff --git a/chrome/common/gfx/insets.h b/chrome/common/gfx/insets.h deleted file mode 100644 index 741de3a2..0000000 --- a/chrome/common/gfx/insets.h +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (c) 2006-2008 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_COMMON_GFX_INSETS_H__ -#define CHROME_COMMON_GFX_INSETS_H__ - -namespace gfx { - -// -// An insets represents the borders of a container (the space the container must -// leave at each of its edges). -// - -class Insets { - public: - Insets() : top_(0), left_(0), bottom_(0), right_(0) {} - Insets(int top, int left, int bottom, int right) - : top_(top), left_(left), bottom_(bottom), right_(right) { } - - ~Insets() {} - - int top() const { return top_; } - int left() const { return left_; } - int bottom() const { return bottom_; } - int right() const { return right_; } - - // Returns the total width taken up by the insets, which is the sum of the - // left and right insets. - int width() const { return left_ + right_; } - - // Returns the total height taken up by the insets, which is the sum of the - // top and bottom insets. - int height() const { return top_ + bottom_; } - - void Set(int top, int left, int bottom, int right) { - top_ = top; - left_ = left; - bottom_ = bottom; - right_ = right; - } - - bool operator==(const Insets& insets) const { - return top_ == insets.top_ && left_ == insets.left_ && - bottom_ == insets.bottom_ && right_ == insets.right_; - } - - bool operator!=(const Insets& insets) const { - return !(*this == insets); - } - - Insets& operator+=(const Insets& insets) { - top_ += insets.top_; - left_ += insets.left_; - bottom_ += insets.bottom_; - right_ += insets.right_; - return *this; - } - - private: - int top_; - int left_; - int bottom_; - int right_; -}; - -} // namespace - -#endif // CHROME_COMMON_GFX_INSETS_H__ diff --git a/chrome/common/gfx/path.h b/chrome/common/gfx/path.h deleted file mode 100644 index ac7537c..0000000 --- a/chrome/common/gfx/path.h +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) 2009 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_COMMON_GFX_CHROME_PATH_H_ -#define CHROME_COMMON_GFX_CHROME_PATH_H_ - -#include "base/basictypes.h" - -#if defined(OS_WIN) -#include <windows.h> -#elif defined(OS_LINUX) -typedef struct _GdkRegion GdkRegion; -#endif - -#include "SkPath.h" - -namespace gfx { - -class Path : public SkPath { - public: - Path() : SkPath() { moveTo(0, 0); } - -#if defined(OS_WIN) - // Creates a HRGN from the path. The caller is responsible for freeing - // resources used by this region. This only supports polygon paths. - HRGN CreateHRGN() const; -#elif defined(OS_LINUX) - // Creates a Gdkregion from the path. The caller is responsible for freeing - // resources used by this region. This only supports polygon paths. - GdkRegion* CreateGdkRegion() const; -#endif - - private: - DISALLOW_COPY_AND_ASSIGN(Path); -}; - -} - -#endif // #ifndef CHROME_COMMON_GFX_CHROME_PATH_H_ diff --git a/chrome/common/gfx/path_gtk.cc b/chrome/common/gfx/path_gtk.cc deleted file mode 100644 index aeab76f..0000000 --- a/chrome/common/gfx/path_gtk.cc +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (c) 2006-2008 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/common/gfx/path.h" - -#include <gdk/gdk.h> - -#include "base/scoped_ptr.h" - -namespace gfx { - -GdkRegion* Path::CreateGdkRegion() const { - int point_count = getPoints(NULL, 0); - scoped_array<SkPoint> points(new SkPoint[point_count]); - getPoints(points.get(), point_count); - - scoped_array<GdkPoint> gdk_points(new GdkPoint[point_count]); - for (int i = 0; i < point_count; ++i) { - gdk_points[i].x = SkScalarRound(points[i].fX); - gdk_points[i].y = SkScalarRound(points[i].fY); - } - - return gdk_region_polygon(gdk_points.get(), point_count, GDK_EVEN_ODD_RULE); -} - -} // namespace gfx diff --git a/chrome/common/gfx/path_win.cc b/chrome/common/gfx/path_win.cc deleted file mode 100644 index aa2fe02..0000000 --- a/chrome/common/gfx/path_win.cc +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) 2006-2008 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/common/gfx/path.h" - -#include "base/scoped_ptr.h" - -namespace gfx { - -HRGN Path::CreateHRGN() const { - int point_count = getPoints(NULL, 0); - scoped_array<SkPoint> points(new SkPoint[point_count]); - getPoints(points.get(), point_count); - scoped_array<POINT> windows_points(new POINT[point_count]); - for (int i = 0; i < point_count; ++i) { - windows_points[i].x = SkScalarRound(points[i].fX); - windows_points[i].y = SkScalarRound(points[i].fY); - } - - return ::CreatePolygonRgn(windows_points.get(), point_count, ALTERNATE); -} - -} // namespace gfx diff --git a/chrome/common/message_box_flags.h b/chrome/common/message_box_flags.h deleted file mode 100644 index 8520c56..0000000 --- a/chrome/common/message_box_flags.h +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) 2009 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_COMMON_MESSAGE_BOX_FLAGS_H_ -#define CHROME_COMMON_MESSAGE_BOX_FLAGS_H_ - -#include "base/basictypes.h" - -// This class contains flags used to communicate the type of message box -// to show. E.g., the renderer can request the browser to show a -// javascript alert or a javascript confirm message. -class MessageBoxFlags { - public: - static const int kFlagHasOKButton = 0x1; - static const int kFlagHasCancelButton = 0x2; - static const int kFlagHasPromptField = 0x4; - static const int kFlagHasMessage = 0x8; - - // The following flag is used to indicate whether the message's alignment - // should be autodetected or inherited from Chrome UI. Callers should pass - // the correct flag based on the origin of the message. If the message is - // from a web page (such as the JavaScript alert message), its alignment and - // directionality are based on the first character with strong directionality - // in the message. Chrome UI strings are localized string and therefore they - // should have the same alignment and directionality as those of the Chrome - // UI. For example, in RTL locales, even though some strings might begin with - // an English character, they should still be right aligned and be displayed - // Right-To-Left. - // - // TODO(xji): If the message is from a web page, then the message - // directionality should be determined based on the directionality of the web - // page. Please refer to http://crbug.com/7166 for more information. - static const int kAutoDetectAlignment = 0x10; - - static const int kIsConfirmMessageBox = kFlagHasMessage | - kFlagHasOKButton | - kFlagHasCancelButton; - static const int kIsJavascriptAlert = kFlagHasOKButton | kFlagHasMessage; - static const int kIsJavascriptConfirm = kIsJavascriptAlert | - kFlagHasCancelButton; - static const int kIsJavascriptPrompt = kIsJavascriptConfirm | - kFlagHasPromptField; - - // Dialog button identifiers used to specify which buttons to show the user. - enum DialogButton { - DIALOGBUTTON_NONE = 0, // No dialog buttons, for WindowType == WINDOW. - DIALOGBUTTON_OK = 1, // Has an OK button. - DIALOGBUTTON_CANCEL = 2, // Has a Cancel button (becomes a Close button if - }; // no OK button). - - private: - MessageBoxFlags() {} - DISALLOW_COPY_AND_ASSIGN(MessageBoxFlags); -}; - -#endif // CHROME_COMMON_MESSAGE_BOX_FLAGS_H_ diff --git a/chrome/common/os_exchange_data.cc b/chrome/common/os_exchange_data.cc deleted file mode 100644 index 969724f..0000000 --- a/chrome/common/os_exchange_data.cc +++ /dev/null @@ -1,707 +0,0 @@ -// Copyright (c) 2006-2008 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 <shlobj.h> - -#include "chrome/common/os_exchange_data.h" - -#include "app/l10n_util.h" -#include "base/clipboard_util.h" -#include "base/file_util.h" -#include "base/logging.h" -#include "base/pickle.h" -#include "base/scoped_handle.h" -#include "base/stl_util-inl.h" -#include "base/string_util.h" -#include "chrome/common/win_util.h" -#include "googleurl/src/gurl.h" -#include "grit/generated_resources.h" -#include "net/base/net_util.h" - -// Creates a new STGMEDIUM object to hold the specified text. The caller -// owns the resulting object. The "Bytes" version does not NULL terminate, the -// string version does. -static STGMEDIUM* GetStorageForBytes(const char* data, size_t bytes); -static STGMEDIUM* GetStorageForWString(const std::wstring& data); -static STGMEDIUM* GetStorageForString(const std::string& data); -// Creates the contents of an Internet Shortcut file for the given URL. -static void GetInternetShortcutFileContents(const GURL& url, std::string* data); -// Creates a valid file name given a suggested title and URL. -static void CreateValidFileNameFromTitle(const GURL& url, - const std::wstring& title, - std::wstring* validated); -// Creates a File Descriptor for the creation of a file to the given URL and -// returns a handle to it. -static STGMEDIUM* GetStorageForFileDescriptor( - const std::wstring& valid_file_name); - -/////////////////////////////////////////////////////////////////////////////// -// FormatEtcEnumerator - -// -// This object implements an enumeration interface. The existence of an -// implementation of this interface is exposed to clients through -// OSExchangeData's EnumFormatEtc method. Our implementation is nobody's -// business but our own, so it lives in this file. -// -// This Windows API is truly a gem. It wants to be an enumerator but assumes -// some sort of sequential data (why not just use an array?). See comments -// throughout. -// -class FormatEtcEnumerator : public IEnumFORMATETC { - public: - FormatEtcEnumerator(OSExchangeData::StoredData::const_iterator begin, - OSExchangeData::StoredData::const_iterator end); - ~FormatEtcEnumerator(); - - // IEnumFORMATETC implementation: - HRESULT __stdcall Next( - ULONG count, FORMATETC* elements_array, ULONG* elements_fetched); - HRESULT __stdcall Skip(ULONG skip_count); - HRESULT __stdcall Reset(); - HRESULT __stdcall Clone(IEnumFORMATETC** clone); - - // IUnknown implementation: - HRESULT __stdcall QueryInterface(const IID& iid, void** object); - ULONG __stdcall AddRef(); - ULONG __stdcall Release(); - - private: - // This can only be called from |CloneFromOther|, since it initializes the - // contents_ from the other enumerator's contents. - FormatEtcEnumerator() : ref_count_(0) { - } - - // Clone a new FormatEtc from another instance of this enumeration. - static FormatEtcEnumerator* CloneFromOther(const FormatEtcEnumerator* other); - - private: - // We are _forced_ to use a vector as our internal data model as Windows' - // retarded IEnumFORMATETC API assumes a deterministic ordering of elements - // through methods like Next and Skip. This exposes the underlying data - // structure to the user. Bah. - std::vector<FORMATETC*> contents_; - - // The cursor of the active enumeration - an index into |contents_|. - int cursor_; - - LONG ref_count_; - - DISALLOW_EVIL_CONSTRUCTORS(FormatEtcEnumerator); -}; - -// Safely makes a copy of all of the relevant bits of a FORMATETC object. -static void CloneFormatEtc(FORMATETC* source, FORMATETC* clone) { - *clone = *source; - if (source->ptd) { - source->ptd = - static_cast<DVTARGETDEVICE*>(CoTaskMemAlloc(sizeof(DVTARGETDEVICE))); - *(clone->ptd) = *(source->ptd); - } -} - -FormatEtcEnumerator::FormatEtcEnumerator( - OSExchangeData::StoredData::const_iterator start, - OSExchangeData::StoredData::const_iterator end) - : ref_count_(0), cursor_(0) { - // Copy FORMATETC data from our source into ourselves. - while (start != end) { - FORMATETC* format_etc = new FORMATETC; - CloneFormatEtc(&(*start)->format_etc, format_etc); - contents_.push_back(format_etc); - ++start; - } -} - -FormatEtcEnumerator::~FormatEtcEnumerator() { - STLDeleteContainerPointers(contents_.begin(), contents_.end()); -} - -STDMETHODIMP FormatEtcEnumerator::Next( - ULONG count, FORMATETC* elements_array, ULONG* elements_fetched) { - // MSDN says |elements_fetched| is allowed to be NULL if count is 1. - if (!elements_fetched) - DCHECK(count == 1); - - // This method copies count elements into |elements_array|. - int index = 0; - while (cursor_ < static_cast<int>(contents_.size()) && - static_cast<ULONG>(index) < count) { - CloneFormatEtc(contents_.at(cursor_), &elements_array[index]); - ++cursor_; - ++index; - } - // The out param is for how many we actually copied. - if (elements_fetched) - *elements_fetched = index; - - // If the two don't agree, then we fail. - return index == count ? S_OK : S_FALSE; -} - -STDMETHODIMP FormatEtcEnumerator::Skip(ULONG skip_count) { - cursor_ += skip_count; - // MSDN implies it's OK to leave the enumerator trashed. - // "Whatever you say, boss" - return cursor_ <= static_cast<int>(contents_.size()) ? S_OK : S_FALSE; -} - -STDMETHODIMP FormatEtcEnumerator::Reset() { - cursor_ = 0; - return S_OK; -} - -STDMETHODIMP FormatEtcEnumerator::Clone(IEnumFORMATETC** clone) { - // Clone the current enumerator in its exact state, including cursor. - FormatEtcEnumerator* e = CloneFromOther(this); - e->AddRef(); - *clone = e; - return S_OK; -} - -STDMETHODIMP FormatEtcEnumerator::QueryInterface(const IID& iid, - void** object) { - *object = NULL; - if (IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IEnumFORMATETC)) { - *object = this; - } else { - return E_NOINTERFACE; - } - AddRef(); - return S_OK; -} - -ULONG FormatEtcEnumerator::AddRef() { - return InterlockedIncrement(&ref_count_); -} - -ULONG FormatEtcEnumerator::Release() { - if (InterlockedDecrement(&ref_count_) == 0) { - ULONG copied_refcnt = ref_count_; - delete this; - return copied_refcnt; - } - return ref_count_; -} - -// static -FormatEtcEnumerator* FormatEtcEnumerator::CloneFromOther( - const FormatEtcEnumerator* other) { - FormatEtcEnumerator* e = new FormatEtcEnumerator; - // Copy FORMATETC data from our source into ourselves. - std::vector<FORMATETC*>::const_iterator start = other->contents_.begin(); - while (start != other->contents_.end()) { - FORMATETC* format_etc = new FORMATETC; - CloneFormatEtc(*start, format_etc); - e->contents_.push_back(format_etc); - ++start; - } - // Carry over - e->cursor_ = other->cursor_; - return e; -} - -/////////////////////////////////////////////////////////////////////////////// -// OSExchangeData, public: - -// static -bool OSExchangeData::HasPlainTextURL(IDataObject* source) { - std::wstring plain_text; - return (ClipboardUtil::GetPlainText(source, &plain_text) && - !plain_text.empty() && GURL(plain_text).is_valid()); -} - -// static -bool OSExchangeData::GetPlainTextURL(IDataObject* source, GURL* url) { - std::wstring plain_text; - if (ClipboardUtil::GetPlainText(source, &plain_text) && - !plain_text.empty()) { - GURL gurl(plain_text); - if (gurl.is_valid()) { - *url = gurl; - return true; - } - } - return false; -} - -OSExchangeData::OSExchangeData() - : ref_count_(0) { -} - -OSExchangeData::OSExchangeData(IDataObject* source) - : ref_count_(0) { - source_object_ = source; -} - -OSExchangeData::~OSExchangeData() { - STLDeleteContainerPointers(contents_.begin(), contents_.end()); -} - -void OSExchangeData::SetString(const std::wstring& data) { - STGMEDIUM* storage = GetStorageForWString(data); - contents_.push_back(new StoredDataInfo(CF_UNICODETEXT, storage)); - - // Also add plain text. - storage = GetStorageForString(WideToUTF8(data)); - contents_.push_back(new StoredDataInfo(CF_TEXT, storage)); -} - -void OSExchangeData::SetURL(const GURL& url, const std::wstring& title) { - // NOTE WELL: - // Every time you change the order of the first two CLIPFORMATS that get - // added here, you need to update the EnumerationViaCOM test case in - // the _unittest.cc file to reflect the new arrangement otherwise that test - // will fail! It assumes an insertion order. - - // Add text/x-moz-url for drags from Firefox - std::wstring x_moz_url_str = UTF8ToWide(url.spec()); - x_moz_url_str += '\n'; - x_moz_url_str += title; - STGMEDIUM* storage = GetStorageForWString(x_moz_url_str); - contents_.push_back(new StoredDataInfo( - ClipboardUtil::GetMozUrlFormat()->cfFormat, storage)); - - // Add a .URL shortcut file for dragging to Explorer. - std::wstring valid_file_name; - CreateValidFileNameFromTitle(url, title, &valid_file_name); - std::string shortcut_url_file_contents; - GetInternetShortcutFileContents(url, &shortcut_url_file_contents); - SetFileContents(valid_file_name, shortcut_url_file_contents); - - // Add a UniformResourceLocator link for apps like IE and Word. - storage = GetStorageForWString(UTF8ToWide(url.spec())); - contents_.push_back(new StoredDataInfo( - ClipboardUtil::GetUrlWFormat()->cfFormat, storage)); - storage = GetStorageForString(url.spec()); - contents_.push_back(new StoredDataInfo( - ClipboardUtil::GetUrlFormat()->cfFormat, storage)); - - // TODO(beng): (http://b/1085501) add CF_HTML... - - // Also add text representations (these should be last since they're the - // least preferable). - storage = GetStorageForWString(UTF8ToWide(url.spec())); - contents_.push_back(new StoredDataInfo(CF_UNICODETEXT, storage)); - storage = GetStorageForString(url.spec()); - contents_.push_back(new StoredDataInfo(CF_TEXT, storage)); -} - -void OSExchangeData::SetFilename(const std::wstring& full_path) { - const size_t drop_size = sizeof(DROPFILES); - const size_t bytes = drop_size + (full_path.length() + 2) * sizeof(wchar_t); - HANDLE hdata = ::GlobalAlloc(GMEM_MOVEABLE, bytes); - if (!hdata) - return; - - ScopedHGlobal<DROPFILES> locked_mem(hdata); - DROPFILES* drop_files = locked_mem.get(); - drop_files->pFiles = sizeof(DROPFILES); - drop_files->fWide = TRUE; - wchar_t* data = reinterpret_cast<wchar_t*>((BYTE*)(drop_files) + drop_size); - const size_t copy_size = (full_path.length() + 1) * sizeof(wchar_t); - memcpy(data, full_path.c_str(), copy_size); - data[full_path.length() + 1] = L'\0'; // Double NULL - - // Set up the STGMEDIUM - STGMEDIUM* storage = new STGMEDIUM; - storage->tymed = TYMED_HGLOBAL; - storage->hGlobal = drop_files; - storage->pUnkForRelease = NULL; - - // Set up the StoredDataInfo - StoredDataInfo* info = new StoredDataInfo(CF_HDROP, storage); - contents_.push_back(info); -} - -void OSExchangeData::SetPickledData(CLIPFORMAT format, const Pickle& data) { - STGMEDIUM* storage = GetStorageForString( - std::string(static_cast<const char *>(data.data()), - static_cast<size_t>(data.size()))); - contents_.push_back(new StoredDataInfo(format, storage)); -} - -void OSExchangeData::SetFileContents(const std::wstring& filename, - const std::string& file_contents) { - // Add CFSTR_FILEDESCRIPTOR - STGMEDIUM* storage = GetStorageForFileDescriptor(filename); - contents_.push_back(new StoredDataInfo( - ClipboardUtil::GetFileDescriptorFormat()->cfFormat, storage)); - - // Add CFSTR_FILECONTENTS - storage = GetStorageForBytes(file_contents.data(), file_contents.length()); - contents_.push_back(new StoredDataInfo( - ClipboardUtil::GetFileContentFormatZero()->cfFormat, storage)); -} - -void OSExchangeData::SetHtml(const std::wstring& html, const GURL& base_url) { - // Add both MS CF_HTML and text/html format. CF_HTML should be in utf-8. - std::string utf8_html = WideToUTF8(html); - std::string url = base_url.is_valid() ? base_url.spec() : std::string(); - - std::string cf_html = ClipboardUtil::HtmlToCFHtml(utf8_html, url); - STGMEDIUM* storage = GetStorageForBytes(cf_html.c_str(), cf_html.size()); - contents_.push_back(new StoredDataInfo( - ClipboardUtil::GetHtmlFormat()->cfFormat, storage)); - - STGMEDIUM* storage_plain = GetStorageForBytes(utf8_html.c_str(), - utf8_html.size()); - contents_.push_back(new StoredDataInfo( - ClipboardUtil::GetTextHtmlFormat()->cfFormat, storage_plain)); -} - -bool OSExchangeData::GetString(std::wstring* data) const { - return ClipboardUtil::GetPlainText(source_object_, data); -} - -bool OSExchangeData::GetURLAndTitle(GURL* url, std::wstring* title) const { - std::wstring url_str; - bool success = ClipboardUtil::GetUrl(source_object_, &url_str, title); - if (success) { - GURL test_url(url_str); - if (test_url.is_valid()) { - *url = test_url; - return true; - } - } else if (GetPlainTextURL(source_object_, url)) { - title->clear(); - return true; - } - return false; -} - -bool OSExchangeData::GetFilename(std::wstring* full_path) const { - std::vector<std::wstring> filenames; - bool success = ClipboardUtil::GetFilenames(source_object_, &filenames); - if (success) - full_path->assign(filenames[0]); - return success; -} - -bool OSExchangeData::GetPickledData(CLIPFORMAT format, Pickle* data) const { - DCHECK(data); - FORMATETC format_etc = - { format, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - bool success = false; - STGMEDIUM medium; - if (SUCCEEDED(source_object_->GetData(&format_etc, &medium))) { - if (medium.tymed & TYMED_HGLOBAL) { - ScopedHGlobal<char> c_data(medium.hGlobal); - DCHECK(c_data.Size() > 0); - // Need to subtract 1 as SetPickledData adds an extra byte to the end. - *data = Pickle(c_data.get(), static_cast<int>(c_data.Size() - 1)); - success = true; - } - ReleaseStgMedium(&medium); - } - return success; -} - -bool OSExchangeData::GetFileContents(std::wstring* filename, - std::string* file_contents) const { - return ClipboardUtil::GetFileContents(source_object_, filename, - file_contents); -} - -bool OSExchangeData::GetHtml(std::wstring* html, GURL* base_url) const { - std::string url; - bool success = ClipboardUtil::GetHtml(source_object_, html, &url); - if (success) - *base_url = GURL(url); - return success; -} - -bool OSExchangeData::HasString() const { - return ClipboardUtil::HasPlainText(source_object_); -} - -bool OSExchangeData::HasURL() const { - return (ClipboardUtil::HasUrl(source_object_) || - HasPlainTextURL(source_object_)); -} - -bool OSExchangeData::HasFile() const { - return ClipboardUtil::HasFilenames(source_object_); -} - -bool OSExchangeData::HasFormat(CLIPFORMAT format) const { - FORMATETC format_etc = - { format, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - return (source_object_->QueryGetData(&format_etc) == S_OK); -} - -/////////////////////////////////////////////////////////////////////////////// -// OSExchangeData, IDataObject implementation: - -// The following function, DuplicateMedium, is derived from WCDataObject.cpp -// in the WebKit source code. This is the license information for the file: -/* - * Copyright (C) 2007 Apple Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -static void DuplicateMedium(CLIPFORMAT source_clipformat, - STGMEDIUM* source, - STGMEDIUM* destination) { - switch (source->tymed) { - case TYMED_HGLOBAL: - destination->hGlobal = - static_cast<HGLOBAL>(OleDuplicateData( - source->hGlobal, source_clipformat, 0)); - break; - case TYMED_MFPICT: - destination->hMetaFilePict = - static_cast<HMETAFILEPICT>(OleDuplicateData( - source->hMetaFilePict, source_clipformat, 0)); - break; - case TYMED_GDI: - destination->hBitmap = - static_cast<HBITMAP>(OleDuplicateData( - source->hBitmap, source_clipformat, 0)); - break; - case TYMED_ENHMF: - destination->hEnhMetaFile = - static_cast<HENHMETAFILE>(OleDuplicateData( - source->hEnhMetaFile, source_clipformat, 0)); - break; - case TYMED_FILE: - destination->lpszFileName = - static_cast<LPOLESTR>(OleDuplicateData( - source->lpszFileName, source_clipformat, 0)); - break; - case TYMED_ISTREAM: - destination->pstm = source->pstm; - destination->pstm->AddRef(); - break; - case TYMED_ISTORAGE: - destination->pstg = source->pstg; - destination->pstg->AddRef(); - break; - } - - destination->tymed = source->tymed; - destination->pUnkForRelease = source->pUnkForRelease; - if (destination->pUnkForRelease) - destination->pUnkForRelease->AddRef(); -} - -HRESULT OSExchangeData::GetData(FORMATETC* format_etc, STGMEDIUM* medium) { - StoredData::const_iterator iter = contents_.begin(); - while (iter != contents_.end()) { - if ((*iter)->format_etc.cfFormat == format_etc->cfFormat) { - DuplicateMedium((*iter)->format_etc.cfFormat, (*iter)->medium, medium); - return S_OK; - } - ++iter; - } - - return DV_E_FORMATETC; -} - -HRESULT OSExchangeData::GetDataHere(FORMATETC* format_etc, STGMEDIUM* medium) { - return DATA_E_FORMATETC; -} - -HRESULT OSExchangeData::QueryGetData(FORMATETC* format_etc) { - StoredData::const_iterator iter = contents_.begin(); - while (iter != contents_.end()) { - if ((*iter)->format_etc.cfFormat == format_etc->cfFormat) - return S_OK; - ++iter; - } - return DV_E_FORMATETC; -} - -HRESULT OSExchangeData::GetCanonicalFormatEtc( - FORMATETC* format_etc, FORMATETC* result) { - format_etc->ptd = NULL; - return E_NOTIMPL; -} - -HRESULT OSExchangeData::SetData( - FORMATETC* format_etc, STGMEDIUM* medium, BOOL should_release) { - STGMEDIUM* local_medium = new STGMEDIUM; - if (should_release) { - *local_medium = *medium; - } else { - DuplicateMedium(format_etc->cfFormat, medium, local_medium); - } - - StoredDataInfo* info = - new StoredDataInfo(format_etc->cfFormat, local_medium); - info->medium->tymed = format_etc->tymed; - info->owns_medium = !!should_release; - contents_.push_back(info); - - return S_OK; -} - -HRESULT OSExchangeData::EnumFormatEtc( - DWORD direction, IEnumFORMATETC** enumerator) { - if (direction == DATADIR_GET) { - FormatEtcEnumerator* e = - new FormatEtcEnumerator(contents_.begin(), contents_.end()); - e->AddRef(); - *enumerator = e; - return S_OK; - } - return E_NOTIMPL; -} - -HRESULT OSExchangeData::DAdvise( - FORMATETC* format_etc, DWORD advf, IAdviseSink* sink, DWORD* connection) { - return OLE_E_ADVISENOTSUPPORTED; -} - -HRESULT OSExchangeData::DUnadvise(DWORD connection) { - return OLE_E_ADVISENOTSUPPORTED; -} - -HRESULT OSExchangeData::EnumDAdvise(IEnumSTATDATA** enumerator) { - return OLE_E_ADVISENOTSUPPORTED; -} - -/////////////////////////////////////////////////////////////////////////////// -// OSExchangeData, IUnknown implementation: - -HRESULT OSExchangeData::QueryInterface(const IID& iid, void** object) { - *object = NULL; - if (IsEqualIID(iid, IID_IUnknown) || IsEqualIID(iid, IID_IDataObject)) { - *object = this; - } else { - return E_NOINTERFACE; - } - AddRef(); - return S_OK; -} - -ULONG OSExchangeData::AddRef() { - return InterlockedIncrement(&ref_count_); -} - -ULONG OSExchangeData::Release() { - if (InterlockedDecrement(&ref_count_) == 0) { - ULONG copied_refcnt = ref_count_; - delete this; - return copied_refcnt; - } - return ref_count_; -} - -/////////////////////////////////////////////////////////////////////////////// -// OSExchangeData, private: - -static STGMEDIUM* GetStorageForBytes(const char* data, size_t bytes) { - HANDLE handle = GlobalAlloc(GPTR, static_cast<int>(bytes)); - ScopedHGlobal<char> scoped(handle); - size_t allocated = static_cast<size_t>(GlobalSize(handle)); - memcpy(scoped.get(), data, allocated); - - STGMEDIUM* storage = new STGMEDIUM; - storage->hGlobal = handle; - storage->tymed = TYMED_HGLOBAL; - storage->pUnkForRelease = NULL; - return storage; -} - -template<class T> -static HGLOBAL CopyStringToGlobalHandle(const T& payload) { - int bytes = static_cast<int>(payload.size() + 1) * sizeof(T::value_type); - HANDLE handle = GlobalAlloc(GPTR, bytes); - void* data = GlobalLock(handle); - size_t allocated = static_cast<size_t>(GlobalSize(handle)); - memcpy(data, payload.c_str(), allocated); - static_cast<T::value_type*>(data)[payload.size()] = '\0'; - GlobalUnlock(handle); - return handle; -} - -static STGMEDIUM* GetStorageForWString(const std::wstring& data) { - STGMEDIUM* storage = new STGMEDIUM; - storage->hGlobal = CopyStringToGlobalHandle<std::wstring>(data); - storage->tymed = TYMED_HGLOBAL; - storage->pUnkForRelease = NULL; - return storage; -} - -static STGMEDIUM* GetStorageForString(const std::string& data) { - STGMEDIUM* storage = new STGMEDIUM; - storage->hGlobal = CopyStringToGlobalHandle<std::string>(data); - storage->tymed = TYMED_HGLOBAL; - storage->pUnkForRelease = NULL; - return storage; -} - -static void GetInternetShortcutFileContents(const GURL& url, - std::string* data) { - DCHECK(data); - static const std::string kInternetShortcutFileStart = - "[InternetShortcut]\r\nURL="; - static const std::string kInternetShortcutFileEnd = - "\r\n"; - *data = kInternetShortcutFileStart + url.spec() + kInternetShortcutFileEnd; -} - -static void CreateValidFileNameFromTitle(const GURL& url, - const std::wstring& title, - std::wstring* validated) { - if (title.empty()) { - if (url.is_valid()) { - *validated = net::GetSuggestedFilename( - url, std::string(), std::string(), std::wstring()); - } else { - // Nothing else can be done, just use a default. - *validated = l10n_util::GetString(IDS_UNTITLED_SHORTCUT_FILE_NAME); - } - } else { - *validated = title; - file_util::ReplaceIllegalCharacters(validated, '-'); - } - static const wchar_t extension[] = L".url"; - static const size_t max_length = MAX_PATH - arraysize(extension); - if (validated->size() > max_length) - validated->erase(max_length); - *validated += extension; -} - -static STGMEDIUM* GetStorageForFileDescriptor( - const std::wstring& valid_file_name) { - DCHECK(!valid_file_name.empty() && valid_file_name.size() + 1 <= MAX_PATH); - HANDLE handle = GlobalAlloc(GPTR, sizeof(FILEGROUPDESCRIPTOR)); - FILEGROUPDESCRIPTOR* descriptor = - reinterpret_cast<FILEGROUPDESCRIPTOR*>(GlobalLock(handle)); - - descriptor->cItems = 1; - wcscpy_s(descriptor->fgd[0].cFileName, - valid_file_name.size() + 1, - valid_file_name.c_str()); - descriptor->fgd[0].dwFlags = FD_LINKUI; - - GlobalUnlock(handle); - - STGMEDIUM* storage = new STGMEDIUM; - storage->hGlobal = handle; - storage->tymed = TYMED_HGLOBAL; - storage->pUnkForRelease = NULL; - return storage; -} diff --git a/chrome/common/os_exchange_data.h b/chrome/common/os_exchange_data.h deleted file mode 100644 index 735e366..0000000 --- a/chrome/common/os_exchange_data.h +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (c) 2006-2008 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_COMMON_OS_EXCHANGE_DATA_H__ -#define CHROME_COMMON_OS_EXCHANGE_DATA_H__ - -#include <atlbase.h> -#include <objidl.h> -#include <vector> - -#include "base/basictypes.h" - -class GURL; -class Pickle; - -/////////////////////////////////////////////////////////////////////////////// -// -// OSExchangeData -// An object that holds interchange data to be sent out to OS services like -// clipboard, drag and drop, etc. This object exposes an API that clients can -// use to specify raw data and its high level type. This object takes care of -// translating that into something the OS can understand. -// -/////////////////////////////////////////////////////////////////////////////// -class OSExchangeData : public IDataObject { - public: - // Returns true if source has plain text that is a valid url. - static bool HasPlainTextURL(IDataObject* source); - - // Returns true if source has plain text that is a valid URL and sets url to - // that url. - static bool GetPlainTextURL(IDataObject* source, GURL* url); - - OSExchangeData(); - OSExchangeData(IDataObject* source); - virtual ~OSExchangeData(); - - // These functions add data to the OSExchangeData object of various Chrome - // types. The OSExchangeData object takes care of translating the data into - // a format suitable for exchange with the OS. - // NOTE WELL: Typically, a data object like this will contain only one of the - // following types of data. In cases where more data is held, the - // order in which these functions are called is _important_! - // ---> The order types are added to an OSExchangeData object controls - // the order of enumeration in our IEnumFORMATETC implementation! - // This comes into play when selecting the best (most preferable) - // data type for insertion into a DropTarget. - void SetString(const std::wstring& data); - // A URL can have an optional title in some exchange formats. - void SetURL(const GURL& url, const std::wstring& title); - // A full path to a file - void SetFilename(const std::wstring& full_path); - // Adds pickled data of the specified format. - void SetPickledData(CLIPFORMAT format, const Pickle& data); - // Adds the bytes of a file (CFSTR_FILECONTENTS and CFSTR_FILEDESCRIPTOR). - void SetFileContents(const std::wstring& filename, - const std::string& file_contents); - // Adds a snippet of HTML. |html| is just raw html but this sets both - // text/html and CF_HTML. - void SetHtml(const std::wstring& html, const GURL& base_url); - - // These functions retrieve data of the specified type. If data exists, the - // functions return and the result is in the out parameter. If the data does - // not exist, the out parameter is not touched. The out parameter cannot be - // NULL. - bool GetString(std::wstring* data) const; - bool GetURLAndTitle(GURL* url, std::wstring* title) const; - // Return the path of a file, if available. - bool GetFilename(std::wstring* full_path) const; - bool GetPickledData(CLIPFORMAT format, Pickle* data) const; - bool GetFileContents(std::wstring* filename, - std::string* file_contents) const; - bool GetHtml(std::wstring* html, GURL* base_url) const; - - // Test whether or not data of certain types is present, without actually - // returning anything. - bool HasString() const; - bool HasURL() const; - bool HasURLTitle() const; - bool HasFile() const; - bool HasFormat(CLIPFORMAT format) const; - - // IDataObject implementation: - HRESULT __stdcall GetData(FORMATETC* format_etc, STGMEDIUM* medium); - HRESULT __stdcall GetDataHere(FORMATETC* format_etc, STGMEDIUM* medium); - HRESULT __stdcall QueryGetData(FORMATETC* format_etc); - HRESULT __stdcall GetCanonicalFormatEtc( - FORMATETC* format_etc, FORMATETC* result); - HRESULT __stdcall SetData( - FORMATETC* format_etc, STGMEDIUM* medium, BOOL should_release); - HRESULT __stdcall EnumFormatEtc( - DWORD direction, IEnumFORMATETC** enumerator); - HRESULT __stdcall DAdvise( - FORMATETC* format_etc, DWORD advf, IAdviseSink* sink, DWORD* connection); - HRESULT __stdcall DUnadvise(DWORD connection); - HRESULT __stdcall EnumDAdvise(IEnumSTATDATA** enumerator); - - // IUnknown implementation: - HRESULT __stdcall QueryInterface(const IID& iid, void** object); - ULONG __stdcall AddRef(); - ULONG __stdcall Release(); - - private: - // FormatEtcEnumerator only likes us for our StoredDataMap typedef. - friend class FormatEtcEnumerator; - - // Our internal representation of stored data & type info. - struct StoredDataInfo { - FORMATETC format_etc; - STGMEDIUM* medium; - bool owns_medium; - - StoredDataInfo(CLIPFORMAT cf, STGMEDIUM* a_medium) { - format_etc.cfFormat = cf; - format_etc.dwAspect = DVASPECT_CONTENT; - format_etc.lindex = -1; - format_etc.ptd = NULL; - format_etc.tymed = a_medium->tymed; - - owns_medium = true; - - medium = a_medium; - } - - ~StoredDataInfo() { - if (owns_medium) { - ReleaseStgMedium(medium); - delete medium; - } - } - }; - - typedef std::vector<StoredDataInfo*> StoredData; - StoredData contents_; - - CComPtr<IDataObject> source_object_; - - LONG ref_count_; - - DISALLOW_EVIL_CONSTRUCTORS(OSExchangeData); -}; - -#endif // #ifndef CHROME_COMMON_OS_EXCHANGE_DATA_H__ diff --git a/chrome/common/os_exchange_data_unittest.cc b/chrome/common/os_exchange_data_unittest.cc deleted file mode 100644 index 205eb40..0000000 --- a/chrome/common/os_exchange_data_unittest.cc +++ /dev/null @@ -1,365 +0,0 @@ -// Copyright (c) 2006-2008 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 <atlbase.h> -#include <shlobj.h> - -#include "base/clipboard_util.h" -#include "base/pickle.h" -#include "base/ref_counted.h" -#include "base/scoped_handle.h" -#include "base/string_util.h" -#include "chrome/common/os_exchange_data.h" -#include "chrome/common/win_util.h" -#include "googleurl/src/gurl.h" -#include "testing/gtest/include/gtest/gtest.h" - -typedef testing::Test OSExchangeDataTest; - -// Test setting/getting using the OSExchangeData API -TEST(OSExchangeDataTest, StringDataGetAndSet) { - OSExchangeData* data = new OSExchangeData; - std::wstring input = L"I can has cheezburger?"; - data->SetString(input); - - OSExchangeData* data2 = new OSExchangeData(data); - std::wstring output; - EXPECT_TRUE(data2->GetString(&output)); - EXPECT_EQ(input, output); - std::string url_spec = "http://www.goats.com/"; - GURL url(url_spec); - std::wstring title; - EXPECT_FALSE(data2->GetURLAndTitle(&url, &title)); - // No URLs in |data|, so url should be untouched. - EXPECT_EQ(url_spec, url.spec()); - // data gets freed when data2 releases the ref on it - delete data2; -} - -// Test getting using the IDataObject COM API -TEST(OSExchangeDataTest, StringDataAccessViaCOM) { - OSExchangeData* data = new OSExchangeData; - std::wstring input = L"O hai googlz."; - data->SetString(input); - CComPtr<IDataObject> com_data(data); - - FORMATETC format_etc = - { CF_UNICODETEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - EXPECT_EQ(S_OK, com_data->QueryGetData(&format_etc)); - - STGMEDIUM medium; - EXPECT_EQ(S_OK, com_data->GetData(&format_etc, &medium)); - std::wstring output = - ScopedHGlobal<wchar_t>(medium.hGlobal).get(); - EXPECT_EQ(input, output); - ReleaseStgMedium(&medium); - - // data is freed automatically by CComPtr. -} - -// Test setting using the IDataObject COM API -TEST(OSExchangeDataTest, StringDataWritingViaCOM) { - OSExchangeData* data = new OSExchangeData; - std::wstring input = L"http://www.google.com/"; - - CComPtr<IDataObject> com_data(data); - - // Store data in the object using the COM SetData API. - CLIPFORMAT cfstr_ineturl = RegisterClipboardFormat(CFSTR_INETURL); - FORMATETC format_etc = - { cfstr_ineturl, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - STGMEDIUM medium; - medium.tymed = TYMED_HGLOBAL; - HGLOBAL glob = GlobalAlloc(GPTR, sizeof(wchar_t) * (input.size() + 1)); - size_t stringsz = input.size(); - SIZE_T sz = GlobalSize(glob); - ScopedHGlobal<wchar_t> global_lock(glob); - wchar_t* buffer_handle = global_lock.get(); - wcscpy_s(buffer_handle, input.size() + 1, input.c_str()); - medium.hGlobal = glob; - medium.pUnkForRelease = NULL; - EXPECT_EQ(S_OK, com_data->SetData(&format_etc, &medium, TRUE)); - - // Construct a new object with the old object so that we can use our access - // APIs. - OSExchangeData* data2 = new OSExchangeData(com_data); - EXPECT_TRUE(data2->HasURL()); - GURL url_from_data; - std::wstring title; - EXPECT_TRUE(data2->GetURLAndTitle(&url_from_data, &title)); - GURL reference_url(input); - EXPECT_EQ(reference_url.spec(), url_from_data.spec()); - // deleting data2 will free data because it holds a ref to it. - delete data2; -} - -TEST(OSExchangeDataTest, URLDataAccessViaCOM) { - OSExchangeData* data = new OSExchangeData; - GURL url("http://www.google.com/"); - data->SetURL(url, L""); - CComPtr<IDataObject> com_data(data); - - CLIPFORMAT cfstr_ineturl = RegisterClipboardFormat(CFSTR_INETURL); - FORMATETC format_etc = - { cfstr_ineturl, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - EXPECT_EQ(S_OK, com_data->QueryGetData(&format_etc)); - - STGMEDIUM medium; - EXPECT_EQ(S_OK, com_data->GetData(&format_etc, &medium)); - std::wstring output = - ScopedHGlobal<wchar_t>(medium.hGlobal).get(); - EXPECT_EQ(url.spec(), WideToUTF8(output)); - ReleaseStgMedium(&medium); -} - -TEST(OSExchangeDataTest, MultipleFormatsViaCOM) { - OSExchangeData* data = new OSExchangeData; - std::string url_spec = "http://www.google.com/"; - GURL url(url_spec); - std::wstring text = L"O hai googlz."; - data->SetURL(url, L"Google"); - data->SetString(text); - - CComPtr<IDataObject> com_data(data); - - CLIPFORMAT cfstr_ineturl = RegisterClipboardFormat(CFSTR_INETURL); - FORMATETC url_format_etc = - { cfstr_ineturl, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - EXPECT_EQ(S_OK, com_data->QueryGetData(&url_format_etc)); - FORMATETC text_format_etc = - { CF_UNICODETEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - EXPECT_EQ(S_OK, com_data->QueryGetData(&text_format_etc)); - - STGMEDIUM medium; - EXPECT_EQ(S_OK, com_data->GetData(&url_format_etc, &medium)); - std::wstring output_url = - ScopedHGlobal<wchar_t>(medium.hGlobal).get(); - EXPECT_EQ(url.spec(), WideToUTF8(output_url)); - ReleaseStgMedium(&medium); - - // The text is supposed to be the raw text of the URL, _NOT_ the value of - // |text|! This is because the URL is added first and thus takes precedence! - EXPECT_EQ(S_OK, com_data->GetData(&text_format_etc, &medium)); - std::wstring output_text = - ScopedHGlobal<wchar_t>(medium.hGlobal).get(); - EXPECT_EQ(url_spec, WideToUTF8(output_text)); - ReleaseStgMedium(&medium); -} - -TEST(OSExchangeDataTest, EnumerationViaCOM) { - OSExchangeData* data = new OSExchangeData; - data->SetURL(GURL("http://www.google.com/"), L""); - data->SetString(L"O hai googlz."); - - CLIPFORMAT cfstr_file_group_descriptor = - RegisterClipboardFormat(CFSTR_FILEDESCRIPTOR); - CLIPFORMAT text_x_moz_url = RegisterClipboardFormat(L"text/x-moz-url"); - - CComPtr<IDataObject> com_data(data); - CComPtr<IEnumFORMATETC> enumerator; - EXPECT_EQ(S_OK, com_data->EnumFormatEtc(DATADIR_GET, &enumerator)); - - // Test that we can get one item. - { - // Explictly don't reset the first time, to verify the creation state is - // OK. - ULONG retrieved = 0; - FORMATETC elements_array[1]; - EXPECT_EQ(S_OK, enumerator->Next(1, - reinterpret_cast<FORMATETC*>(&elements_array), &retrieved)); - EXPECT_EQ(1, retrieved); - EXPECT_EQ(text_x_moz_url, elements_array[0].cfFormat); - } - - // Test that we can get one item with a NULL retrieved value. - { - EXPECT_EQ(S_OK, enumerator->Reset()); - FORMATETC elements_array[1]; - EXPECT_EQ(S_OK, enumerator->Next(1, - reinterpret_cast<FORMATETC*>(&elements_array), NULL)); - EXPECT_EQ(text_x_moz_url, elements_array[0].cfFormat); - } - - // Test that we can get two items. - { - EXPECT_EQ(S_OK, enumerator->Reset()); - ULONG retrieved = 0; - FORMATETC elements_array[2]; - EXPECT_EQ(S_OK, enumerator->Next(2, - reinterpret_cast<FORMATETC*>(&elements_array), &retrieved)); - EXPECT_EQ(2, retrieved); - EXPECT_EQ(text_x_moz_url, elements_array[0].cfFormat); - EXPECT_EQ(cfstr_file_group_descriptor, elements_array[1].cfFormat); - } - - // Test that we can skip the first item. - { - EXPECT_EQ(S_OK, enumerator->Reset()); - EXPECT_EQ(S_OK, enumerator->Skip(1)); - ULONG retrieved = 0; - FORMATETC elements_array[1]; - EXPECT_EQ(S_OK, enumerator->Next(1, - reinterpret_cast<FORMATETC*>(&elements_array), &retrieved)); - EXPECT_EQ(1, retrieved); - EXPECT_EQ(cfstr_file_group_descriptor, elements_array[0].cfFormat); - } - - // Test that we can skip the first item, and create a clone that matches in - // this state, and modify the original without affecting the clone. - { - EXPECT_EQ(S_OK, enumerator->Reset()); - EXPECT_EQ(S_OK, enumerator->Skip(1)); - CComPtr<IEnumFORMATETC> cloned_enumerator; - EXPECT_EQ(S_OK, enumerator->Clone(&cloned_enumerator)); - EXPECT_EQ(S_OK, enumerator->Reset()); - - { - ULONG retrieved = 0; - FORMATETC elements_array[1]; - EXPECT_EQ(S_OK, cloned_enumerator->Next(1, - reinterpret_cast<FORMATETC*>(&elements_array), &retrieved)); - EXPECT_EQ(1, retrieved); - EXPECT_EQ(cfstr_file_group_descriptor, elements_array[0].cfFormat); - } - - { - ULONG retrieved = 0; - FORMATETC elements_array[1]; - EXPECT_EQ(S_OK, enumerator->Next(1, - reinterpret_cast<FORMATETC*>(&elements_array), &retrieved)); - EXPECT_EQ(1, retrieved); - EXPECT_EQ(text_x_moz_url, elements_array[0].cfFormat); - } - } -} - -TEST(OSExchangeDataTest, TestURLExchangeFormats) { - OSExchangeData* data = new OSExchangeData; - std::string url_spec = "http://www.google.com/"; - GURL url(url_spec); - std::wstring url_title = L"Google"; - data->SetURL(url, url_title); - std::wstring output; - - OSExchangeData* data2 = new OSExchangeData(data); - - // URL spec and title should match - GURL output_url; - std::wstring output_title; - EXPECT_TRUE(data2->GetURLAndTitle(&output_url, &output_title)); - EXPECT_EQ(url_spec, output_url.spec()); - EXPECT_EQ(url_title, output_title); - std::wstring output_string; - - // URL should be the raw text response - EXPECT_TRUE(data2->GetString(&output_string)); - EXPECT_EQ(url_spec, WideToUTF8(output_string)); - - // File contents access via COM - CComPtr<IDataObject> com_data(data); - { - CLIPFORMAT cfstr_file_contents = - RegisterClipboardFormat(CFSTR_FILECONTENTS); - FORMATETC format_etc = - { cfstr_file_contents, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }; - EXPECT_EQ(S_OK, com_data->QueryGetData(&format_etc)); - - STGMEDIUM medium; - EXPECT_EQ(S_OK, com_data->GetData(&format_etc, &medium)); - ScopedHGlobal<char> glob(medium.hGlobal); - std::string output(glob.get(), glob.Size()); - std::string file_contents = "[InternetShortcut]\r\nURL="; - file_contents += url_spec; - file_contents += "\r\n"; - EXPECT_EQ(file_contents, output); - ReleaseStgMedium(&medium); - } - - // Need to manually free data2 since we never stuff it into a COMPtr. - delete data2; -} - -TEST(OSExchangeDataTest, TestPickledData) { - CLIPFORMAT test_cf = RegisterClipboardFormat(L"chrome/test"); - - Pickle saved_pickle; - saved_pickle.WriteInt(1); - saved_pickle.WriteInt(2); - scoped_refptr<OSExchangeData> data(new OSExchangeData()); - data->SetPickledData(test_cf, saved_pickle); - - scoped_refptr<OSExchangeData> copy(new OSExchangeData(data.get())); - EXPECT_TRUE(copy->HasFormat(test_cf)); - - Pickle restored_pickle; - EXPECT_TRUE(copy->GetPickledData(test_cf, &restored_pickle)); - void* p_iterator = NULL; - int value; - EXPECT_TRUE(restored_pickle.ReadInt(&p_iterator, &value)); - EXPECT_EQ(1, value); - EXPECT_TRUE(restored_pickle.ReadInt(&p_iterator, &value)); - EXPECT_EQ(2, value); -} - -TEST(OSExchangeDataTest, FileContents) { - scoped_refptr<OSExchangeData> data(new OSExchangeData); - std::string file_contents("data\0with\0nulls", 15); - data->SetFileContents(L"filename.txt", file_contents); - - scoped_refptr<OSExchangeData> copy(new OSExchangeData(data.get())); - std::wstring filename; - std::string read_contents; - EXPECT_TRUE(copy->GetFileContents(&filename, &read_contents)); - EXPECT_EQ(L"filename.txt", filename); - EXPECT_EQ(file_contents, read_contents); -} - -TEST(OSExchangeDataTest, Html) { - scoped_refptr<OSExchangeData> data(new OSExchangeData); - GURL url("http://www.google.com/"); - std::wstring html( - L"<HTML>\n<BODY>\n" - L"<b>bold.</b> <i><b>This is bold italic.</b></i>\n" - L"</BODY>\n</HTML>"); - data->SetHtml(html, url); - - scoped_refptr<OSExchangeData> copy(new OSExchangeData(data.get())); - std::wstring read_html; - EXPECT_TRUE(copy->GetHtml(&read_html, &url)); - EXPECT_EQ(html, read_html); - - // Check the CF_HTML too. - std::string expected_cf_html( - "Version:0.9\r\nStartHTML:0000000139\r\nEndHTML:0000000292\r\n" - "StartFragment:0000000177\r\nEndFragment:0000000254\r\n" - "SourceURL:http://www.google.com/\r\n<html>\r\n<body>\r\n" - "<!--StartFragment-->\r\n"); - expected_cf_html += WideToUTF8(html); - expected_cf_html.append("\r\n<!--EndFragment-->\r\n</body>\r\n</html>"); - - STGMEDIUM medium; - EXPECT_EQ(S_OK, data->GetData(ClipboardUtil::GetHtmlFormat(), &medium)); - ScopedHGlobal<char> glob(medium.hGlobal); - std::string output(glob.get(), glob.Size()); - EXPECT_EQ(expected_cf_html, output); - ReleaseStgMedium(&medium); -} - -TEST(OSExchangeDataTest, SetURLWithMaxPath) { - scoped_refptr<OSExchangeData> data(new OSExchangeData); - std::wstring long_title(L'a', MAX_PATH + 1); - data->SetURL(GURL("http://google.com"), long_title); -} - -TEST(OSExchangeDataTest, ProvideURLForPlainTextURL) { - scoped_refptr<OSExchangeData> data(new OSExchangeData); - data->SetString(L"http://google.com"); - - scoped_ptr<OSExchangeData> data2(new OSExchangeData(data.get())); - ASSERT_TRUE(data2->HasURL()); - GURL read_url; - std::wstring title; - EXPECT_TRUE(data2->GetURLAndTitle(&read_url, &title)); - EXPECT_EQ(GURL("http://google.com"), read_url); -} diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index c5407d5..3e62e11 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -8,7 +8,9 @@ #include <string> #include <vector> +#include "app/gfx/favicon_size.h" #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "app/resource_bundle.h" #include "base/command_line.h" #include "base/compiler_specific.h" @@ -19,10 +21,8 @@ #include "build/build_config.h" #include "chrome/common/bindings_policy.h" #include "chrome/common/chrome_switches.h" -#include "chrome/common/gfx/favicon_size.h" #include "chrome/common/gfx/color_utils.h" #include "chrome/common/jstemplate_builder.h" -#include "chrome/common/message_box_flags.h" #include "chrome/common/page_zoom.h" #include "chrome/common/render_messages.h" #include "chrome/common/thumbnail_score.h" diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index 7669c6d..fca1078 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -7,6 +7,7 @@ #include <string> +#include "app/message_box_flags.h" #include "base/basictypes.h" #include "base/process_util.h" #include "base/scoped_ptr.h" @@ -16,7 +17,6 @@ #include "chrome/common/ipc_channel_proxy.h" #include "chrome/common/ipc_message.h" #include "chrome/common/ipc_sync_channel.h" -#include "chrome/common/message_box_flags.h" #include "chrome/test/automation/automation_handle_tracker.h" #include "chrome/test/automation/automation_messages.h" diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index e3bca00..b782a6c 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -4,6 +4,7 @@ #include <string> +#include "app/message_box_flags.h" #include "base/command_line.h" #include "base/file_path.h" #include "base/string_util.h" @@ -13,7 +14,6 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/json_value_serializer.h" -#include "chrome/common/message_box_flags.h" #include "chrome/test/automation/constrained_window_proxy.h" #include "chrome/test/automation/browser_proxy.h" #include "chrome/test/automation/tab_proxy.h" diff --git a/chrome/test/unit/unittests.vcproj b/chrome/test/unit/unittests.vcproj index f274c23..7488c28 100644 --- a/chrome/test/unit/unittests.vcproj +++ b/chrome/test/unit/unittests.vcproj @@ -960,10 +960,6 @@ > </File> <File - RelativePath="..\..\common\gfx\icon_util_unittest.cc" - > - </File> - <File RelativePath="..\..\common\ipc_message_unittest.cc" > </File> @@ -996,10 +992,6 @@ > </File> <File - RelativePath="..\..\common\os_exchange_data_unittest.cc" - > - </File> - <File RelativePath="..\..\common\pref_member_unittest.cc" > </File> @@ -1100,9 +1092,17 @@ > </File> <File + RelativePath="..\..\..\app\gfx\icon_util_unittest.cc" + > + </File> + <File RelativePath="..\..\..\app\l10n_util_unittest.cc" > </File> + <File + RelativePath="..\..\..\app\os_exchange_data_unittest.cc" + > + </File> </Filter> </Files> <Globals> diff --git a/chrome/views/border.h b/chrome/views/border.h index ae6831c..c53a92d 100644 --- a/chrome/views/border.h +++ b/chrome/views/border.h @@ -5,7 +5,7 @@ #ifndef CHROME_VIEWS_BORDER_H_ #define CHROME_VIEWS_BORDER_H_ -#include "chrome/common/gfx/insets.h" +#include "app/gfx/insets.h" #include "chrome/views/view.h" #include "SkColor.h" diff --git a/chrome/views/controls/button/menu_button.cc b/chrome/views/controls/button/menu_button.cc index f7e7136..6f82b16 100644 --- a/chrome/views/controls/button/menu_button.cc +++ b/chrome/views/controls/button/menu_button.cc @@ -4,10 +4,10 @@ #include "chrome/views/controls/button/menu_button.h" +#include "app/drag_drop_types.h" #include "app/gfx/chrome_canvas.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" -#include "chrome/common/drag_drop_types.h" #include "chrome/common/win_util.h" #include "chrome/views/controls/button/button.h" #include "chrome/views/controls/menu/view_menu_delegate.h" diff --git a/chrome/views/controls/label.cc b/chrome/views/controls/label.cc index 7cd8920..be9918f 100644 --- a/chrome/views/controls/label.cc +++ b/chrome/views/controls/label.cc @@ -8,11 +8,11 @@ #include "app/gfx/chrome_canvas.h" #include "app/gfx/chrome_font.h" +#include "app/gfx/insets.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/logging.h" #include "base/string_util.h" -#include "chrome/common/gfx/insets.h" #include "chrome/common/gfx/text_elider.h" #include "chrome/views/background.h" diff --git a/chrome/views/controls/menu/chrome_menu.cc b/chrome/views/controls/menu/chrome_menu.cc index c591a7e..1b1e475 100644 --- a/chrome/views/controls/menu/chrome_menu.cc +++ b/chrome/views/controls/menu/chrome_menu.cc @@ -11,6 +11,7 @@ #include "app/gfx/chrome_canvas.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" +#include "app/os_exchange_data.h" #include "base/base_drag_source.h" #include "base/gfx/native_theme.h" #include "base/message_loop.h" @@ -20,7 +21,6 @@ // TODO(beng): (Cleanup) remove this browser dep. #include "chrome/browser/drag_utils.h" #include "chrome/common/gfx/color_utils.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/views/border.h" #include "chrome/views/view_constants.h" #include "chrome/views/widget/root_view.h" diff --git a/chrome/views/controls/menu/chrome_menu.h b/chrome/views/controls/menu/chrome_menu.h index 5258742..6f18abb 100644 --- a/chrome/views/controls/menu/chrome_menu.h +++ b/chrome/views/controls/menu/chrome_menu.h @@ -8,12 +8,12 @@ #include <list> #include <vector> +#include "app/drag_drop_types.h" #include "app/gfx/chrome_font.h" #include "base/gfx/point.h" #include "base/gfx/rect.h" #include "base/message_loop.h" #include "base/task.h" -#include "chrome/common/drag_drop_types.h" #include "chrome/views/controls/menu/controller.h" #include "chrome/views/view.h" #include "skia/include/SkBitmap.h" diff --git a/chrome/views/controls/message_box_view.cc b/chrome/views/controls/message_box_view.cc index 191b78c..6fb895a 100644 --- a/chrome/views/controls/message_box_view.cc +++ b/chrome/views/controls/message_box_view.cc @@ -5,13 +5,13 @@ #include "chrome/views/controls/message_box_view.h" #include "app/l10n_util.h" +#include "app/message_box_flags.h" #include "base/clipboard.h" #include "base/message_loop.h" #include "base/scoped_clipboard_writer.h" #include "base/string_util.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/views/standard_layout.h" -#include "chrome/common/message_box_flags.h" #include "chrome/views/controls/button/checkbox.h" #include "chrome/views/window/client_view.h" #include "grit/generated_resources.h" diff --git a/chrome/views/controls/table/table_view.cc b/chrome/views/controls/table/table_view.cc index ecb9773..445c262 100644 --- a/chrome/views/controls/table/table_view.cc +++ b/chrome/views/controls/table/table_view.cc @@ -8,12 +8,12 @@ #include <windowsx.h> #include "app/gfx/chrome_canvas.h" +#include "app/gfx/favicon_size.h" +#include "app/gfx/icon_util.h" #include "app/l10n_util_win.h" #include "app/resource_bundle.h" #include "base/string_util.h" #include "base/win_util.h" -#include "chrome/common/gfx/favicon_size.h" -#include "chrome/common/gfx/icon_util.h" #include "chrome/common/win_util.h" #include "chrome/views/controls/hwnd_view.h" #include "SkBitmap.h" diff --git a/chrome/views/controls/text_field.cc b/chrome/views/controls/text_field.cc index 4e61afd..0871cdf 100644 --- a/chrome/views/controls/text_field.cc +++ b/chrome/views/controls/text_field.cc @@ -11,6 +11,7 @@ #include <tom.h> // For ITextDocument, a COM interface to CRichEditCtrl #include <vsstyle.h> +#include "app/gfx/insets.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" #include "base/clipboard.h" @@ -19,8 +20,6 @@ #include "base/string_util.h" #include "base/win_util.h" #include "chrome/browser/browser_process.h" -#include "chrome/common/gfx/insets.h" -#include "chrome/common/logging_chrome.h" #include "chrome/common/win_util.h" #include "chrome/views/controls/hwnd_view.h" #include "chrome/views/controls/menu/menu.h" diff --git a/chrome/views/controls/throbber.cc b/chrome/views/controls/throbber.cc index de2a651..64d18e5 100644 --- a/chrome/views/controls/throbber.cc +++ b/chrome/views/controls/throbber.cc @@ -7,7 +7,6 @@ #include "app/gfx/chrome_canvas.h" #include "app/resource_bundle.h" #include "base/time.h" -#include "chrome/common/logging_chrome.h" #include "grit/theme_resources.h" #include "skia/include/SkBitmap.h" diff --git a/chrome/views/controls/tree/tree_view.cc b/chrome/views/controls/tree/tree_view.cc index e657658..1bf668c 100644 --- a/chrome/views/controls/tree/tree_view.cc +++ b/chrome/views/controls/tree/tree_view.cc @@ -7,12 +7,12 @@ #include <shellapi.h> #include "app/gfx/chrome_canvas.h" +#include "app/gfx/icon_util.h" #include "app/l10n_util.h" #include "app/l10n_util_win.h" #include "app/resource_bundle.h" #include "base/stl_util-inl.h" #include "base/win_util.h" -#include "chrome/common/gfx/icon_util.h" #include "chrome/views/focus/focus_manager.h" #include "chrome/views/widget/widget.h" #include "grit/theme_resources.h" diff --git a/chrome/views/event.cc b/chrome/views/event.cc index d0b375c..a968adc 100644 --- a/chrome/views/event.cc +++ b/chrome/views/event.cc @@ -5,9 +5,6 @@ #include "chrome/views/event.h" #include "chrome/views/view.h" -#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" - -using WebKit::WebInputEvent; namespace views { @@ -21,18 +18,6 @@ Event::Event(EventType type, int flags) flags_(flags) { } -// static -int Event::ConvertWebInputEventFlags(int web_input_event_flags) { - int r = 0; - if (web_input_event_flags & WebInputEvent::ShiftKey) - r |= EF_SHIFT_DOWN; - if (web_input_event_flags & WebInputEvent::ControlKey) - r |= EF_CONTROL_DOWN; - if (web_input_event_flags & WebInputEvent::AltKey) - r |= EF_ALT_DOWN; - return r; -} - LocatedEvent::LocatedEvent(const LocatedEvent& model, View* from, View* to) : Event(model), location_(model.location_) { diff --git a/chrome/views/event.h b/chrome/views/event.h index 3171ad4..d3dbb61 100644 --- a/chrome/views/event.h +++ b/chrome/views/event.h @@ -12,7 +12,6 @@ #endif #include "base/gfx/point.h" -#include "webkit/glue/window_open_disposition.h" class OSExchangeData; @@ -100,10 +99,6 @@ class Event { static int GetFlagsFromGdkState(int state); #endif - // Convert WebInputEvent::Modifiers flags to views::Event flags. - // Note that this only deals with keyboard modifiers. - static int ConvertWebInputEventFlags(int web_input_event_flags); - protected: Event(EventType type, int flags); diff --git a/chrome/views/view.cc b/chrome/views/view.cc index 22ab762..8c2a888 100644 --- a/chrome/views/view.cc +++ b/chrome/views/view.cc @@ -9,13 +9,13 @@ #include <iostream> #endif +#include "app/drag_drop_types.h" #include "app/gfx/chrome_canvas.h" #include "app/l10n_util.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/scoped_handle.h" #include "base/string_util.h" -#include "chrome/common/drag_drop_types.h" #include "chrome/views/background.h" #include "chrome/views/layout_manager.h" #include "chrome/views/widget/root_view.h" diff --git a/chrome/views/view_unittest.cc b/chrome/views/view_unittest.cc index ad14e81..da8c6ff 100644 --- a/chrome/views/view_unittest.cc +++ b/chrome/views/view_unittest.cc @@ -3,10 +3,10 @@ // found in the LICENSE file. #include "app/gfx/chrome_canvas.h" +#include "app/gfx/path.h" #include "base/clipboard.h" #include "base/message_loop.h" #include "chrome/browser/browser_process.h" -#include "chrome/common/gfx/path.h" #include "chrome/common/notification_service.h" #include "chrome/views/background.h" #include "chrome/views/controls/button/checkbox.h" diff --git a/chrome/views/view_win.cc b/chrome/views/view_win.cc index 41e97a9..382e169 100644 --- a/chrome/views/view_win.cc +++ b/chrome/views/view_win.cc @@ -4,12 +4,12 @@ #include "chrome/views/view.h" +#include "app/drag_drop_types.h" #include "app/gfx/chrome_canvas.h" +#include "app/gfx/path.h" +#include "app/os_exchange_data.h" #include "base/scoped_handle.h" #include "base/string_util.h" -#include "chrome/common/drag_drop_types.h" -#include "chrome/common/gfx/path.h" -#include "chrome/common/os_exchange_data.h" #include "chrome/views/accessibility/view_accessibility_wrapper.h" #include "chrome/views/border.h" #include "chrome/views/widget/root_view.h" diff --git a/chrome/views/widget/root_view.cc b/chrome/views/widget/root_view.cc index 8d7b047..bd57fe4 100644 --- a/chrome/views/widget/root_view.cc +++ b/chrome/views/widget/root_view.cc @@ -6,13 +6,13 @@ #include <algorithm> +#include "app/drag_drop_types.h" #include "app/gfx/chrome_canvas.h" #if defined(OS_WIN) #include "base/base_drag_source.h" #endif #include "base/logging.h" #include "base/message_loop.h" -#include "chrome/common/drag_drop_types.h" #include "chrome/common/notification_service.h" #if defined(OS_WIN) #include "chrome/views/widget/root_view_drop_target.h" diff --git a/chrome/views/widget/root_view_drop_target.cc b/chrome/views/widget/root_view_drop_target.cc index 60324c5..832caac 100644 --- a/chrome/views/widget/root_view_drop_target.cc +++ b/chrome/views/widget/root_view_drop_target.cc @@ -4,8 +4,8 @@ #include "chrome/views/widget/root_view_drop_target.h" +#include "app/drag_drop_types.h" #include "base/gfx/point.h" -#include "chrome/common/drag_drop_types.h" #include "chrome/views/widget/root_view.h" #include "chrome/views/widget/widget.h" diff --git a/chrome/views/widget/root_view_drop_target.h b/chrome/views/widget/root_view_drop_target.h index 02ce6c6..3e3aec1 100644 --- a/chrome/views/widget/root_view_drop_target.h +++ b/chrome/views/widget/root_view_drop_target.h @@ -9,8 +9,8 @@ #include <atlapp.h> #include <atlmisc.h> +#include "app/os_exchange_data.h" #include "base/base_drop_target.h" -#include "chrome/common/os_exchange_data.h" namespace gfx { class Point; diff --git a/chrome/views/widget/root_view_win.cc b/chrome/views/widget/root_view_win.cc index 17efd54..14bd9c5 100644 --- a/chrome/views/widget/root_view_win.cc +++ b/chrome/views/widget/root_view_win.cc @@ -4,10 +4,10 @@ #include "chrome/views/widget/root_view.h" +#include "app/drag_drop_types.h" #include "app/gfx/chrome_canvas.h" #include "base/base_drag_source.h" #include "base/logging.h" -#include "chrome/common/drag_drop_types.h" #include "chrome/views/widget/root_view_drop_target.h" namespace views { diff --git a/chrome/views/window/custom_frame_view.cc b/chrome/views/window/custom_frame_view.cc index d5d587e..4c824af 100644 --- a/chrome/views/window/custom_frame_view.cc +++ b/chrome/views/window/custom_frame_view.cc @@ -6,9 +6,9 @@ #include "app/gfx/chrome_canvas.h" #include "app/gfx/chrome_font.h" +#include "app/gfx/path.h" #include "app/resource_bundle.h" #include "base/win_util.h" -#include "chrome/common/gfx/path.h" #include "chrome/common/win_util.h" #include "chrome/views/window/client_view.h" #include "chrome/views/window/window_delegate.h" diff --git a/chrome/views/window/dialog_delegate.h b/chrome/views/window/dialog_delegate.h index 8add450..a38100c 100644 --- a/chrome/views/window/dialog_delegate.h +++ b/chrome/views/window/dialog_delegate.h @@ -5,7 +5,7 @@ #ifndef CHROME_VIEWS_WINDOW_DIALOG_DELEGATE_H_ #define CHROME_VIEWS_WINDOW_DIALOG_DELEGATE_H_ -#include "chrome/common/message_box_flags.h" +#include "app/message_box_flags.h" #include "chrome/views/window/dialog_client_view.h" #include "chrome/views/window/window_delegate.h" diff --git a/chrome/views/window/window_win.cc b/chrome/views/window/window_win.cc index 58301f5..0093b3a 100644 --- a/chrome/views/window/window_win.cc +++ b/chrome/views/window/window_win.cc @@ -8,12 +8,12 @@ #include "app/gfx/chrome_canvas.h" #include "app/gfx/chrome_font.h" +#include "app/gfx/icon_util.h" +#include "app/gfx/path.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/win_util.h" #include "chrome/app/chrome_dll_resource.h" -#include "chrome/common/gfx/icon_util.h" -#include "chrome/common/gfx/path.h" #include "chrome/common/notification_service.h" #include "chrome/common/pref_service.h" #include "chrome/common/win_util.h" |