diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-10 18:32:14 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-10 18:32:14 +0000 |
commit | 6e64343accab0d5b5436645e40a36f5ff20d17ec (patch) | |
tree | cbf33d783e15f8fcd27bd1c27b79046fac0fb4be /chrome | |
parent | ede729d4d7a1e6a1dc07d58e0fff2ca5cc6e7131 (diff) | |
download | chromium_src-6e64343accab0d5b5436645e40a36f5ff20d17ec.zip chromium_src-6e64343accab0d5b5436645e40a36f5ff20d17ec.tar.gz chromium_src-6e64343accab0d5b5436645e40a36f5ff20d17ec.tar.bz2 |
Final removal of the bad dependency of chrome/common on chrome/browser
Also convert app/gtk_dnd_util.h from a class to a namespace for consistency
with added app/gtk_util.h.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/669268
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41177 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
35 files changed, 130 insertions, 241 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc index 00f6755..8cadec5 100644 --- a/chrome/browser/browser_main.cc +++ b/chrome/browser/browser_main.cc @@ -109,6 +109,7 @@ #include "chrome/browser/rlz/rlz.h" #include "chrome/browser/views/user_data_dir_dialog.h" #include "chrome/common/env_vars.h" +#include "chrome/common/sandbox_policy.h" #include "chrome/installer/util/helper.h" #include "chrome/installer/util/install_util.h" #include "chrome/installer/util/shell_util.h" @@ -507,7 +508,7 @@ int BrowserMain(const MainFunctionParams& parameters) { sandbox::BrokerServices* broker_services = parameters.sandbox_info_.BrokerServices(); if (broker_services) { - browser_process->InitBrokerServices(broker_services); + sandbox::InitBrokerServices(broker_services); if (!parsed_command_line.HasSwitch(switches::kNoSandbox)) { bool use_winsta = !parsed_command_line.HasSwitch( switches::kDisableAltWinstation); diff --git a/chrome/browser/browser_process.h b/chrome/browser/browser_process.h index efab8d7..136d3be 100644 --- a/chrome/browser/browser_process.h +++ b/chrome/browser/browser_process.h @@ -39,12 +39,6 @@ class Thread; class WaitableEvent; } -#if defined(OS_WIN) -namespace sandbox { -class BrokerServices; -} -#endif // defined(OS_WIN) - namespace printing { class PrintJobManager; } @@ -109,11 +103,6 @@ class BrowserProcess { virtual base::Thread* background_x11_thread() = 0; #endif -#if defined(OS_WIN) - virtual sandbox::BrokerServices* broker_services() = 0; - virtual void InitBrokerServices(sandbox::BrokerServices*) = 0; -#endif // defined(OS_WIN) - virtual IconManager* icon_manager() = 0; virtual ThumbnailGenerator* GetThumbnailGenerator() = 0; diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 9e9e1b0..cf25fb6 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -67,10 +67,6 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) created_process_launcher_thread_(false), created_profile_manager_(false), created_local_state_(false), -#if defined(OS_WIN) - initialized_broker_services_(false), - broker_services_(NULL), -#endif // defined(OS_WIN) created_icon_manager_(false), created_debugger_wrapper_(false), created_devtools_manager_(false), @@ -379,16 +375,6 @@ void BrowserProcessImpl::CreateLocalState() { local_state_.reset(new PrefService(local_state_path)); } -#if defined(OS_WIN) -void BrowserProcessImpl::InitBrokerServices( - sandbox::BrokerServices* broker_services) { - DCHECK(!initialized_broker_services_ && broker_services_ == NULL); - broker_services->Init(); - initialized_broker_services_ = true; - broker_services_ = broker_services; -} -#endif // defined(OS_WIN) - void BrowserProcessImpl::CreateIconManager() { DCHECK(!created_icon_manager_ && icon_manager_.get() == NULL); created_icon_manager_ = true; diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h index 118400e..d6d870b 100644 --- a/chrome/browser/browser_process_impl.h +++ b/chrome/browser/browser_process_impl.h @@ -21,10 +21,6 @@ #include "chrome/browser/tab_contents/thumbnail_generator.h" #include "ipc/ipc_message.h" -#if defined(OS_WIN) -#include "sandbox/src/sandbox.h" -#endif - class CommandLine; class FilePath; class NotificationService; @@ -103,17 +99,6 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe { return local_state_.get(); } -#if defined(OS_WIN) - virtual sandbox::BrokerServices* broker_services() { - // TODO(abarth): DCHECK(CalledOnValidThread()); - // See <http://b/1287166>. - if (!initialized_broker_services_) - return NULL; - return broker_services_; - } - void InitBrokerServices(sandbox::BrokerServices* broker_services); -#endif // defined(OS_WIN) - virtual DebuggerWrapper* debugger_wrapper() { DCHECK(CalledOnValidThread()); if (!created_debugger_wrapper_) @@ -276,11 +261,6 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe { bool created_local_state_; scoped_ptr<PrefService> local_state_; -#if defined(OS_WIN) - bool initialized_broker_services_; - sandbox::BrokerServices* broker_services_; -#endif // defined(OS_WIN) - bool created_icon_manager_; scoped_ptr<IconManager> icon_manager_; diff --git a/chrome/browser/cookie_modal_dialog_gtk.cc b/chrome/browser/cookie_modal_dialog_gtk.cc index 54ce2e2..4ff08f6 100644 --- a/chrome/browser/cookie_modal_dialog_gtk.cc +++ b/chrome/browser/cookie_modal_dialog_gtk.cc @@ -4,6 +4,7 @@ #include "chrome/browser/cookie_modal_dialog.h" +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "base/logging.h" #include "base/string_util.h" diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc index 19fe0b2..1105bf9b 100644 --- a/chrome/browser/gtk/bookmark_bar_gtk.cc +++ b/chrome/browser/gtk/bookmark_bar_gtk.cc @@ -78,10 +78,10 @@ const double kTopBorderColor[] = { 222.0 / 255.0, 234.0 / 255.0, 248.0 / 255.0 }; // The targets accepted by the toolbar and folder buttons for DnD. -const int kDestTargetList[] = { GtkDndUtil::CHROME_BOOKMARK_ITEM, - GtkDndUtil::CHROME_NAMED_URL, - GtkDndUtil::TEXT_URI_LIST, - GtkDndUtil::TEXT_PLAIN, -1 }; +const int kDestTargetList[] = { gtk_dnd_util::CHROME_BOOKMARK_ITEM, + gtk_dnd_util::CHROME_NAMED_URL, + gtk_dnd_util::TEXT_URI_LIST, + gtk_dnd_util::TEXT_PLAIN, -1 }; // Acceptable drag actions for the bookmark bar drag destinations. const GdkDragAction kDragAction = @@ -218,7 +218,7 @@ void BookmarkBarGtk::Init(Profile* profile) { gtk_drag_dest_set(instructions_, GtkDestDefaults(GTK_DEST_DEFAULT_DROP | GTK_DEST_DEFAULT_MOTION), NULL, 0, kDragAction); - GtkDndUtil::SetDestTargetList(instructions_, kDestTargetList); + gtk_dnd_util::SetDestTargetList(instructions_, kDestTargetList); g_signal_connect(instructions_, "drag-data-received", G_CALLBACK(&OnDragReceived), this); @@ -245,7 +245,7 @@ void BookmarkBarGtk::Init(Profile* profile) { gtk_drag_dest_set(bookmark_toolbar_.get(), GTK_DEST_DEFAULT_DROP, NULL, 0, kDragAction); - GtkDndUtil::SetDestTargetList(bookmark_toolbar_.get(), kDestTargetList); + gtk_dnd_util::SetDestTargetList(bookmark_toolbar_.get(), kDestTargetList); g_signal_connect(bookmark_toolbar_.get(), "drag-motion", G_CALLBACK(&OnToolbarDragMotion), this); g_signal_connect(bookmark_toolbar_.get(), "drag-leave", @@ -837,13 +837,13 @@ GtkWidget* BookmarkBarGtk::CreateBookmarkButton(const BookmarkNode* node) { // The tool item is also a source for dragging gtk_drag_source_set(button, GDK_BUTTON1_MASK, NULL, 0, static_cast<GdkDragAction>(GDK_ACTION_MOVE | GDK_ACTION_COPY)); - int target_mask = GtkDndUtil::CHROME_BOOKMARK_ITEM; + int target_mask = gtk_dnd_util::CHROME_BOOKMARK_ITEM; if (node->is_url()) { - target_mask |= GtkDndUtil::TEXT_URI_LIST | - GtkDndUtil::TEXT_PLAIN | - GtkDndUtil::NETSCAPE_URL; + target_mask |= gtk_dnd_util::TEXT_URI_LIST | + gtk_dnd_util::TEXT_PLAIN | + gtk_dnd_util::NETSCAPE_URL; } - GtkDndUtil::SetSourceTargetListFromCodeMask(button, target_mask); + gtk_dnd_util::SetSourceTargetListFromCodeMask(button, target_mask); g_signal_connect(button, "drag-begin", G_CALLBACK(&OnButtonDragBegin), this); g_signal_connect(button, "drag-end", @@ -884,7 +884,7 @@ GtkToolItem* BookmarkBarGtk::CreateBookmarkToolItem(const BookmarkNode* node) { void BookmarkBarGtk::ConnectFolderButtonEvents(GtkWidget* widget) { gtk_drag_dest_set(widget, GTK_DEST_DEFAULT_ALL, NULL, 0, kDragAction); - GtkDndUtil::SetDestTargetList(widget, kDestTargetList); + gtk_dnd_util::SetDestTargetList(widget, kDestTargetList); g_signal_connect(widget, "drag-data-received", G_CALLBACK(&OnDragReceived), this); @@ -1110,7 +1110,7 @@ gboolean BookmarkBarGtk::OnToolbarDragMotion(GtkToolbar* toolbar, } if (target_type == - GtkDndUtil::GetAtomForTarget(GtkDndUtil::CHROME_BOOKMARK_ITEM)) { + gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::CHROME_BOOKMARK_ITEM)) { gdk_drag_status(context, GDK_ACTION_MOVE, time); } else { gdk_drag_status(context, GDK_ACTION_COPY, time); @@ -1174,7 +1174,7 @@ void BookmarkBarGtk::OnDragReceived(GtkWidget* widget, } switch (target_type) { - case GtkDndUtil::CHROME_BOOKMARK_ITEM: { + case gtk_dnd_util::CHROME_BOOKMARK_ITEM: { std::vector<const BookmarkNode*> nodes = bookmark_utils::GetNodesFromSelection(context, selection_data, target_type, @@ -1190,19 +1190,19 @@ void BookmarkBarGtk::OnDragReceived(GtkWidget* widget, break; } - case GtkDndUtil::CHROME_NAMED_URL: { + case gtk_dnd_util::CHROME_NAMED_URL: { dnd_success = bookmark_utils::CreateNewBookmarkFromNamedUrl( selection_data, bar->model_, dest_node, index); break; } - case GtkDndUtil::TEXT_URI_LIST: { + case gtk_dnd_util::TEXT_URI_LIST: { dnd_success = bookmark_utils::CreateNewBookmarksFromURIList( selection_data, bar->model_, dest_node, index); break; } - case GtkDndUtil::TEXT_PLAIN: { + case gtk_dnd_util::TEXT_PLAIN: { guchar* text = gtk_selection_data_get_text(selection_data); if (!text) break; diff --git a/chrome/browser/gtk/bookmark_manager_gtk.cc b/chrome/browser/gtk/bookmark_manager_gtk.cc index b856ace..b023a44c 100644 --- a/chrome/browser/gtk/bookmark_manager_gtk.cc +++ b/chrome/browser/gtk/bookmark_manager_gtk.cc @@ -58,13 +58,13 @@ const int kSearchDelayMS = 200; const int kDefaultColumnWidth = 200; // The destination targets that the right tree view accepts for dragging. -const int kDestTargetList[] = { GtkDndUtil::CHROME_BOOKMARK_ITEM, -1 }; +const int kDestTargetList[] = { gtk_dnd_util::CHROME_BOOKMARK_ITEM, -1 }; // The source targets that the right tree view supports for dragging. -const int kSourceTargetMask = GtkDndUtil::CHROME_BOOKMARK_ITEM | - GtkDndUtil::TEXT_URI_LIST | - GtkDndUtil::TEXT_PLAIN | - GtkDndUtil::NETSCAPE_URL; +const int kSourceTargetMask = gtk_dnd_util::CHROME_BOOKMARK_ITEM | + gtk_dnd_util::TEXT_URI_LIST | + gtk_dnd_util::TEXT_PLAIN | + gtk_dnd_util::NETSCAPE_URL; // We only have one manager open at a time. BookmarkManagerGtk* manager = NULL; @@ -481,7 +481,7 @@ GtkWidget* BookmarkManagerGtk::MakeLeftPane() { // The left side is only a drag destination (not a source). gtk_drag_dest_set(left_tree_view_, GTK_DEST_DEFAULT_DROP, NULL, 0, GDK_ACTION_MOVE); - GtkDndUtil::SetDestTargetList(left_tree_view_, kDestTargetList); + gtk_dnd_util::SetDestTargetList(left_tree_view_, kDestTargetList); g_signal_connect(left_tree_view_, "drag-data-received", G_CALLBACK(&OnLeftTreeViewDragReceived), this); @@ -558,7 +558,7 @@ GtkWidget* BookmarkManagerGtk::MakeRightPane() { gtk_drag_source_set(right_tree_view_, GDK_BUTTON1_MASK, NULL, 0, static_cast<GdkDragAction>(GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK)); - GtkDndUtil::SetSourceTargetListFromCodeMask( + gtk_dnd_util::SetSourceTargetListFromCodeMask( right_tree_view_, kSourceTargetMask); // We connect to drag dest signals, but we don't actually enable the widget @@ -714,7 +714,7 @@ void BookmarkManagerGtk::ResetRightStoreModel() { gtk_drag_dest_set(right_tree_view_, GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_MOVE); - GtkDndUtil::SetDestTargetList(right_tree_view_, kDestTargetList); + gtk_dnd_util::SetDestTargetList(right_tree_view_, kDestTargetList); } else { SaveColumnConfiguration(); gtk_tree_view_column_set_visible(path_column_, TRUE); @@ -1300,7 +1300,7 @@ gboolean BookmarkManagerGtk::OnRightTreeViewMotion( static_cast<gint>(event->x), static_cast<gint>(event->y))) { bm->delaying_mousedown_ = false; - GtkTargetList* targets = GtkDndUtil::GetTargetListFromCodeMask( + GtkTargetList* targets = gtk_dnd_util::GetTargetListFromCodeMask( kSourceTargetMask); gtk_drag_begin(tree_view, targets, GDK_ACTION_MOVE, 1, reinterpret_cast<GdkEvent*>(event)); diff --git a/chrome/browser/gtk/bookmark_menu_controller_gtk.cc b/chrome/browser/gtk/bookmark_menu_controller_gtk.cc index b284f91..754e506 100644 --- a/chrome/browser/gtk/bookmark_menu_controller_gtk.cc +++ b/chrome/browser/gtk/bookmark_menu_controller_gtk.cc @@ -188,10 +188,10 @@ void BookmarkMenuController::BuildMenu(const BookmarkNode* parent, gtk_drag_source_set(menu_item, GDK_BUTTON1_MASK, NULL, 0, static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_LINK)); - int target_mask = GtkDndUtil::CHROME_BOOKMARK_ITEM; + int target_mask = gtk_dnd_util::CHROME_BOOKMARK_ITEM; if (node->is_url()) - target_mask |= GtkDndUtil::TEXT_URI_LIST | GtkDndUtil::NETSCAPE_URL; - GtkDndUtil::SetSourceTargetListFromCodeMask(menu_item, target_mask); + target_mask |= gtk_dnd_util::TEXT_URI_LIST | gtk_dnd_util::NETSCAPE_URL; + gtk_dnd_util::SetSourceTargetListFromCodeMask(menu_item, target_mask); g_signal_connect(menu_item, "drag-begin", G_CALLBACK(&OnMenuItemDragBegin), this); g_signal_connect(menu_item, "drag-end", diff --git a/chrome/browser/gtk/bookmark_utils_gtk.cc b/chrome/browser/gtk/bookmark_utils_gtk.cc index c7d5770..880731d 100644 --- a/chrome/browser/gtk/bookmark_utils_gtk.cc +++ b/chrome/browser/gtk/bookmark_utils_gtk.cc @@ -213,7 +213,7 @@ void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, guint target_type, Profile* profile) { switch (target_type) { - case GtkDndUtil::CHROME_BOOKMARK_ITEM: { + case gtk_dnd_util::CHROME_BOOKMARK_ITEM: { BookmarkDragData data(nodes); Pickle pickle; data.WriteToPickle(profile, &pickle); @@ -224,7 +224,7 @@ void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, pickle.size()); break; } - case GtkDndUtil::NETSCAPE_URL: { + case gtk_dnd_util::NETSCAPE_URL: { // _NETSCAPE_URL format is URL + \n + title. std::string utf8_text = nodes[0]->GetURL().spec() + "\n" + UTF16ToUTF8( nodes[0]->GetTitleAsString16()); @@ -235,7 +235,7 @@ void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, utf8_text.length()); break; } - case GtkDndUtil::TEXT_URI_LIST: { + case gtk_dnd_util::TEXT_URI_LIST: { gchar** uris = reinterpret_cast<gchar**>(malloc(sizeof(gchar*) * (nodes.size() + 1))); for (size_t i = 0; i < nodes.size(); ++i) { @@ -253,7 +253,7 @@ void WriteBookmarksToSelection(const std::vector<const BookmarkNode*>& nodes, free(uris); break; } - case GtkDndUtil::TEXT_PLAIN: { + case gtk_dnd_util::TEXT_PLAIN: { gtk_selection_data_set_text(selection_data, nodes[0]->GetURL().spec().c_str(), -1); break; @@ -281,7 +281,7 @@ std::vector<const BookmarkNode*> GetNodesFromSelection( } switch (target_type) { - case GtkDndUtil::CHROME_BOOKMARK_ITEM: { + case gtk_dnd_util::CHROME_BOOKMARK_ITEM: { *dnd_success = TRUE; Pickle pickle(reinterpret_cast<char*>(selection_data->data), selection_data->length); @@ -302,7 +302,7 @@ bool CreateNewBookmarkFromNamedUrl(GtkSelectionData* selection_data, BookmarkModel* model, const BookmarkNode* parent, int idx) { GURL url; string16 title; - if (!GtkDndUtil::ExtractNamedURL(selection_data, &url, &title)) + if (!gtk_dnd_util::ExtractNamedURL(selection_data, &url, &title)) return false; model->AddURL(parent, idx, UTF16ToWideHack(title), url); @@ -312,7 +312,7 @@ bool CreateNewBookmarkFromNamedUrl(GtkSelectionData* selection_data, bool CreateNewBookmarksFromURIList(GtkSelectionData* selection_data, BookmarkModel* model, const BookmarkNode* parent, int idx) { std::vector<GURL> urls; - GtkDndUtil::ExtractURIList(selection_data, &urls); + gtk_dnd_util::ExtractURIList(selection_data, &urls); for (size_t i = 0; i < urls.size(); ++i) { std::string title = GetNameForURL(urls[i]); model->AddURL(parent, idx++, UTF8ToWide(title), urls[i]); diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc index 030a18d..403e38e 100644 --- a/chrome/browser/gtk/browser_toolbar_gtk.cc +++ b/chrome/browser/gtk/browser_toolbar_gtk.cc @@ -525,9 +525,9 @@ GtkWidget* BrowserToolbarGtk::BuildToolbarMenuButton( void BrowserToolbarGtk::SetUpDragForHomeButton() { gtk_drag_dest_set(home_->widget(), GTK_DEST_DEFAULT_ALL, NULL, 0, GDK_ACTION_COPY); - static const int targets[] = { GtkDndUtil::TEXT_PLAIN, - GtkDndUtil::TEXT_URI_LIST, -1 }; - GtkDndUtil::SetDestTargetList(home_->widget(), targets); + static const int targets[] = { gtk_dnd_util::TEXT_PLAIN, + gtk_dnd_util::TEXT_URI_LIST, -1 }; + gtk_dnd_util::SetDestTargetList(home_->widget(), targets); g_signal_connect(home_->widget(), "drag-data-received", G_CALLBACK(OnDragDataReceived), this); @@ -674,7 +674,7 @@ void BrowserToolbarGtk::OnDragDataReceived(GtkWidget* widget, GdkDragContext* drag_context, gint x, gint y, GtkSelectionData* data, guint info, guint time, BrowserToolbarGtk* toolbar) { - if (info != GtkDndUtil::TEXT_PLAIN) { + if (info != gtk_dnd_util::TEXT_PLAIN) { NOTIMPLEMENTED() << "Only support plain text drops for now, sorry!"; return; } diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc index 6bcb176..f1dc892 100644 --- a/chrome/browser/gtk/browser_window_gtk.cc +++ b/chrome/browser/gtk/browser_window_gtk.cc @@ -11,6 +11,7 @@ #include "app/gfx/color_utils.h" #include "app/gfx/gtk_util.h" #include "app/gfx/skia_utils_gtk.h" +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/theme_provider.h" diff --git a/chrome/browser/gtk/download_item_drag.cc b/chrome/browser/gtk/download_item_drag.cc index 9ad1c2e..ed5a8dd 100644 --- a/chrome/browser/gtk/download_item_drag.cc +++ b/chrome/browser/gtk/download_item_drag.cc @@ -14,8 +14,8 @@ namespace { -const int kCodeMask = GtkDndUtil::TEXT_URI_LIST | - GtkDndUtil::CHROME_NAMED_URL; +const int kCodeMask = gtk_dnd_util::TEXT_URI_LIST | + gtk_dnd_util::CHROME_NAMED_URL; const GdkDragAction kDragAction = GDK_ACTION_COPY; void OnDragDataGet(GtkWidget* widget, GdkDragContext* context, @@ -23,7 +23,7 @@ void OnDragDataGet(GtkWidget* widget, GdkDragContext* context, guint target_type, guint time, DownloadItem* download_item) { GURL url = net::FilePathToFileURL(download_item->full_path()); - GtkDndUtil::WriteURLWithName(selection_data, url, + gtk_dnd_util::WriteURLWithName(selection_data, url, UTF8ToUTF16(download_item->GetFileName().value()), target_type); } @@ -33,7 +33,7 @@ void OnDragDataGet(GtkWidget* widget, GdkDragContext* context, void DownloadItemDrag::SetSource(GtkWidget* widget, DownloadItem* item) { gtk_drag_source_set(widget, GDK_BUTTON1_MASK, NULL, 0, kDragAction); - GtkDndUtil::SetSourceTargetListFromCodeMask(widget, kCodeMask); + gtk_dnd_util::SetSourceTargetListFromCodeMask(widget, kCodeMask); g_signal_connect(widget, "drag-data-get", G_CALLBACK(OnDragDataGet), item); } @@ -55,7 +55,7 @@ DownloadItemDrag::DownloadItemDrag(const DownloadItem* item, g_signal_connect(drag_widget_, "drag-end", G_CALLBACK(OnDragEnd), this); - GtkTargetList* list = GtkDndUtil::GetTargetListFromCodeMask(kCodeMask); + GtkTargetList* list = gtk_dnd_util::GetTargetListFromCodeMask(kCodeMask); GdkEvent* event = gtk_get_current_event(); gtk_drag_begin(drag_widget_, list, kDragAction, 1, event); if (event) diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc index d2c940c..264b003 100644 --- a/chrome/browser/gtk/download_item_gtk.cc +++ b/chrome/browser/gtk/download_item_gtk.cc @@ -4,6 +4,7 @@ #include "chrome/browser/gtk/download_item_gtk.h" +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "app/gfx/canvas_paint.h" #include "app/gfx/color_utils.h" diff --git a/chrome/browser/gtk/first_run_bubble.cc b/chrome/browser/gtk/first_run_bubble.cc index e502781..eff6f9d 100644 --- a/chrome/browser/gtk/first_run_bubble.cc +++ b/chrome/browser/gtk/first_run_bubble.cc @@ -7,10 +7,10 @@ #include <gtk/gtk.h> #include "app/gfx/gtk_util.h" +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "base/utf_string_conversions.h" #include "chrome/browser/gtk/gtk_theme_provider.h" -#include "chrome/browser/gtk/gtk_util.h" #include "chrome/browser/options_window.h" #include "chrome/browser/search_engines/template_url_model.h" #include "chrome/common/notification_service.h" diff --git a/chrome/browser/gtk/gtk_util.cc b/chrome/browser/gtk/gtk_util.cc index 465202b..88b60fb 100644 --- a/chrome/browser/gtk/gtk_util.cc +++ b/chrome/browser/gtk/gtk_util.cc @@ -10,6 +10,7 @@ #include <cstdarg> #include <map> +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/linux_util.h" @@ -202,44 +203,6 @@ GtkWidget* CreateBoldLabel(const std::string& text) { return LeftAlignMisc(label); } -void GetWidgetSizeFromResources(GtkWidget* widget, int width_chars, - int height_lines, int* width, int* height) { - DCHECK(GTK_WIDGET_REALIZED(widget)) - << " widget must be realized to compute font metrics correctly"; - - double chars = 0; - if (width) - StringToDouble(l10n_util::GetStringUTF8(width_chars), &chars); - - double lines = 0; - if (height) - StringToDouble(l10n_util::GetStringUTF8(height_lines), &lines); - - GetWidgetSizeFromCharacters(widget, chars, lines, width, height); -} - -void GetWidgetSizeFromCharacters(GtkWidget* widget, double width_chars, - double height_lines, int* width, int* height) { - DCHECK(GTK_WIDGET_REALIZED(widget)) - << " widget must be realized to compute font metrics correctly"; - PangoContext* context = gtk_widget_create_pango_context(widget); - PangoFontMetrics* metrics = pango_context_get_metrics(context, - widget->style->font_desc, pango_context_get_language(context)); - if (width) { - *width = static_cast<int>( - pango_font_metrics_get_approximate_char_width(metrics) * - width_chars / PANGO_SCALE); - } - if (height) { - *height = static_cast<int>( - (pango_font_metrics_get_ascent(metrics) + - pango_font_metrics_get_descent(metrics)) * - height_lines / PANGO_SCALE); - } - pango_font_metrics_unref(metrics); - g_object_unref(context); -} - void SetWindowSizeFromResources(GtkWindow* window, int width_id, int height_id, bool resizable) { int width = -1; @@ -839,16 +802,6 @@ gfx::Rect GetWidgetRectRelativeToToplevel(GtkWidget* widget) { return gfx::Rect(x, y, widget->allocation.width, widget->allocation.height); } -void ApplyMessageDialogQuirks(GtkWidget* dialog) { - if (gtk_window_get_modal(GTK_WINDOW(dialog))) { - // Work around a KDE 3 window manager bug. - scoped_ptr<base::EnvironmentVariableGetter> env( - base::EnvironmentVariableGetter::Create()); - if (base::DESKTOP_ENVIRONMENT_KDE3 == GetDesktopEnvironment(env.get())) - gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), FALSE); - } -} - void SuppressDefaultPainting(GtkWidget* container) { g_signal_connect(container, "expose-event", G_CALLBACK(PaintNoBackground), NULL); diff --git a/chrome/browser/gtk/gtk_util.h b/chrome/browser/gtk/gtk_util.h index a51470f..dad4d6b 100644 --- a/chrome/browser/gtk/gtk_util.h +++ b/chrome/browser/gtk/gtk_util.h @@ -78,18 +78,6 @@ GtkWidget* LeftAlignMisc(GtkWidget* misc); // Create a left-aligned label with the given text in bold. GtkWidget* CreateBoldLabel(const std::string& text); -// Calculates the size of given widget based on the size specified in -// number of characters/lines (in locale specific resource file) and -// font metrics. -// NOTE: Make sure to realize |widget| before using this method, or a -// default font size will be used instead of the actual font size. -void GetWidgetSizeFromResources(GtkWidget* widget, int width_chars, - int height_lines, int* width, int* height); - -// As above, but uses number of characters/lines directly rather than looking -// up a resource. -void GetWidgetSizeFromCharacters(GtkWidget* widget, double width_chars, - double height_lines, int* width, int* height); // As above, but a convenience method for configuring dialog size. // |width_id| and |height_id| are resource IDs for the size. If either of these @@ -244,11 +232,6 @@ void StackPopupWindow(GtkWidget* popup, GtkWidget* toplevel); // toplevel window's origin. gfx::Rect GetWidgetRectRelativeToToplevel(GtkWidget* widget); -// A helper function for gtk_message_dialog_new() to work around a KDE 3 window -// manager bugs. You should always call it after creating a dialog with -// gtk_message_dialog_new. -void ApplyMessageDialogQuirks(GtkWidget* dialog); - // Don't allow the widget to paint anything, and instead propagate the expose // to its children. This is similar to calling // diff --git a/chrome/browser/gtk/options/advanced_contents_gtk.cc b/chrome/browser/gtk/options/advanced_contents_gtk.cc index bed7964..665da0e 100644 --- a/chrome/browser/gtk/options/advanced_contents_gtk.cc +++ b/chrome/browser/gtk/options/advanced_contents_gtk.cc @@ -7,6 +7,7 @@ #include <sys/types.h> #include <sys/wait.h> +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "base/basictypes.h" #include "base/file_util.h" diff --git a/chrome/browser/gtk/options/advanced_page_gtk.cc b/chrome/browser/gtk/options/advanced_page_gtk.cc index 4c9d437..3440595 100644 --- a/chrome/browser/gtk/options/advanced_page_gtk.cc +++ b/chrome/browser/gtk/options/advanced_page_gtk.cc @@ -4,6 +4,7 @@ #include "chrome/browser/gtk/options/advanced_page_gtk.h" +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "chrome/browser/gtk/gtk_util.h" #include "chrome/browser/options_util.h" diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc index 64556cf..2789195 100644 --- a/chrome/browser/gtk/options/content_page_gtk.cc +++ b/chrome/browser/gtk/options/content_page_gtk.cc @@ -7,6 +7,7 @@ #include <string> #include "app/gfx/gtk_util.h" +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "chrome/browser/browser.h" diff --git a/chrome/browser/gtk/options/passwords_page_gtk.cc b/chrome/browser/gtk/options/passwords_page_gtk.cc index f52a901..5d21276 100644 --- a/chrome/browser/gtk/options/passwords_page_gtk.cc +++ b/chrome/browser/gtk/options/passwords_page_gtk.cc @@ -7,6 +7,7 @@ #include <string> #include "app/gfx/gtk_util.h" +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/utf_string_conversions.h" diff --git a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc index f89a199..fde744d 100644 --- a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc +++ b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc @@ -5,6 +5,7 @@ #include <gtk/gtk.h> #include "app/gfx/gtk_util.h" +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "base/message_loop.h" #include "base/utf_string_conversions.h" diff --git a/chrome/browser/gtk/process_singleton_dialog.cc b/chrome/browser/gtk/process_singleton_dialog.cc index 26fc1b4..cdd4eab 100644 --- a/chrome/browser/gtk/process_singleton_dialog.cc +++ b/chrome/browser/gtk/process_singleton_dialog.cc @@ -4,9 +4,9 @@ #include "chrome/browser/gtk/process_singleton_dialog.h" +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "base/message_loop.h" -#include "chrome/browser/gtk/gtk_util.h" #include "grit/chromium_strings.h" // static diff --git a/chrome/browser/gtk/repost_form_warning_gtk.cc b/chrome/browser/gtk/repost_form_warning_gtk.cc index 5245866..53d1ca1 100644 --- a/chrome/browser/gtk/repost_form_warning_gtk.cc +++ b/chrome/browser/gtk/repost_form_warning_gtk.cc @@ -4,6 +4,7 @@ #include "chrome/browser/gtk/repost_form_warning_gtk.h" +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "base/message_loop.h" #include "chrome/browser/gtk/gtk_util.h" diff --git a/chrome/browser/gtk/tab_contents_drag_source.cc b/chrome/browser/gtk/tab_contents_drag_source.cc index dbc7293..85ebe0c 100644 --- a/chrome/browser/gtk/tab_contents_drag_source.cc +++ b/chrome/browser/gtk/tab_contents_drag_source.cc @@ -73,22 +73,22 @@ void TabContentsDragSource::StartDragging(const WebDropData& drop_data, int targets_mask = 0; if (!drop_data.plain_text.empty()) - targets_mask |= GtkDndUtil::TEXT_PLAIN; + targets_mask |= gtk_dnd_util::TEXT_PLAIN; if (drop_data.url.is_valid()) { - targets_mask |= GtkDndUtil::TEXT_URI_LIST; - targets_mask |= GtkDndUtil::CHROME_NAMED_URL; - targets_mask |= GtkDndUtil::NETSCAPE_URL; + targets_mask |= gtk_dnd_util::TEXT_URI_LIST; + targets_mask |= gtk_dnd_util::CHROME_NAMED_URL; + targets_mask |= gtk_dnd_util::NETSCAPE_URL; } if (!drop_data.text_html.empty()) - targets_mask |= GtkDndUtil::TEXT_HTML; + targets_mask |= gtk_dnd_util::TEXT_HTML; if (!drop_data.file_contents.empty()) - targets_mask |= GtkDndUtil::CHROME_WEBDROP_FILE_CONTENTS; + targets_mask |= gtk_dnd_util::CHROME_WEBDROP_FILE_CONTENTS; if (!drop_data.download_metadata.empty() && drag_download_util::ParseDownloadMetadata(drop_data.download_metadata, &wide_download_mime_type_, &download_file_name_, &download_url_)) { - targets_mask |= GtkDndUtil::DIRECT_SAVE_FILE; + targets_mask |= gtk_dnd_util::DIRECT_SAVE_FILE; } if (targets_mask == 0) { @@ -99,12 +99,12 @@ void TabContentsDragSource::StartDragging(const WebDropData& drop_data, drop_data_.reset(new WebDropData(drop_data)); - GtkTargetList* list = GtkDndUtil::GetTargetListFromCodeMask(targets_mask); - if (targets_mask & GtkDndUtil::CHROME_WEBDROP_FILE_CONTENTS) { + GtkTargetList* list = gtk_dnd_util::GetTargetListFromCodeMask(targets_mask); + if (targets_mask & gtk_dnd_util::CHROME_WEBDROP_FILE_CONTENTS) { drag_file_mime_type_ = gdk_atom_intern( mime_util::GetDataMimeType(drop_data.file_contents).c_str(), FALSE); gtk_target_list_add(list, drag_file_mime_type_, - 0, GtkDndUtil::CHROME_WEBDROP_FILE_CONTENTS); + 0, gtk_dnd_util::CHROME_WEBDROP_FILE_CONTENTS); } drag_failed_ = false; @@ -161,35 +161,35 @@ void TabContentsDragSource::OnDragDataGet( const int kBitsPerByte = 8; switch (target_type) { - case GtkDndUtil::TEXT_PLAIN: { + case gtk_dnd_util::TEXT_PLAIN: { std::string utf8_text = UTF16ToUTF8(drop_data_->plain_text); gtk_selection_data_set_text(selection_data, utf8_text.c_str(), utf8_text.length()); break; } - case GtkDndUtil::TEXT_HTML: { + case gtk_dnd_util::TEXT_HTML: { // TODO(estade): change relative links to be absolute using // |html_base_url|. std::string utf8_text = UTF16ToUTF8(drop_data_->text_html); gtk_selection_data_set(selection_data, - GtkDndUtil::GetAtomForTarget( - GtkDndUtil::TEXT_HTML), + gtk_dnd_util::GetAtomForTarget( + gtk_dnd_util::TEXT_HTML), kBitsPerByte, reinterpret_cast<const guchar*>(utf8_text.c_str()), utf8_text.length()); break; } - case GtkDndUtil::TEXT_URI_LIST: - case GtkDndUtil::CHROME_NAMED_URL: - case GtkDndUtil::NETSCAPE_URL: { - GtkDndUtil::WriteURLWithName(selection_data, drop_data_->url, + case gtk_dnd_util::TEXT_URI_LIST: + case gtk_dnd_util::CHROME_NAMED_URL: + case gtk_dnd_util::NETSCAPE_URL: { + gtk_dnd_util::WriteURLWithName(selection_data, drop_data_->url, drop_data_->url_title, target_type); break; } - case GtkDndUtil::CHROME_WEBDROP_FILE_CONTENTS: { + case gtk_dnd_util::CHROME_WEBDROP_FILE_CONTENTS: { gtk_selection_data_set( selection_data, drag_file_mime_type_, kBitsPerByte, @@ -198,7 +198,7 @@ void TabContentsDragSource::OnDragDataGet( break; } - case GtkDndUtil::DIRECT_SAVE_FILE: { + case gtk_dnd_util::DIRECT_SAVE_FILE: { char status_code = 'E'; // Retrieves the full file path (in file URL format) provided by the @@ -207,10 +207,10 @@ void TabContentsDragSource::OnDragDataGet( gint file_url_len = 0; guchar* file_url_value = NULL; if (gdk_property_get(context->source_window, - GtkDndUtil::GetAtomForTarget( - GtkDndUtil::DIRECT_SAVE_FILE), - GtkDndUtil::GetAtomForTarget( - GtkDndUtil::TEXT_PLAIN_NO_CHARSET), + gtk_dnd_util::GetAtomForTarget( + gtk_dnd_util::DIRECT_SAVE_FILE), + gtk_dnd_util::GetAtomForTarget( + gtk_dnd_util::TEXT_PLAIN_NO_CHARSET), 0, 1024, FALSE, @@ -293,10 +293,10 @@ void TabContentsDragSource::OnDragBegin(GdkDragContext* drag_context) { // Pass the file name to the drop target by setting the source window's // XdndDirectSave0 property. gdk_property_change(drag_context->source_window, - GtkDndUtil::GetAtomForTarget( - GtkDndUtil::DIRECT_SAVE_FILE), - GtkDndUtil::GetAtomForTarget( - GtkDndUtil::TEXT_PLAIN_NO_CHARSET), + gtk_dnd_util::GetAtomForTarget( + gtk_dnd_util::DIRECT_SAVE_FILE), + gtk_dnd_util::GetAtomForTarget( + gtk_dnd_util::TEXT_PLAIN_NO_CHARSET), 8, GDK_PROP_MODE_REPLACE, reinterpret_cast<const guchar*>( @@ -311,8 +311,8 @@ void TabContentsDragSource::OnDragEnd(GdkDragContext* drag_context, if (!download_url_.is_empty()) { gdk_property_delete(drag_context->source_window, - GtkDndUtil::GetAtomForTarget( - GtkDndUtil::DIRECT_SAVE_FILE)); + gtk_dnd_util::GetAtomForTarget( + gtk_dnd_util::DIRECT_SAVE_FILE)); } if (!drag_failed_) { diff --git a/chrome/browser/gtk/tabs/tab_gtk.cc b/chrome/browser/gtk/tabs/tab_gtk.cc index 64c5404..165b789 100644 --- a/chrome/browser/gtk/tabs/tab_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_gtk.cc @@ -389,8 +389,8 @@ void TabGtk::DestroyDragWidget() { void TabGtk::StartDragging(gfx::Point drag_offset) { CreateDragWidget(); - GtkTargetList* list = GtkDndUtil::GetTargetListFromCodeMask( - GtkDndUtil::CHROME_TAB); + GtkTargetList* list = gtk_dnd_util::GetTargetListFromCodeMask( + gtk_dnd_util::CHROME_TAB); gtk_drag_begin(drag_widget_, list, GDK_ACTION_MOVE, 1, // Drags are always initiated by the left button. last_mouse_down_); diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc index ec8c893..7c52293 100644 --- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc +++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc @@ -731,10 +731,10 @@ void TabStripGtk::Init() { NULL, 0, static_cast<GdkDragAction>( GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK)); - static const int targets[] = { GtkDndUtil::TEXT_URI_LIST, - GtkDndUtil::NETSCAPE_URL, + static const int targets[] = { gtk_dnd_util::TEXT_URI_LIST, + gtk_dnd_util::NETSCAPE_URL, -1 }; - GtkDndUtil::SetDestTargetList(tabstrip_.get(), targets); + gtk_dnd_util::SetDestTargetList(tabstrip_.get(), targets); g_signal_connect(tabstrip_.get(), "expose-event", G_CALLBACK(OnExpose), this); @@ -1962,8 +1962,8 @@ gboolean TabStripGtk::OnDragDataReceived(GtkWidget* widget, TabStripGtk* tabstrip) { bool success = false; - if (info == GtkDndUtil::TEXT_URI_LIST || - info == GtkDndUtil::NETSCAPE_URL) { + if (info == gtk_dnd_util::TEXT_URI_LIST || + info == gtk_dnd_util::NETSCAPE_URL) { success = tabstrip->CompleteDrop(data->data); } diff --git a/chrome/browser/gtk/toolbar_star_toggle_gtk.cc b/chrome/browser/gtk/toolbar_star_toggle_gtk.cc index 5c1f931..8715dde 100644 --- a/chrome/browser/gtk/toolbar_star_toggle_gtk.cc +++ b/chrome/browser/gtk/toolbar_star_toggle_gtk.cc @@ -40,11 +40,11 @@ ToolbarStarToggleGtk::ToolbarStarToggleGtk(BrowserToolbarGtk* host) gtk_drag_source_set(widget(), GDK_BUTTON1_MASK, NULL, 0, static_cast<GdkDragAction>(GDK_ACTION_COPY | GDK_ACTION_LINK)); - GtkDndUtil::SetSourceTargetListFromCodeMask(widget(), - GtkDndUtil::TEXT_PLAIN | - GtkDndUtil::TEXT_URI_LIST | - GtkDndUtil::CHROME_NAMED_URL | - GtkDndUtil::NETSCAPE_URL); + gtk_dnd_util::SetSourceTargetListFromCodeMask(widget(), + gtk_dnd_util::TEXT_PLAIN | + gtk_dnd_util::TEXT_URI_LIST | + gtk_dnd_util::CHROME_NAMED_URL | + gtk_dnd_util::NETSCAPE_URL); g_signal_connect(widget(), "drag-data-get", G_CALLBACK(OnDragDataGet), this); theme_provider_->InitThemesFor(this); @@ -107,7 +107,7 @@ void ToolbarStarToggleGtk::OnDragDataGet(GtkWidget* widget, GetSelectedTabContents(); if (!tab) return; - GtkDndUtil::WriteURLWithName(data, tab->GetURL(), tab->GetTitle(), info); + gtk_dnd_util::WriteURLWithName(data, tab->GetURL(), tab->GetTitle(), info); } void ToolbarStarToggleGtk::UpdateGTKButton() { diff --git a/chrome/browser/js_modal_dialog_gtk.cc b/chrome/browser/js_modal_dialog_gtk.cc index 773fcfc..73d7f16 100644 --- a/chrome/browser/js_modal_dialog_gtk.cc +++ b/chrome/browser/js_modal_dialog_gtk.cc @@ -6,6 +6,7 @@ #include <gtk/gtk.h> +#include "app/gtk_util.h" #include "app/l10n_util.h" #include "app/message_box_flags.h" #include "base/logging.h" diff --git a/chrome/browser/tab_contents/web_drag_dest_gtk.cc b/chrome/browser/tab_contents/web_drag_dest_gtk.cc index d439a3f..2336345 100644 --- a/chrome/browser/tab_contents/web_drag_dest_gtk.cc +++ b/chrome/browser/tab_contents/web_drag_dest_gtk.cc @@ -70,16 +70,16 @@ gboolean WebDragDestGtk::OnDragMotion(GdkDragContext* context, gint x, gint y, is_drop_target_ = false; static int supported_targets[] = { - GtkDndUtil::TEXT_PLAIN, - GtkDndUtil::TEXT_URI_LIST, - GtkDndUtil::TEXT_HTML, + gtk_dnd_util::TEXT_PLAIN, + gtk_dnd_util::TEXT_URI_LIST, + gtk_dnd_util::TEXT_HTML, // TODO(estade): support image drags? }; data_requests_ = arraysize(supported_targets); for (size_t i = 0; i < arraysize(supported_targets); ++i) { gtk_drag_get_data(widget_, context, - GtkDndUtil::GetAtomForTarget(supported_targets[i]), + gtk_dnd_util::GetAtomForTarget(supported_targets[i]), time); } } else if (data_requests_ == 0) { @@ -112,7 +112,7 @@ void WebDragDestGtk::OnDragDataReceived( // If the source can't provide us with valid data for a requested target, // data->data will be NULL. if (data->target == - GtkDndUtil::GetAtomForTarget(GtkDndUtil::TEXT_PLAIN)) { + gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::TEXT_PLAIN)) { guchar* text = gtk_selection_data_get_text(data); if (text) { drop_data_->plain_text = @@ -121,7 +121,7 @@ void WebDragDestGtk::OnDragDataReceived( g_free(text); } } else if (data->target == - GtkDndUtil::GetAtomForTarget(GtkDndUtil::TEXT_URI_LIST)) { + gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::TEXT_URI_LIST)) { gchar** uris = gtk_selection_data_get_uris(data); if (uris) { for (gchar** uri_iter = uris; *uri_iter; uri_iter++) { @@ -136,7 +136,7 @@ void WebDragDestGtk::OnDragDataReceived( g_strfreev(uris); } } else if (data->target == - GtkDndUtil::GetAtomForTarget(GtkDndUtil::TEXT_HTML)) { + gtk_dnd_util::GetAtomForTarget(gtk_dnd_util::TEXT_HTML)) { // TODO(estade): Can the html have a non-UTF8 encoding? drop_data_->text_html = UTF8ToUTF16(std::string(reinterpret_cast<char*>(data->data), diff --git a/chrome/common/DEPS b/chrome/common/DEPS index 50f16bfb..8a41106 100644 --- a/chrome/common/DEPS +++ b/chrome/common/DEPS @@ -16,6 +16,5 @@ include_rules = [ # FIXME - refactor code and remove these dependencies "+chrome/app", - "+chrome/browser", "+chrome/installer", ] diff --git a/chrome/common/platform_util_linux.cc b/chrome/common/platform_util_linux.cc index c4bf536..beb6cf1 100644 --- a/chrome/common/platform_util_linux.cc +++ b/chrome/common/platform_util_linux.cc @@ -6,10 +6,10 @@ #include <gtk/gtk.h> +#include "app/gtk_util.h" #include "base/file_util.h" #include "base/process_util.h" #include "base/utf_string_conversions.h" -#include "chrome/browser/gtk/gtk_util.h" #include "chrome/common/process_watcher.h" #include "googleurl/src/gurl.h" diff --git a/chrome/common/sandbox_policy.cc b/chrome/common/sandbox_policy.cc index ba9b76d..ff5e5c5 100644 --- a/chrome/common/sandbox_policy.cc +++ b/chrome/common/sandbox_policy.cc @@ -14,7 +14,6 @@ #include "base/registry.h" #include "base/string_util.h" #include "base/win_util.h" -#include "chrome/browser/browser_process.h" #include "chrome/common/child_process_info.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_paths.h" @@ -23,13 +22,8 @@ #include "sandbox/src/sandbox.h" #include "webkit/glue/plugins/plugin_list.h" -#ifdef NACL_WIN64 - // The sandbox can be used also by the NaCl broker process. In this case we - // define a global variable g_broker_services instead of g_browser_process. - // This can be changed if we discover that the broker process needs to be more - // similar to the browser process. - extern sandbox::BrokerServices* g_broker_services; -#endif +static sandbox::BrokerServices* g_broker_services = NULL; + namespace { // The DLLs listed here are known (or under strong suspicion) of causing crashes @@ -364,6 +358,15 @@ void AddPolicyForRenderer(sandbox::TargetPolicy* policy, namespace sandbox { +void InitBrokerServices(sandbox::BrokerServices* broker_services) { + // TODO(abarth): DCHECK(CalledOnValidThread()); + // See <http://b/1287166>. + CHECK(broker_services); + CHECK(!g_broker_services); + broker_services->Init(); + g_broker_services = broker_services; +} + base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line, const FilePath& exposed_dir) { base::ProcessHandle process = 0; @@ -418,18 +421,9 @@ base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line, return process; } -#ifdef NACL_WIN64 - // When running in the broker we get the BrokerServices pointer from a global - // variable. It is initialized in NaClBrokerMain. - sandbox::BrokerServices* broker_service = g_broker_services; -#else - // spawn the child process in the sandbox - sandbox::BrokerServices* broker_service = - g_browser_process->broker_services(); -#endif sandbox::ResultCode result; PROCESS_INFORMATION target = {0}; - sandbox::TargetPolicy* policy = broker_service->CreatePolicy(); + sandbox::TargetPolicy* policy = g_broker_services->CreatePolicy(); bool on_sandbox_desktop = false; // TODO(gregoryd): try locked-down policy for sel_ldr after we fix IMC. @@ -468,7 +462,7 @@ base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line, return 0; } - result = broker_service->SpawnTarget( + result = g_broker_services->SpawnTarget( cmd_line->program().c_str(), cmd_line->command_line_string().c_str(), policy, &target); diff --git a/chrome/common/sandbox_policy.h b/chrome/common/sandbox_policy.h index 542b946..46ab7bf 100644 --- a/chrome/common/sandbox_policy.h +++ b/chrome/common/sandbox_policy.h @@ -12,6 +12,10 @@ class CommandLine; namespace sandbox { +class BrokerServices; + +void InitBrokerServices(sandbox::BrokerServices* broker_services); + // Starts a sandboxed process with the given directory unsandboxed // and returns a handle to it. base::ProcessHandle StartProcessWithAccess(CommandLine* cmd_line, diff --git a/chrome/nacl/nacl_main.cc b/chrome/nacl/nacl_main.cc index 88f7af8..a7325cd 100644 --- a/chrome/nacl/nacl_main.cc +++ b/chrome/nacl/nacl_main.cc @@ -21,6 +21,7 @@ #include "chrome/common/logging_chrome.h" #include "chrome/common/main_function_params.h" #include "chrome/common/result_codes.h" +#include "chrome/common/sandbox_policy.h" #if defined(OS_WIN) #include "chrome/nacl/broker_thread.h" #endif @@ -28,8 +29,6 @@ #ifdef _WIN64 -sandbox::BrokerServices* g_broker_services = NULL; - // main() routine for the NaCl broker process. // This is necessary for supporting NaCl in Chrome on Win64. int NaClBrokerMain(const MainFunctionParams& parameters) { @@ -54,7 +53,7 @@ int NaClBrokerMain(const MainFunctionParams& parameters) { sandbox::BrokerServices* broker_services = parameters.sandbox_info_.BrokerServices(); if (broker_services) { - g_broker_services = broker_services; + sandbox::InitBrokerServices(broker_services); if (!parsed_command_line.HasSwitch(switches::kNoSandbox)) { bool use_winsta = !parsed_command_line.HasSwitch( switches::kDisableAltWinstation); diff --git a/chrome/test/testing_browser_process.h b/chrome/test/testing_browser_process.h index 47a75e1..0a22151 100644 --- a/chrome/test/testing_browser_process.h +++ b/chrome/test/testing_browser_process.h @@ -81,15 +81,6 @@ class TestingBrowserProcess : public BrowserProcess { return NULL; } -#if defined(OS_WIN) - virtual sandbox::BrokerServices* broker_services() { - return NULL; - } - - virtual void InitBrokerServices(sandbox::BrokerServices*) { - } -#endif - virtual DebuggerWrapper* debugger_wrapper() { return NULL; } |