diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-24 05:27:21 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-24 05:27:21 +0000 |
commit | 1158d69dfd5c0a320ba237abe3044566d98786ab (patch) | |
tree | 306d64d6d4cb15e0f90dd8c3d503dc8808bcce9c /chrome/browser/ui/gtk | |
parent | ae428afa0b4956151d38ac88d3311c36a825e88f (diff) | |
download | chromium_src-1158d69dfd5c0a320ba237abe3044566d98786ab.zip chromium_src-1158d69dfd5c0a320ba237abe3044566d98786ab.tar.gz chromium_src-1158d69dfd5c0a320ba237abe3044566d98786ab.tar.bz2 |
Revert trunk r97990. It broke some Linux builds:
http://build.chromium.org/p/chromium/builders/Linux%20Clang%20%28ChromiumOS%20dbg%29/builds/9822/steps/compile/logs/stdio
http://build.chromium.org/p/chromium/builders/Linux%20Builder%20%28Views%20dbg%29/builds/12722/steps/compile/logs/stdio
http://build.chromium.org/p/chromium/builders/Linux%20Touch/builds/4948/steps/compile/logs/stdio
http://build.chromium.org/p/chromium/builders/Arm/builds/16148/steps/compile/logs/stdio
You can use the linux_view, linux_chromeos, linux_clang_chromeos, and other
try bots to test further iterations of this change.
--
Web Intent Picker UI (implemented as a constrained dialog, linux only)
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/7648061
TBR=binji@chromium.org
Review URL: http://codereview.chromium.org/7701022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97994 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/ui/gtk')
-rw-r--r-- | chrome/browser/ui/gtk/web_intent_picker_gtk.cc | 142 | ||||
-rw-r--r-- | chrome/browser/ui/gtk/web_intent_picker_gtk.h | 76 |
2 files changed, 0 insertions, 218 deletions
diff --git a/chrome/browser/ui/gtk/web_intent_picker_gtk.cc b/chrome/browser/ui/gtk/web_intent_picker_gtk.cc deleted file mode 100644 index 90c7901..0000000 --- a/chrome/browser/ui/gtk/web_intent_picker_gtk.cc +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/browser/ui/gtk/web_intent_picker_gtk.h" - -#include "chrome/browser/favicon/favicon_service.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/gtk/custom_button.h" -#include "chrome/browser/ui/gtk/gtk_theme_service.h" -#include "chrome/browser/ui/gtk/gtk_util.h" -#include "chrome/browser/ui/intents/web_intent_picker_controller.h" -#include "chrome/browser/ui/intents/web_intent_picker_delegate.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "content/browser/tab_contents/tab_contents.h" -#include "content/common/content_notification_types.h" -#include "googleurl/src/gurl.h" -#include "grit/generated_resources.h" -#include "grit/ui_resources.h" -#include "ui/base/l10n/l10n_util.h" -#include "ui/base/resource/resource_bundle.h" -#include "ui/gfx/gtk_util.h" -#include "ui/gfx/image/image.h" - -namespace { - -GtkThemeService *GetThemeService(TabContents* tab_contents) { - Profile* profile = Profile::FromBrowserContext( - tab_contents->browser_context()); - return GtkThemeService::GetFrom(profile); -} - -} // namespace - -// static -WebIntentPicker* WebIntentPicker::Create(TabContents* tab_contents, - WebIntentPickerDelegate* delegate) { - return new WebIntentPickerGtk(tab_contents, delegate); -} - -WebIntentPickerGtk::WebIntentPickerGtk(TabContents* tab_contents, - WebIntentPickerDelegate* delegate) - : tab_contents_(tab_contents), - delegate_(delegate), - window_(NULL) { - DCHECK(delegate_ != NULL); - root_.Own(gtk_vbox_new(FALSE, gtk_util::kContentAreaBorder)); - GtkWidget* hbox = gtk_hbox_new(FALSE, 0); - GtkWidget* label = gtk_label_new( - l10n_util::GetStringUTF8(IDS_CHOOSE_INTENT_HANDLER_MESSAGE).c_str()); - gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0); - - close_button_.reset( - CustomDrawButton::CloseButton(GetThemeService(tab_contents_))); - g_signal_connect(close_button_->widget(), - "clicked", - G_CALLBACK(OnCloseButtonClickThunk), - this); - gtk_widget_set_can_focus(close_button_->widget(), FALSE); - gtk_box_pack_end(GTK_BOX(hbox), close_button_->widget(), FALSE, FALSE, 0); - - gtk_box_pack_start(GTK_BOX(root_.get()), hbox, FALSE, FALSE, 0); - - button_hbox_ = gtk_hbox_new(FALSE, gtk_util::kContentAreaBorder); - gtk_box_pack_start(GTK_BOX(root_.get()), button_hbox_, TRUE, TRUE, 0); -} - -WebIntentPickerGtk::~WebIntentPickerGtk() { - DCHECK(window_ == NULL) << "Should have closed window before destroying."; -} - -void WebIntentPickerGtk::SetServiceURLs(const std::vector<GURL>& urls) { - for (size_t i = 0; i < urls.size(); ++i) { - GtkWidget* button = gtk_button_new(); - gtk_widget_set_tooltip_text(button, urls[i].spec().c_str()); - gtk_box_pack_start(GTK_BOX(button_hbox_), button, FALSE, FALSE, 0); - g_signal_connect(button, - "clicked", - G_CALLBACK(OnServiceButtonClickThunk), - this); - } - - gtk_widget_show_all(button_hbox_); -} - -void WebIntentPickerGtk::SetServiceIcon(size_t index, const SkBitmap& icon) { - if (icon.empty()) - return; - - GList* button_list = gtk_container_get_children(GTK_CONTAINER(button_hbox_)); - GtkButton* button = GTK_BUTTON(g_list_nth_data(button_list, index)); - DCHECK(button != NULL) << "Invalid index."; - - GdkPixbuf* icon_pixbuf = gfx::GdkPixbufFromSkBitmap(&icon); - gtk_button_set_image(button, gtk_image_new_from_pixbuf(icon_pixbuf)); - g_object_unref(icon_pixbuf); -} - -void WebIntentPickerGtk::SetDefaultServiceIcon(size_t index) { - GList* button_list = gtk_container_get_children(GTK_CONTAINER(button_hbox_)); - GtkButton* button = GTK_BUTTON(g_list_nth_data(button_list, index)); - DCHECK(button != NULL) << "Invalid index."; - - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - GdkPixbuf* icon_pixbuf = rb.GetNativeImageNamed(IDR_DEFAULT_FAVICON); - gtk_button_set_image(button, gtk_image_new_from_pixbuf(icon_pixbuf)); -} - -void WebIntentPickerGtk::Show() { - DCHECK(window_ == NULL) << "Show already called."; - window_ = tab_contents_->CreateConstrainedDialog(this); -} - -void WebIntentPickerGtk::Close() { - DCHECK(window_ != NULL) << "Show not called."; - window_->CloseConstrainedWindow(); - window_ = NULL; -} - -GtkWidget* WebIntentPickerGtk::GetWidgetRoot() { - return root_.get(); -} - -GtkWidget* WebIntentPickerGtk::GetFocusWidget() { - return root_.get(); -} - -void WebIntentPickerGtk::DeleteDelegate() { - MessageLoop::current()->DeleteSoon(FROM_HERE, this); -} - -void WebIntentPickerGtk::OnCloseButtonClick(GtkWidget* button) { - delegate_->OnCancelled(); -} - -void WebIntentPickerGtk::OnServiceButtonClick(GtkWidget* button) { - GList* button_list = gtk_container_get_children(GTK_CONTAINER(button_hbox_)); - gint index = g_list_index(button_list, button); - DCHECK(index != -1); - - delegate_->OnServiceChosen(static_cast<size_t>(index)); -} diff --git a/chrome/browser/ui/gtk/web_intent_picker_gtk.h b/chrome/browser/ui/gtk/web_intent_picker_gtk.h deleted file mode 100644 index b85fd80..0000000 --- a/chrome/browser/ui/gtk/web_intent_picker_gtk.h +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_BROWSER_UI_GTK_WEB_INTENT_PICKER_GTK_H_ -#define CHROME_BROWSER_UI_GTK_WEB_INTENT_PICKER_GTK_H_ -#pragma once - -#include <vector> - -#include <gtk/gtk.h> - -#include "base/basictypes.h" -#include "base/compiler_specific.h" -#include "base/memory/scoped_ptr.h" -#include "chrome/browser/ui/gtk/constrained_window_gtk.h" -#include "chrome/browser/ui/intents/web_intent_picker.h" -#include "ui/base/gtk/gtk_signal.h" - -class CustomDrawButton; -class GURL; -class TabContents; -class WebIntentController; -class WebIntentPickerDelegate; - -// Gtk implementation of WebIntentPicker. -class WebIntentPickerGtk : public WebIntentPicker, - public ConstrainedDialogDelegate { - public: - WebIntentPickerGtk(TabContents* tab_contents, - WebIntentPickerDelegate* delegate); - virtual ~WebIntentPickerGtk(); - - // WebIntentPicker implementation. - virtual void SetServiceURLs(const std::vector<GURL>& urls) OVERRIDE; - virtual void SetServiceIcon(size_t index, const SkBitmap& icon) OVERRIDE; - virtual void SetDefaultServiceIcon(size_t index) OVERRIDE; - virtual void Show() OVERRIDE; - virtual void Close() OVERRIDE; - - // ConstrainedDialogDelegate implementation. - virtual GtkWidget* GetWidgetRoot() OVERRIDE; - virtual GtkWidget* GetFocusWidget() OVERRIDE; - virtual void DeleteDelegate() OVERRIDE; - - private: - // Callback when a service button is clicked. - CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnServiceButtonClick); - // Callback when close button is clicked. - CHROMEGTK_CALLBACK_0(WebIntentPickerGtk, void, OnCloseButtonClick); - - // A weak pointer to the tab contents on which to display the picker UI. - TabContents* tab_contents_; - - // A weak pointer to the WebIntentPickerDelegate to notify when the user - // chooses a service or cancels. - WebIntentPickerDelegate* delegate_; - - // The root GtkWidget of the dialog. - ui::OwnedWidgetGtk root_; - - // A weak pointer to the hbox that contains the buttons used to choose the - // service. - GtkWidget* button_hbox_; - - // A button to close the dialog delegate. - scoped_ptr<CustomDrawButton> close_button_; - - // The displayed constrained window. Technically owned by the TabContents - // page, but this object tells it when to destroy. - ConstrainedWindow* window_; - - DISALLOW_COPY_AND_ASSIGN(WebIntentPickerGtk); -}; - -#endif // CHROME_BROWSER_UI_GTK_WEB_INTENT_PICKER_GTK_H_ |