summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/back_forward_button_gtk.cc2
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.cc3
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.h3
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc8
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk_unittest.cc6
-rw-r--r--chrome/browser/gtk/bookmark_editor_gtk.cc168
-rw-r--r--chrome/browser/gtk/bookmark_editor_gtk.h40
-rw-r--r--chrome/browser/gtk/bookmark_menu_controller_gtk.cc26
-rw-r--r--chrome/browser/gtk/bookmark_menu_controller_gtk.h3
-rw-r--r--chrome/browser/gtk/browser_actions_toolbar_gtk.cc2
-rw-r--r--chrome/browser/gtk/browser_actions_toolbar_gtk.h1
-rw-r--r--chrome/browser/gtk/browser_titlebar.cc13
-rw-r--r--chrome/browser/gtk/browser_titlebar.h4
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.cc2
-rw-r--r--chrome/browser/gtk/browser_toolbar_gtk.h1
-rw-r--r--chrome/browser/gtk/browser_window_factory_gtk.cc2
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc45
-rw-r--r--chrome/browser/gtk/browser_window_gtk.h2
-rw-r--r--chrome/browser/gtk/chrome_gtk_frame.cc155
-rw-r--r--chrome/browser/gtk/chrome_gtk_frame.h56
-rw-r--r--chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc2
-rw-r--r--chrome/browser/gtk/constrained_window_gtk.cc6
-rw-r--r--chrome/browser/gtk/custom_button.h1
-rw-r--r--chrome/browser/gtk/dialogs_gtk.cc1
-rw-r--r--chrome/browser/gtk/download_in_progress_dialog_gtk.cc4
-rw-r--r--chrome/browser/gtk/download_item_gtk.cc2
-rw-r--r--chrome/browser/gtk/download_item_gtk.h2
-rw-r--r--chrome/browser/gtk/download_shelf_gtk.cc2
-rw-r--r--chrome/browser/gtk/extension_infobar_gtk.cc8
-rw-r--r--chrome/browser/gtk/extension_infobar_gtk.h2
-rw-r--r--chrome/browser/gtk/extension_install_prompt2_gtk.cc5
-rw-r--r--chrome/browser/gtk/extension_installed_bubble_gtk.cc93
-rw-r--r--chrome/browser/gtk/extension_installed_bubble_gtk.h2
-rw-r--r--chrome/browser/gtk/extension_popup_gtk.cc2
-rw-r--r--chrome/browser/gtk/find_bar_gtk.cc2
-rw-r--r--chrome/browser/gtk/first_run_bubble.cc2
-rw-r--r--chrome/browser/gtk/gconf_titlebar_listener.cc10
-rw-r--r--chrome/browser/gtk/gtk_theme_provider.cc259
-rw-r--r--chrome/browser/gtk/gtk_theme_provider.h35
-rw-r--r--chrome/browser/gtk/gtk_util.cc97
-rw-r--r--chrome/browser/gtk/gtk_util.h6
-rw-r--r--chrome/browser/gtk/hover_controller_gtk.h1
-rw-r--r--chrome/browser/gtk/html_dialog_gtk.cc2
-rw-r--r--chrome/browser/gtk/hung_renderer_dialog_gtk.cc14
-rw-r--r--chrome/browser/gtk/infobar_arrow_model.h1
-rw-r--r--chrome/browser/gtk/infobar_gtk.h1
-rw-r--r--chrome/browser/gtk/instant_confirm_dialog_gtk.cc12
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.cc6
-rw-r--r--chrome/browser/gtk/location_bar_view_gtk.h4
-rw-r--r--chrome/browser/gtk/menu_gtk.cc12
-rw-r--r--chrome/browser/gtk/meta_frames.cc25
-rw-r--r--chrome/browser/gtk/meta_frames.h39
-rw-r--r--chrome/browser/gtk/notifications/balloon_view_gtk.h2
-rw-r--r--chrome/browser/gtk/options/advanced_contents_gtk.cc8
-rw-r--r--chrome/browser/gtk/options/content_filter_page_gtk.cc135
-rw-r--r--chrome/browser/gtk/options/content_filter_page_gtk.h23
-rw-r--r--chrome/browser/gtk/options/content_page_gtk.cc6
-rw-r--r--chrome/browser/gtk/options/content_settings_window_gtk.cc4
-rw-r--r--chrome/browser/gtk/options/cookie_filter_page_gtk.cc106
-rw-r--r--chrome/browser/gtk/options/cookie_filter_page_gtk.h17
-rw-r--r--chrome/browser/gtk/options/general_page_gtk.cc3
-rw-r--r--chrome/browser/gtk/page_info_bubble_gtk.cc5
-rw-r--r--chrome/browser/gtk/reload_button_gtk.cc2
-rw-r--r--chrome/browser/gtk/sad_tab_gtk.cc7
-rw-r--r--chrome/browser/gtk/slide_animator_gtk.h2
-rw-r--r--chrome/browser/gtk/status_bubble_gtk.cc1
-rw-r--r--chrome/browser/gtk/status_bubble_gtk.h3
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc2
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_gtk.h1
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.cc11
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.h4
-rw-r--r--chrome/browser/gtk/tabs/tab_strip_gtk.cc38
-rw-r--r--chrome/browser/gtk/task_manager_gtk.cc7
-rw-r--r--chrome/browser/gtk/translate/translate_infobar_base_gtk.h1
-rw-r--r--chrome/browser/gtk/view_id_util_browsertest.cc2
75 files changed, 1135 insertions, 457 deletions
diff --git a/chrome/browser/gtk/back_forward_button_gtk.cc b/chrome/browser/gtk/back_forward_button_gtk.cc
index 29d6ddd..669b9d7 100644
--- a/chrome/browser/gtk/back_forward_button_gtk.cc
+++ b/chrome/browser/gtk/back_forward_button_gtk.cc
@@ -10,11 +10,11 @@
#include "base/message_loop.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/back_forward_menu_model.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/menu_gtk.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/ui/browser.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc
index 0580b54..4784b2a 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk.cc
@@ -7,13 +7,13 @@
#include <vector>
#include "app/gtk_dnd_util.h"
+#include "app/slide_animation.h"
#include "app/resource_bundle.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_drag_data.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
#include "chrome/browser/browser_shutdown.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/gtk/bookmark_menu_controller_gtk.h"
#include "chrome/browser/gtk/bookmark_tree_model.h"
#include "chrome/browser/gtk/bookmark_utils_gtk.h"
@@ -38,6 +38,7 @@
#include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "gfx/canvas_skia_paint.h"
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.h b/chrome/browser/gtk/bookmark_bar_gtk.h
index 2e7f985..0939c70 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.h
+++ b/chrome/browser/gtk/bookmark_bar_gtk.h
@@ -10,8 +10,8 @@
#include <vector>
+#include "app/animation_delegate.h"
#include "app/gtk_signal.h"
-#include "app/slide_animation.h"
#include "base/gtest_prod_util.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/bookmarks/bookmark_context_menu_controller.h"
@@ -34,6 +34,7 @@ class GtkThemeProvider;
class MenuGtk;
class PageNavigator;
class Profile;
+class SlideAnimation;
class TabstripOriginProvider;
class BookmarkBarGtk : public AnimationDelegate,
diff --git a/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc b/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc
index 0fc9101..cb027a8 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk_interactive_uitest.cc
@@ -4,10 +4,10 @@
#include <gtk/gtk.h>
-#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/gtk/view_id_util.h"
#include "chrome/browser/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/test/in_process_browser_test.h"
#include "chrome/test/ui_test_utils.h"
#include "net/test/test_server.h"
@@ -22,12 +22,12 @@ void OnClicked(GtkWidget* widget, bool* clicked_bit) {
} // namespace
-class BookmarkBarGtkBrowserTest : public InProcessBrowserTest {
+class BookmarkBarGtkInteractiveUITest : public InProcessBrowserTest {
};
// Makes sure that when you switch back to an NTP with an active findbar,
// the findbar is above the floating bookmark bar.
-IN_PROC_BROWSER_TEST_F(BookmarkBarGtkBrowserTest, FindBarTest) {
+IN_PROC_BROWSER_TEST_F(BookmarkBarGtkInteractiveUITest, FindBarTest) {
ASSERT_TRUE(test_server()->Start());
// Create new tab; open findbar.
@@ -52,7 +52,7 @@ IN_PROC_BROWSER_TEST_F(BookmarkBarGtkBrowserTest, FindBarTest) {
}
// Makes sure that you can click on the floating bookmark bar.
-IN_PROC_BROWSER_TEST_F(BookmarkBarGtkBrowserTest, ClickOnFloatingTest) {
+IN_PROC_BROWSER_TEST_F(BookmarkBarGtkInteractiveUITest, ClickOnFloatingTest) {
ASSERT_TRUE(test_server()->Start());
GtkWidget* other_bookmarks =
diff --git a/chrome/browser/gtk/bookmark_bar_gtk_unittest.cc b/chrome/browser/gtk/bookmark_bar_gtk_unittest.cc
index fa04251..074e8fc 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk_unittest.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk_unittest.cc
@@ -4,14 +4,14 @@
#include "chrome/browser/gtk/bookmark_bar_gtk.h"
+#include "base/task.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/bookmarks/bookmark_model.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/browser_thread.h"
#include "chrome/browser/gtk/tabstrip_origin_provider.h"
-#include "base/task.h"
-#include "testing/gtest/include/gtest/gtest.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/test/testing_profile.h"
+#include "testing/gtest/include/gtest/gtest.h"
// Dummy implementation that's good enough for the tests; we don't test
// rendering here so all we need is a non-NULL object.
diff --git a/chrome/browser/gtk/bookmark_editor_gtk.cc b/chrome/browser/gtk/bookmark_editor_gtk.cc
index 5aafc6c..1ad5857 100644
--- a/chrome/browser/gtk/bookmark_editor_gtk.cc
+++ b/chrome/browser/gtk/bookmark_editor_gtk.cc
@@ -7,6 +7,7 @@
#include <gtk/gtk.h>
#include "app/l10n_util.h"
+#include "app/menus/simple_menu_model.h"
#include "base/basictypes.h"
#include "base/logging.h"
#include "base/string_util.h"
@@ -21,11 +22,18 @@
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/profile.h"
#include "gfx/gtk_util.h"
+#include "gfx/point.h"
#include "googleurl/src/gurl.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
+#if defined(TOOLKIT_VIEWS)
+#include "views/controls/menu/menu_2.h"
+#else
+#include "chrome/browser/gtk/menu_gtk.h"
+#endif
+
namespace {
// Background color of text field when URL is invalid.
@@ -37,6 +45,143 @@ static const int kTreeHeight = 150;
} // namespace
+class BookmarkEditorGtk::ContextMenuController
+ : public menus::SimpleMenuModel::Delegate {
+ public:
+ explicit ContextMenuController(BookmarkEditorGtk* editor)
+ : editor_(editor),
+ running_menu_for_root_(false) {
+ menu_model_.reset(new menus::SimpleMenuModel(this));
+ menu_model_->AddItemWithStringId(COMMAND_EDIT, IDS_EDIT);
+ menu_model_->AddItemWithStringId(
+ COMMAND_NEW_FOLDER,
+ IDS_BOOMARK_EDITOR_NEW_FOLDER_MENU_ITEM);
+#if defined(TOOLKIT_VIEWS)
+ menu_.reset(new views::Menu2(menu_model_.get()));
+#else
+ menu_.reset(new MenuGtk(NULL, menu_model_.get()));
+#endif
+ }
+ virtual ~ContextMenuController() {}
+
+ void RunMenu(const gfx::Point& point) {
+ const BookmarkNode* selected_node = GetSelectedNode();
+ if (selected_node)
+ running_menu_for_root_ = selected_node->GetParent()->IsRoot();
+#if defined(TOOLKIT_VIEWS)
+ menu_->RunContextMenuAt(point);
+#else
+ menu_->PopupAsContextAt(gtk_get_current_event_time(), point);
+#endif
+ }
+
+ void Cancel() {
+ editor_ = NULL;
+#if defined(TOOLKIT_VIEWS)
+ menu_->CancelMenu();
+#else
+ menu_->Cancel();
+#endif
+ }
+
+ private:
+ enum ContextMenuCommand {
+ COMMAND_EDIT,
+ COMMAND_NEW_FOLDER
+ };
+
+ // Overridden from menus::SimpleMenuModel::Delegate:
+ virtual bool IsCommandIdEnabled(int command_id) const {
+ return !(command_id == COMMAND_EDIT && running_menu_for_root_) &&
+ (editor_ != NULL);
+ }
+
+ virtual bool IsCommandIdChecked(int command_id) const {
+ return false;
+ }
+
+ virtual bool GetAcceleratorForCommandId(int command_id,
+ menus::Accelerator* accelerator) {
+ return false;
+ }
+
+ virtual void ExecuteCommand(int command_id) {
+ if (!editor_)
+ return;
+
+ switch (command_id) {
+ case COMMAND_EDIT: {
+ GtkTreeIter iter;
+ if (!gtk_tree_selection_get_selected(editor_->tree_selection_,
+ NULL,
+ &iter)) {
+ return;
+ }
+
+ GtkTreePath* path = gtk_tree_model_get_path(
+ GTK_TREE_MODEL(editor_->tree_store_), &iter);
+ gtk_tree_view_expand_to_path(GTK_TREE_VIEW(editor_->tree_view_), path);
+
+ // Make the folder name editable.
+ gtk_tree_view_set_cursor(GTK_TREE_VIEW(editor_->tree_view_), path,
+ gtk_tree_view_get_column(GTK_TREE_VIEW(editor_->tree_view_), 0),
+ TRUE);
+
+ gtk_tree_path_free(path);
+ break;
+ }
+ case COMMAND_NEW_FOLDER:
+ editor_->NewFolder();
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
+ }
+
+ int64 GetRowIdAt(GtkTreeModel* model, GtkTreeIter* iter) {
+ GValue value = { 0, };
+ gtk_tree_model_get_value(model, iter, bookmark_utils::ITEM_ID, &value);
+ int64 id = g_value_get_int64(&value);
+ g_value_unset(&value);
+ return id;
+ }
+
+ const BookmarkNode* GetNodeAt(GtkTreeModel* model, GtkTreeIter* iter) {
+ int64 id = GetRowIdAt(model, iter);
+ return (id > 0) ? editor_->bb_model_->GetNodeByID(id) : NULL;
+ }
+
+ const BookmarkNode* GetSelectedNode() {
+ GtkTreeModel* model;
+ GtkTreeIter iter;
+ if (!gtk_tree_selection_get_selected(editor_->tree_selection_,
+ &model,
+ &iter)) {
+ return NULL;
+ }
+
+ return GetNodeAt(model, &iter);
+ }
+
+ // The model and view for the right click context menu.
+ scoped_ptr<menus::SimpleMenuModel> menu_model_;
+#if defined(TOOLKIT_VIEWS)
+ scoped_ptr<views::Menu2> menu_;
+#else
+ scoped_ptr<MenuGtk> menu_;
+#endif
+
+ // The context menu was brought up for. Set to NULL when the menu is canceled.
+ BookmarkEditorGtk* editor_;
+
+ // If true, we're running the menu for the bookmark bar or other bookmarks
+ // nodes.
+ bool running_menu_for_root_;
+
+ DISALLOW_COPY_AND_ASSIGN(ContextMenuController);
+};
+
// static
void BookmarkEditor::Show(gfx::NativeWindow parent_hwnd,
Profile* profile,
@@ -181,6 +326,8 @@ void BookmarkEditorGtk::Init(GtkWindow* parent_window) {
tree_view_ = bookmark_utils::MakeTreeViewForStore(tree_store_);
gtk_widget_set_size_request(tree_view_, kTreeWidth, kTreeHeight);
tree_selection_ = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view_));
+ g_signal_connect(tree_view_, "button-press-event",
+ G_CALLBACK(OnTreeViewButtonPressEventThunk), this);
GtkTreePath* path = NULL;
if (selected_id) {
@@ -396,6 +543,27 @@ void BookmarkEditorGtk::OnEntryChanged(GtkWidget* entry) {
}
void BookmarkEditorGtk::OnNewFolderClicked(GtkWidget* button) {
+ NewFolder();
+}
+
+gboolean BookmarkEditorGtk::OnTreeViewButtonPressEvent(GtkWidget* widget,
+ GdkEventButton* event) {
+ if (event->button == 3) {
+ gfx::Point pt(event->x_root, event->y_root);
+ ShowContextMenu(pt);
+ }
+
+ return FALSE;
+}
+
+void BookmarkEditorGtk::ShowContextMenu(const gfx::Point& point) {
+ if (!menu_controller_.get())
+ menu_controller_.reset(new ContextMenuController(this));
+
+ menu_controller_->RunMenu(point);
+}
+
+void BookmarkEditorGtk::NewFolder() {
GtkTreeIter iter;
if (!gtk_tree_selection_get_selected(tree_selection_,
NULL,
diff --git a/chrome/browser/gtk/bookmark_editor_gtk.h b/chrome/browser/gtk/bookmark_editor_gtk.h
index fda8769..7295689 100644
--- a/chrome/browser/gtk/bookmark_editor_gtk.h
+++ b/chrome/browser/gtk/bookmark_editor_gtk.h
@@ -9,6 +9,7 @@
#include "app/gtk_integers.h"
#include "app/gtk_signal.h"
#include "base/gtest_prod_util.h"
+#include "base/scoped_ptr.h"
#include "base/string16.h"
#include "chrome/browser/bookmarks/bookmark_editor.h"
#include "chrome/browser/bookmarks/bookmark_model_observer.h"
@@ -16,24 +17,19 @@
class GURL;
typedef union _GdkEvent GdkEvent;
+typedef struct _GdkEventButton GdkEventButton;
typedef struct _GtkTreeIter GtkTreeIter;
typedef struct _GtkTreeSelection GtkTreeSelection;
typedef struct _GtkTreeStore GtkTreeStore;
typedef struct _GtkWidget GtkWidget;
+namespace gfx {
+class Point;
+} // namespace gfx
+
// GTK version of the bookmark editor dialog.
class BookmarkEditorGtk : public BookmarkEditor,
public BookmarkModelObserver {
- FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, ChangeParent);
- FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, ChangeParentAndURL);
- FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, ChangeURLToExistingURL);
- FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, EditTitleKeepsPosition);
- FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, EditURLKeepsPosition);
- FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, ModelsMatch);
- FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, MoveToNewParent);
- FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, NewURL);
- FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, ChangeURLNoTree);
- FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, ChangeTitleNoTree);
public:
BookmarkEditorGtk(GtkWindow* window,
Profile* profile,
@@ -47,6 +43,20 @@ class BookmarkEditorGtk : public BookmarkEditor,
void Close();
private:
+ FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, ChangeParent);
+ FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, ChangeParentAndURL);
+ FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, ChangeURLToExistingURL);
+ FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, EditTitleKeepsPosition);
+ FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, EditURLKeepsPosition);
+ FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, ModelsMatch);
+ FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, MoveToNewParent);
+ FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, NewURL);
+ FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, ChangeURLNoTree);
+ FRIEND_TEST_ALL_PREFIXES(BookmarkEditorGtkTest, ChangeTitleNoTree);
+
+ class ContextMenuController;
+ friend class ContextMenuController;
+
void Init(GtkWindow* parent_window);
// BookmarkModel observer methods. Any structural change results in
@@ -104,6 +114,13 @@ class BookmarkEditorGtk : public BookmarkEditor,
CHROMEGTK_CALLBACK_0(BookmarkEditorGtk, void, OnNewFolderClicked);
+ CHROMEGTK_CALLBACK_1(BookmarkEditorGtk, gboolean, OnTreeViewButtonPressEvent,
+ GdkEventButton*);
+
+ void ShowContextMenu(const gfx::Point& point);
+
+ void NewFolder();
+
// Profile the entry is from.
Profile* profile_;
@@ -141,6 +158,9 @@ class BookmarkEditorGtk : public BookmarkEditor,
// Is the tree shown?
bool show_tree_;
+ // The context menu controller.
+ scoped_ptr<ContextMenuController> menu_controller_;
+
DISALLOW_COPY_AND_ASSIGN(BookmarkEditorGtk);
};
diff --git a/chrome/browser/gtk/bookmark_menu_controller_gtk.cc b/chrome/browser/gtk/bookmark_menu_controller_gtk.cc
index 38fc8ef..5930fb1 100644
--- a/chrome/browser/gtk/bookmark_menu_controller_gtk.cc
+++ b/chrome/browser/gtk/bookmark_menu_controller_gtk.cc
@@ -80,15 +80,17 @@ BookmarkMenuController::BookmarkMenuController(Browser* browser,
ignore_button_release_(false),
triggering_widget_(NULL) {
menu_ = gtk_menu_new();
+ g_object_ref_sink(menu_);
BuildMenu(node, start_child_index, menu_);
- g_signal_connect(menu_, "hide",
+ signals_.Connect(menu_, "hide",
G_CALLBACK(OnMenuHiddenThunk), this);
gtk_widget_show_all(menu_);
}
BookmarkMenuController::~BookmarkMenuController() {
profile_->GetBookmarkModel()->RemoveObserver(this);
- gtk_menu_popdown(GTK_MENU(menu_));
+ gtk_widget_destroy(menu_);
+ g_object_unref(menu_);
}
void BookmarkMenuController::Popup(GtkWidget* widget, gint button_type,
@@ -96,6 +98,8 @@ void BookmarkMenuController::Popup(GtkWidget* widget, gint button_type,
profile_->GetBookmarkModel()->AddObserver(this);
triggering_widget_ = widget;
+ signals_.Connect(triggering_widget_, "destroy",
+ G_CALLBACK(gtk_widget_destroyed), &triggering_widget_);
gtk_chrome_button_set_paint_state(GTK_CHROME_BUTTON(widget),
GTK_STATE_ACTIVE);
gtk_menu_popup(GTK_MENU(menu_), NULL, NULL,
@@ -139,9 +143,9 @@ void BookmarkMenuController::BuildMenu(const BookmarkNode* parent,
DCHECK(!parent->GetChildCount() ||
start_child_index < parent->GetChildCount());
- g_signal_connect(menu, "button-press-event",
+ signals_.Connect(menu, "button-press-event",
G_CALLBACK(OnMenuButtonPressedOrReleasedThunk), this);
- g_signal_connect(menu, "button-release-event",
+ signals_.Connect(menu, "button-release-event",
G_CALLBACK(OnMenuButtonPressedOrReleasedThunk), this);
for (int i = start_child_index; i < parent->GetChildCount(); ++i) {
@@ -158,10 +162,10 @@ void BookmarkMenuController::BuildMenu(const BookmarkNode* parent,
SetImageMenuItem(menu_item, node, profile_->GetBookmarkModel());
gtk_util::SetAlwaysShowImage(menu_item);
- g_signal_connect(menu_item, "button-release-event",
+ signals_.Connect(menu_item, "button-release-event",
G_CALLBACK(OnButtonReleasedThunk), this);
if (node->is_url()) {
- g_signal_connect(menu_item, "activate",
+ signals_.Connect(menu_item, "activate",
G_CALLBACK(OnMenuItemActivatedThunk), this);
} else if (node->is_folder()) {
GtkWidget* submenu = gtk_menu_new();
@@ -177,18 +181,18 @@ void BookmarkMenuController::BuildMenu(const BookmarkNode* parent,
if (node->is_url())
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",
+ signals_.Connect(menu_item, "drag-begin",
G_CALLBACK(OnMenuItemDragBeginThunk), this);
- g_signal_connect(menu_item, "drag-end",
+ signals_.Connect(menu_item, "drag-end",
G_CALLBACK(OnMenuItemDragEndThunk), this);
- g_signal_connect(menu_item, "drag-data-get",
+ signals_.Connect(menu_item, "drag-data-get",
G_CALLBACK(OnMenuItemDragGetThunk), this);
// It is important to connect to this signal after setting up the drag
// source because we only want to stifle the menu's default handler and
// not the handler that the drag source uses.
if (node->is_folder()) {
- g_signal_connect(menu_item, "button-press-event",
+ signals_.Connect(menu_item, "button-press-event",
G_CALLBACK(OnFolderButtonPressedThunk), this);
}
@@ -267,7 +271,7 @@ gboolean BookmarkMenuController::OnMenuButtonPressedOrReleased(
// context menu is hidden, re-assert our grab.
GtkWidget* grabbing_menu = gtk_grab_get_current();
g_object_ref(grabbing_menu);
- g_signal_connect(context_menu_->widget(), "hide",
+ signals_.Connect(context_menu_->widget(), "hide",
G_CALLBACK(OnContextMenuHide), grabbing_menu);
context_menu_->PopupAsContext(event->time);
diff --git a/chrome/browser/gtk/bookmark_menu_controller_gtk.h b/chrome/browser/gtk/bookmark_menu_controller_gtk.h
index cf8443c..0060267 100644
--- a/chrome/browser/gtk/bookmark_menu_controller_gtk.h
+++ b/chrome/browser/gtk/bookmark_menu_controller_gtk.h
@@ -10,6 +10,7 @@
#include "app/gtk_integers.h"
#include "app/gtk_signal.h"
+#include "app/gtk_signal_registrar.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/bookmarks/base_bookmark_model_observer.h"
#include "chrome/browser/bookmarks/bookmark_context_menu_controller.h"
@@ -136,6 +137,8 @@ class BookmarkMenuController : public BaseBookmarkModelObserver,
scoped_ptr<BookmarkContextMenuController> context_menu_controller_;
scoped_ptr<MenuGtk> context_menu_;
+ GtkSignalRegistrar signals_;
+
DISALLOW_COPY_AND_ASSIGN(BookmarkMenuController);
};
diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
index 4ee92b1..4d45545 100644
--- a/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.cc
@@ -8,7 +8,6 @@
#include "base/i18n/rtl.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/extensions/extension_browser_event_router.h"
#include "chrome/browser/extensions/extension_context_menu_model.h"
#include "chrome/browser/extensions/extensions_service.h"
@@ -24,6 +23,7 @@
#include "chrome/browser/gtk/view_id_util.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_action.h"
#include "chrome/common/extensions/extension_resource.h"
diff --git a/chrome/browser/gtk/browser_actions_toolbar_gtk.h b/chrome/browser/gtk/browser_actions_toolbar_gtk.h
index 72cf960..ac80386 100644
--- a/chrome/browser/gtk/browser_actions_toolbar_gtk.h
+++ b/chrome/browser/gtk/browser_actions_toolbar_gtk.h
@@ -9,6 +9,7 @@
#include <map>
#include <string>
+#include "app/animation_delegate.h"
#include "app/gtk_signal.h"
#include "app/gtk_signal_registrar.h"
#include "app/menus/simple_menu_model.h"
diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc
index dea24e6..995f047 100644
--- a/chrome/browser/gtk/browser_titlebar.cc
+++ b/chrome/browser/gtk/browser_titlebar.cc
@@ -18,12 +18,13 @@
#include "base/string_tokenizer.h"
#include "base/utf_string_conversions.h"
#include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/encoding_menu_controller.h"
#include "chrome/browser/gtk/accelerators_gtk.h"
#include "chrome/browser/gtk/browser_window_gtk.h"
#include "chrome/browser/gtk/custom_button.h"
+#if defined(USE_GCONF)
#include "chrome/browser/gtk/gconf_titlebar_listener.h"
+#endif
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/menu_gtk.h"
@@ -32,6 +33,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/browser/wrench_menu_model.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
@@ -193,6 +195,9 @@ void PopupPageMenuModel::Build() {
////////////////////////////////////////////////////////////////////////////////
// BrowserTitlebar
+// static
+const char BrowserTitlebar::kDefaultButtonString[] = ":minimize,maximize,close";
+
BrowserTitlebar::BrowserTitlebar(BrowserWindowGtk* browser_window,
GtkWindow* window)
: browser_window_(browser_window),
@@ -299,9 +304,13 @@ void BrowserTitlebar::Init() {
gtk_box_pack_end(GTK_BOX(container_hbox_), titlebar_right_buttons_vbox_,
FALSE, FALSE, 0);
+#if defined(USE_GCONF)
// Either read the gconf database and register for updates (on GNOME), or use
// the default value (anywhere else).
Singleton<GConfTitlebarListener>()->SetTitlebarButtons(this);
+#else
+ BuildButtons(kDefaultButtonString);
+#endif
// We use an alignment to control the titlebar height.
titlebar_alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0);
@@ -363,7 +372,9 @@ void BrowserTitlebar::Init() {
BrowserTitlebar::~BrowserTitlebar() {
ActiveWindowWatcherX::RemoveObserver(this);
+#if defined(USE_GCONF)
Singleton<GConfTitlebarListener>()->RemoveObserver(this);
+#endif
}
void BrowserTitlebar::BuildButtons(const std::string& button_string) {
diff --git a/chrome/browser/gtk/browser_titlebar.h b/chrome/browser/gtk/browser_titlebar.h
index c6da855..5cd30e6 100644
--- a/chrome/browser/gtk/browser_titlebar.h
+++ b/chrome/browser/gtk/browser_titlebar.h
@@ -31,6 +31,10 @@ class BrowserTitlebar : public NotificationObserver,
public ActiveWindowWatcherX::Observer,
public menus::SimpleMenuModel::Delegate {
public:
+ // A default button order string for when we aren't asking gconf for the
+ // metacity configuration.
+ static const char kDefaultButtonString[];
+
BrowserTitlebar(BrowserWindowGtk* browser_window, GtkWindow* window);
virtual ~BrowserTitlebar();
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.cc b/chrome/browser/gtk/browser_toolbar_gtk.cc
index 09fb457..5ceb32d 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.cc
+++ b/chrome/browser/gtk/browser_toolbar_gtk.cc
@@ -18,7 +18,6 @@
#include "base/path_service.h"
#include "base/singleton.h"
#include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/encoding_menu_controller.h"
#include "chrome/browser/gtk/accelerators_gtk.h"
#include "chrome/browser/gtk/back_forward_button_gtk.h"
@@ -39,6 +38,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/themes/browser_theme_provider.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/browser/upgrade_detector.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_details.h"
diff --git a/chrome/browser/gtk/browser_toolbar_gtk.h b/chrome/browser/gtk/browser_toolbar_gtk.h
index 1e27f8f..f2e8fec 100644
--- a/chrome/browser/gtk/browser_toolbar_gtk.h
+++ b/chrome/browser/gtk/browser_toolbar_gtk.h
@@ -10,6 +10,7 @@
#include <string>
#include "app/active_window_watcher_x.h"
+#include "app/animation_delegate.h"
#include "app/gtk_signal.h"
#include "app/gtk_signal_registrar.h"
#include "app/menus/accelerator.h"
diff --git a/chrome/browser/gtk/browser_window_factory_gtk.cc b/chrome/browser/gtk/browser_window_factory_gtk.cc
index 8291fb9..054a0df 100644
--- a/chrome/browser/gtk/browser_window_factory_gtk.cc
+++ b/chrome/browser/gtk/browser_window_factory_gtk.cc
@@ -4,9 +4,9 @@
#include "chrome/browser/browser_window.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/gtk/browser_window_gtk.h"
#include "chrome/browser/gtk/find_bar_gtk.h"
+#include "chrome/browser/ui/browser.h"
BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
return new BrowserWindowGtk(browser);
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 6d537c9..20dd209 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -24,7 +24,6 @@
#include "chrome/browser/app_modal_dialog_queue.h"
#include "chrome/browser/autocomplete/autocomplete_edit_view.h"
#include "chrome/browser/bookmarks/bookmark_utils.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/debugger/devtools_window.h"
@@ -69,12 +68,11 @@
#include "chrome/browser/page_info_window.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
-#include "chrome/browser/renderer_host/render_view_host.h"
-#include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tab_contents/tab_contents_view.h"
#include "chrome/browser/tabs/tab_strip_model.h"
#include "chrome/browser/themes/browser_theme_provider.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/browser/window_sizer.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/native_web_keyboard_event.h"
@@ -304,26 +302,6 @@ bool ShouldExecuteReservedCommandImmediately(
return true;
}
-// Performs Cut/Copy/Paste operation on the |window|.
-// If the current render view is focused, then just call the specified |method|
-// against the current render view host, otherwise emit the specified |signal|
-// against the focused widget.
-// TODO(suzhe): This approach does not work for plugins.
-void DoCutCopyPaste(BrowserWindowGtk* window, void (RenderViewHost::*method)(),
- const char* signal) {
- TabContents* current_tab_contents =
- window->browser()->tabstrip_model()->GetSelectedTabContents();
- if (current_tab_contents && current_tab_contents->GetContentNativeView() &&
- gtk_widget_is_focus(current_tab_contents->GetContentNativeView())) {
- (current_tab_contents->render_view_host()->*method)();
- } else {
- GtkWidget* widget = gtk_window_get_focus(window->window());
- guint id;
- if (widget && (id = g_signal_lookup(signal, G_OBJECT_TYPE(widget))) != 0)
- g_signal_emit(widget, id, 0);
- }
-}
-
} // namespace
std::map<XID, GtkWindow*> BrowserWindowGtk::xid_map_;
@@ -590,9 +568,10 @@ void BrowserWindowGtk::DrawCustomFrame(cairo_t* cr,
CairoCachedSurface* surface = theme_provider->GetSurfaceNamed(
image_name, widget);
if (event->area.y < surface->Height()) {
- surface->SetSource(cr,
- 0,
- UseCustomFrame() ? 0 : -kCustomFrameBackgroundVerticalOffset);
+ int offset = (IsMaximized() || (!UseCustomFrame())) ?
+ -kCustomFrameBackgroundVerticalOffset : 0;
+ surface->SetSource(cr, 0, offset);
+
// The frame background isn't tiled vertically.
cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
cairo_rectangle(cr, event->area.x, event->area.y,
@@ -899,10 +878,6 @@ bool BrowserWindowGtk::IsToolbarVisible() const {
return IsToolbarSupported();
}
-gfx::Rect BrowserWindowGtk::GetRootWindowResizerRect() const {
- return gfx::Rect();
-}
-
void BrowserWindowGtk::ConfirmAddSearchProvider(const TemplateURL* template_url,
Profile* profile) {
new EditSearchEngineDialog(window_, template_url, NULL, profile);
@@ -1116,15 +1091,19 @@ void BrowserWindowGtk::ShowCreateShortcutsDialog(TabContents* tab_contents) {
}
void BrowserWindowGtk::Cut() {
- DoCutCopyPaste(this, &RenderViewHost::Cut, "cut-clipboard");
+ gtk_util::DoCut(this);
}
void BrowserWindowGtk::Copy() {
- DoCutCopyPaste(this, &RenderViewHost::Copy, "copy-clipboard");
+ gtk_util::DoCopy(this);
}
void BrowserWindowGtk::Paste() {
- DoCutCopyPaste(this, &RenderViewHost::Paste, "paste-clipboard");
+ gtk_util::DoPaste(this);
+}
+
+void BrowserWindowGtk::PrepareForInstant() {
+ // TODO: implement fade as done on windows.
}
void BrowserWindowGtk::ShowInstant(TabContents* preview_contents) {
diff --git a/chrome/browser/gtk/browser_window_gtk.h b/chrome/browser/gtk/browser_window_gtk.h
index ce8e582..b1b8502 100644
--- a/chrome/browser/gtk/browser_window_gtk.h
+++ b/chrome/browser/gtk/browser_window_gtk.h
@@ -85,7 +85,6 @@ class BrowserWindowGtk : public BrowserWindow,
virtual bool IsBookmarkBarVisible() const;
virtual bool IsBookmarkBarAnimating() const;
virtual bool IsToolbarVisible() const;
- virtual gfx::Rect GetRootWindowResizerRect() const;
virtual void ConfirmAddSearchProvider(const TemplateURL* template_url,
Profile* profile);
virtual void ToggleBookmarkBar();
@@ -125,6 +124,7 @@ class BrowserWindowGtk : public BrowserWindow,
virtual void Copy();
virtual void Paste();
virtual void ToggleTabStripMode() {}
+ virtual void PrepareForInstant();
virtual void ShowInstant(TabContents* preview_contents);
virtual void HideInstant();
virtual gfx::Rect GetInstantBounds();
diff --git a/chrome/browser/gtk/chrome_gtk_frame.cc b/chrome/browser/gtk/chrome_gtk_frame.cc
new file mode 100644
index 0000000..77f28d1
--- /dev/null
+++ b/chrome/browser/gtk/chrome_gtk_frame.cc
@@ -0,0 +1,155 @@
+// Copyright (c) 2010 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/gtk/chrome_gtk_frame.h"
+
+G_BEGIN_DECLS
+
+// MetaFrames declaration
+G_DEFINE_TYPE(MetaFrames, meta_frames, GTK_TYPE_WINDOW)
+
+static void meta_frames_class_init(MetaFramesClass* frames_class) {
+ // Noop since we don't declare anything.
+}
+
+static void meta_frames_init(MetaFrames* button) {
+}
+
+
+// ChromeGtkFrame declaration
+G_DEFINE_TYPE(ChromeGtkFrame, chrome_gtk_frame, meta_frames_get_type())
+
+static void chrome_gtk_frame_class_init(ChromeGtkFrameClass* frame_class) {
+ GtkWidgetClass* widget_class = reinterpret_cast<GtkWidgetClass*>(frame_class);
+
+ // Frame tints:
+ gtk_widget_class_install_style_property(
+ widget_class,
+ g_param_spec_boxed(
+ "frame-color",
+ "Frame Color",
+ "The color that the chrome frame will be. (If unspecified, "
+ " Chrome will take ChromeGtkFrame::bg[SELECTED] and slightly darken"
+ " it.)",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property(
+ widget_class,
+ g_param_spec_boxed(
+ "inactive-frame-color",
+ "Inactive Frame Color",
+ "The color that the inactive chrome frame will be. (If"
+ " unspecified, Chrome will take ChromeGtkFrame::bg[INSENSITIVE]"
+ " and slightly darken it.)",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property(
+ widget_class,
+ g_param_spec_boxed(
+ "incognito-frame-color",
+ "Incognito Frame Color",
+ "The color that the incognito frame will be. (If unspecified,"
+ " Chrome will take the frame color and tint it by Chrome's default"
+ " incognito tint.)",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property(
+ widget_class,
+ g_param_spec_boxed(
+ "incognito-inactive-frame-color",
+ "Incognito Inactive Frame Color",
+ "The color that the inactive incognito frame will be. (If"
+ " unspecified, Chrome will take the frame color and tint it by"
+ " Chrome's default incognito tint.)",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+
+ // Frame gradient control:
+ gtk_widget_class_install_style_property(
+ widget_class,
+ g_param_spec_int(
+ "frame-gradient-size",
+ "Chrome Frame Gradient Size",
+ "The size of the gradient on top of the frame image. Specify 0 to"
+ " make the frame a solid color.",
+ 0, // 0 disables the gradient
+ 128, // The frame image is only up to 128 pixels tall.
+ 16, // By default, gradients are 16 pixels high.
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property(
+ widget_class,
+ g_param_spec_boxed(
+ "frame-gradient-color",
+ "Frame Gradient Color",
+ "The top color of the chrome frame gradient. (If unspecified,"
+ " chrome will create a lighter tint of frame-color",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property(
+ widget_class,
+ g_param_spec_boxed(
+ "inactive-frame-gradient-color",
+ "Inactive Frame Gradient Color",
+ "The top color of the inactive chrome frame gradient. (If"
+ " unspecified, chrome will create a lighter tint of frame-color",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property(
+ widget_class,
+ g_param_spec_boxed(
+ "incognito-frame-gradient-color",
+ "Incognito Frame Gradient Color",
+ "The top color of the incognito chrome frame gradient. (If"
+ " unspecified, chrome will create a lighter tint of frame-color",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property(
+ widget_class,
+ g_param_spec_boxed(
+ "incognito-inactive-frame-gradient-color",
+ "Incognito Inactive Frame Gradient Color",
+ "The top color of the incognito inactive chrome frame gradient. (If"
+ " unspecified, chrome will create a lighter tint of frame-color",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+
+ // Scrollbar color properties:
+ gtk_widget_class_install_style_property(
+ widget_class,
+ g_param_spec_boxed(
+ "scrollbar-slider-prelight-color",
+ "Scrollbar Slider Prelight Color",
+ "The color applied to the mouse is above the tab",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property(
+ widget_class,
+ g_param_spec_boxed(
+ "scrollbar-slider-normal-color",
+ "Scrollbar Slider Normal Color",
+ "The color applied to the slider normally",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property(
+ widget_class,
+ g_param_spec_boxed(
+ "scrollbar-trough-color",
+ "Scrollbar Trough Color",
+ "The background color of the slider track",
+ GDK_TYPE_COLOR,
+ G_PARAM_READABLE));
+}
+
+static void chrome_gtk_frame_init(ChromeGtkFrame* frame) {
+}
+
+GtkWidget* chrome_gtk_frame_new(void) {
+ GtkWindow* window =
+ GTK_WINDOW(g_object_new(chrome_gtk_frame_get_type(), NULL));
+ window->type = GTK_WINDOW_TOPLEVEL;
+ return GTK_WIDGET(window);
+}
+
+
+G_END_DECLS
diff --git a/chrome/browser/gtk/chrome_gtk_frame.h b/chrome/browser/gtk/chrome_gtk_frame.h
new file mode 100644
index 0000000..0fd7d28
--- /dev/null
+++ b/chrome/browser/gtk/chrome_gtk_frame.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2010 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_GTK_CHROME_GTK_FRAME_H_
+#define CHROME_BROWSER_GTK_CHROME_GTK_FRAME_H_
+#pragma once
+
+#include <gdk/gdk.h>
+#include <gtk/gtkwindow.h>
+
+G_BEGIN_DECLS
+
+// This file declares two subclasses of GtkWindow for easier gtk+ theme
+// integration.
+//
+// The first is "MetaFrames," which is (was?) the name of a gobject class in
+// the metacity window manager. To actually get at those values, we need to
+// have an object whose gobject class name string matches the definitions in
+// the gtkrc file. MetaFrames derives from GtkWindow.
+//
+// Metaframes can not be instantiated. It has no constructor; instantiate
+// ChromeGtkFrame instead.
+typedef struct _MetaFrames MetaFrames;
+typedef struct _MetaFramesClass MetaFramesClass;
+
+struct _MetaFrames {
+ GtkWindow window;
+};
+
+struct _MetaFramesClass {
+ GtkWindowClass parent_class;
+};
+
+
+// The second is ChromeGtkFrame, which defines a number of optional style
+// properties so theme authors can control how chromium appears in gtk-theme
+// mode. It derives from MetaFrames in chrome so older themes that declare a
+// MetaFrames theme will still work. New themes should target this class.
+typedef struct _ChromeGtkFrame ChromeGtkFrame;
+typedef struct _ChromeGtkFrameClass ChromeGtkFrameClass;
+
+struct _ChromeGtkFrame {
+ MetaFrames frames;
+};
+
+struct _ChromeGtkFrameClass {
+ MetaFramesClass frames_class;
+};
+
+// Creates a GtkWindow object the the class name "ChromeGtkFrame".
+GtkWidget* chrome_gtk_frame_new();
+
+G_END_DECLS
+
+#endif // CHROME_BROWSER_GTK_CHROME_GTK_FRAME_H_
diff --git a/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc b/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc
index 2607359..b5b2450 100644
--- a/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc
+++ b/chrome/browser/gtk/clear_browsing_data_dialog_gtk.cc
@@ -7,7 +7,6 @@
#include <string>
#include "app/l10n_util.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/browsing_data_remover.h"
#include "chrome/browser/gtk/accessible_widget_helper_gtk.h"
#include "chrome/browser/gtk/browser_window_gtk.h"
@@ -15,6 +14,7 @@
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
diff --git a/chrome/browser/gtk/constrained_window_gtk.cc b/chrome/browser/gtk/constrained_window_gtk.cc
index 14564de..f10dc03 100644
--- a/chrome/browser/gtk/constrained_window_gtk.cc
+++ b/chrome/browser/gtk/constrained_window_gtk.cc
@@ -45,7 +45,11 @@ ConstrainedWindowGtk::ConstrainedWindowGtk(
gtk_widget_modify_bg(ebox, GTK_STATE_NORMAL, &background);
}
- gtk_container_add(GTK_CONTAINER(alignment), dialog);
+ if (gtk_widget_get_parent(dialog))
+ gtk_widget_reparent(dialog, alignment);
+ else
+ gtk_container_add(GTK_CONTAINER(alignment), dialog);
+
gtk_container_add(GTK_CONTAINER(frame), alignment);
gtk_container_add(GTK_CONTAINER(ebox), frame);
border_.Own(ebox);
diff --git a/chrome/browser/gtk/custom_button.h b/chrome/browser/gtk/custom_button.h
index 4d19510..785df6b 100644
--- a/chrome/browser/gtk/custom_button.h
+++ b/chrome/browser/gtk/custom_button.h
@@ -8,6 +8,7 @@
#include <gtk/gtk.h>
+#include "app/animation_delegate.h"
#include "app/gtk_signal.h"
#include "app/slide_animation.h"
#include "base/scoped_ptr.h"
diff --git a/chrome/browser/gtk/dialogs_gtk.cc b/chrome/browser/gtk/dialogs_gtk.cc
index 4872f89..8a95192 100644
--- a/chrome/browser/gtk/dialogs_gtk.cc
+++ b/chrome/browser/gtk/dialogs_gtk.cc
@@ -172,6 +172,7 @@ SelectFileDialog* SelectFileDialog::Create(Listener* listener) {
SelectFileDialogImpl::SelectFileDialogImpl(Listener* listener)
: listener_(listener),
file_type_index_(0),
+ type_(SELECT_NONE),
preview_(NULL) {
if (!last_saved_path_) {
last_saved_path_ = new FilePath();
diff --git a/chrome/browser/gtk/download_in_progress_dialog_gtk.cc b/chrome/browser/gtk/download_in_progress_dialog_gtk.cc
index 8a41589..3b039ca 100644
--- a/chrome/browser/gtk/download_in_progress_dialog_gtk.cc
+++ b/chrome/browser/gtk/download_in_progress_dialog_gtk.cc
@@ -9,11 +9,11 @@
#include "app/l10n_util.h"
#include "base/string_number_conversions.h"
#include "base/string16.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_window.h"
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_window.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
diff --git a/chrome/browser/gtk/download_item_gtk.cc b/chrome/browser/gtk/download_item_gtk.cc
index 844c751..329208b 100644
--- a/chrome/browser/gtk/download_item_gtk.cc
+++ b/chrome/browser/gtk/download_item_gtk.cc
@@ -14,7 +14,6 @@
#include "base/string_util.h"
#include "base/time.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/download/download_item.h"
#include "chrome/browser/download/download_item_model.h"
@@ -27,6 +26,7 @@
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/menu_gtk.h"
#include "chrome/browser/gtk/nine_box.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/notification_service.h"
#include "gfx/canvas_skia_paint.h"
#include "gfx/color_utils.h"
diff --git a/chrome/browser/gtk/download_item_gtk.h b/chrome/browser/gtk/download_item_gtk.h
index f73592a..a9ad27d 100644
--- a/chrome/browser/gtk/download_item_gtk.h
+++ b/chrome/browser/gtk/download_item_gtk.h
@@ -10,7 +10,7 @@
#include <string>
-#include "app/animation.h"
+#include "app/animation_delegate.h"
#include "app/gtk_signal.h"
#include "base/scoped_ptr.h"
#include "base/time.h"
diff --git a/chrome/browser/gtk/download_shelf_gtk.cc b/chrome/browser/gtk/download_shelf_gtk.cc
index a6c2a69..3c47c38 100644
--- a/chrome/browser/gtk/download_shelf_gtk.cc
+++ b/chrome/browser/gtk/download_shelf_gtk.cc
@@ -6,7 +6,6 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/download/download_item.h"
#include "chrome/browser/download/download_item_model.h"
#include "chrome/browser/download/download_util.h"
@@ -18,6 +17,7 @@
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/notification_service.h"
#include "gfx/gtk_util.h"
#include "grit/generated_resources.h"
diff --git a/chrome/browser/gtk/extension_infobar_gtk.cc b/chrome/browser/gtk/extension_infobar_gtk.cc
index 35d86c0..bd40795 100644
--- a/chrome/browser/gtk/extension_infobar_gtk.cc
+++ b/chrome/browser/gtk/extension_infobar_gtk.cc
@@ -62,7 +62,13 @@ void ExtensionInfoBarGtk::BuildWidgets() {
ExtensionHost* extension_host = delegate_->extension_host();
view_ = extension_host->view();
- gtk_box_pack_start(GTK_BOX(hbox_), view_->native_view(), TRUE, TRUE, 0);
+ if (gtk_widget_get_parent(view_->native_view())) {
+ gtk_widget_reparent(view_->native_view(), hbox_);
+ gtk_box_set_child_packing(GTK_BOX(hbox_), view_->native_view(),
+ TRUE, TRUE, 0, GTK_PACK_START);
+ } else {
+ gtk_box_pack_start(GTK_BOX(hbox_), view_->native_view(), TRUE, TRUE, 0);
+ }
g_signal_connect(view_->native_view(), "size_allocate",
G_CALLBACK(&OnSizeAllocateThunk), this);
diff --git a/chrome/browser/gtk/extension_infobar_gtk.h b/chrome/browser/gtk/extension_infobar_gtk.h
index b727c04..b204bfc 100644
--- a/chrome/browser/gtk/extension_infobar_gtk.h
+++ b/chrome/browser/gtk/extension_infobar_gtk.h
@@ -6,8 +6,6 @@
#define CHROME_BROWSER_GTK_EXTENSION_INFOBAR_GTK_H_
#pragma once
-#include <gtk/gtk.h>
-
#include "chrome/browser/gtk/extension_view_gtk.h"
#include "chrome/browser/gtk/infobar_gtk.h"
#include "chrome/browser/extensions/extension_infobar_delegate.h"
diff --git a/chrome/browser/gtk/extension_install_prompt2_gtk.cc b/chrome/browser/gtk/extension_install_prompt2_gtk.cc
index cf78028..10ee4e4 100644
--- a/chrome/browser/gtk/extension_install_prompt2_gtk.cc
+++ b/chrome/browser/gtk/extension_install_prompt2_gtk.cc
@@ -107,11 +107,8 @@ void ShowInstallPromptDialog2(GtkWindow* parent, SkBitmap* skia_icon,
!show_permissions, !show_permissions, 0);
if (show_permissions) {
- int label = extension->is_app() ?
- IDS_EXTENSION_PROMPT2_APP_WILL_HAVE_ACCESS_TO :
- IDS_EXTENSION_PROMPT2_WILL_HAVE_ACCESS_TO;
GtkWidget* warning_label = gtk_label_new(l10n_util::GetStringUTF8(
- label).c_str());
+ IDS_EXTENSION_PROMPT_WILL_HAVE_ACCESS_TO).c_str());
gtk_misc_set_alignment(GTK_MISC(warning_label), 0.0, 0.5);
gtk_util::SetLabelWidth(warning_label, kRightColumnMinWidth);
diff --git a/chrome/browser/gtk/extension_installed_bubble_gtk.cc b/chrome/browser/gtk/extension_installed_bubble_gtk.cc
index af9c915..adb2b7b 100644
--- a/chrome/browser/gtk/extension_installed_bubble_gtk.cc
+++ b/chrome/browser/gtk/extension_installed_bubble_gtk.cc
@@ -9,13 +9,13 @@
#include "base/i18n/rtl.h"
#include "base/message_loop.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/gtk/browser_actions_toolbar_gtk.h"
#include "chrome/browser/gtk/browser_toolbar_gtk.h"
#include "chrome/browser/gtk/browser_window_gtk.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/location_bar_view_gtk.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_action.h"
#include "chrome/common/notification_service.h"
@@ -57,7 +57,9 @@ ExtensionInstalledBubbleGtk::ExtensionInstalledBubbleGtk(
animation_wait_retries_(kAnimationWaitRetries) {
AddRef(); // Balanced in Close().
- if (extension_->browser_action()) {
+ if (!extension_->omnibox_keyword().empty()) {
+ type_ = OMNIBOX_KEYWORD;
+ } else if (extension_->browser_action()) {
type_ = BROWSER_ACTION;
} else if (extension->page_action() &&
!extension->page_action()->default_icon_path().empty()) {
@@ -141,7 +143,13 @@ void ExtensionInstalledBubbleGtk::ShowInternal() {
gtk_container_check_resize(GTK_CONTAINER(
browser_window->GetToolbar()->widget()));
DCHECK(reference_widget);
+ } else if (type_ == OMNIBOX_KEYWORD) {
+ LocationBarViewGtk* location_bar_view =
+ browser_window->GetToolbar()->GetLocationBarView();
+ reference_widget = location_bar_view->location_entry_widget();
+ DCHECK(reference_widget);
}
+
// Default case.
if (reference_widget == NULL)
reference_widget = browser_window->GetToolbar()->GetAppMenuButton();
@@ -153,34 +161,36 @@ void ExtensionInstalledBubbleGtk::ShowInternal() {
GtkWidget* bubble_content = gtk_hbox_new(FALSE, kHorizontalColumnSpacing);
gtk_container_set_border_width(GTK_CONTAINER(bubble_content), kContentBorder);
- // Scale icon down to 43x43, but allow smaller icons (don't scale up).
- GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon_);
- gfx::Size size(icon_.width(), icon_.height());
- if (size.width() > kIconSize || size.height() > kIconSize) {
- if (size.width() > size.height()) {
- size.set_height(size.height() * kIconSize / size.width());
- size.set_width(kIconSize);
- } else {
- size.set_width(size.width() * kIconSize / size.height());
- size.set_height(kIconSize);
+ if (!icon_.isNull()) {
+ // Scale icon down to 43x43, but allow smaller icons (don't scale up).
+ GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&icon_);
+ gfx::Size size(icon_.width(), icon_.height());
+ if (size.width() > kIconSize || size.height() > kIconSize) {
+ if (size.width() > size.height()) {
+ size.set_height(size.height() * kIconSize / size.width());
+ size.set_width(kIconSize);
+ } else {
+ size.set_width(size.width() * kIconSize / size.height());
+ size.set_height(kIconSize);
+ }
+
+ GdkPixbuf* old = pixbuf;
+ pixbuf = gdk_pixbuf_scale_simple(pixbuf, size.width(), size.height(),
+ GDK_INTERP_BILINEAR);
+ g_object_unref(old);
}
- GdkPixbuf* old = pixbuf;
- pixbuf = gdk_pixbuf_scale_simple(pixbuf, size.width(), size.height(),
- GDK_INTERP_BILINEAR);
- g_object_unref(old);
+ // Put Icon in top of the left column.
+ GtkWidget* icon_column = gtk_vbox_new(FALSE, 0);
+ // Use 3 pixel padding to get visual balance with InfoBubble border on the
+ // left.
+ gtk_box_pack_start(GTK_BOX(bubble_content), icon_column, FALSE, FALSE,
+ kIconPadding);
+ GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf);
+ g_object_unref(pixbuf);
+ gtk_box_pack_start(GTK_BOX(icon_column), image, FALSE, FALSE, 0);
}
- // Put Icon in top of the left column.
- GtkWidget* icon_column = gtk_vbox_new(FALSE, 0);
- // Use 3 pixel padding to get visual balance with InfoBubble border on the
- // left.
- gtk_box_pack_start(GTK_BOX(bubble_content), icon_column, FALSE, FALSE,
- kIconPadding);
- GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf);
- g_object_unref(pixbuf);
- gtk_box_pack_start(GTK_BOX(icon_column), image, FALSE, FALSE, 0);
-
// Center text column.
GtkWidget* text_column = gtk_vbox_new(FALSE, kTextColumnVerticalSpacing);
gtk_box_pack_start(GTK_BOX(bubble_content), text_column, FALSE, FALSE, 0);
@@ -199,9 +209,19 @@ void ExtensionInstalledBubbleGtk::ShowInternal() {
gtk_box_pack_start(GTK_BOX(text_column), heading_label, FALSE, FALSE, 0);
// Page action label
- if (type_ == ExtensionInstalledBubbleGtk::PAGE_ACTION) {
+ if (type_ == PAGE_ACTION) {
GtkWidget* info_label = gtk_label_new(l10n_util::GetStringUTF8(
- IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO).c_str());
+ IDS_EXTENSION_INSTALLED_PAGE_ACTION_INFO).c_str());
+ gtk_label_set_line_wrap(GTK_LABEL(info_label), TRUE);
+ gtk_widget_set_size_request(info_label, kTextColumnWidth, -1);
+ gtk_box_pack_start(GTK_BOX(text_column), info_label, FALSE, FALSE, 0);
+ }
+
+ // Omnibox keyword label
+ if (type_ == OMNIBOX_KEYWORD) {
+ GtkWidget* info_label = gtk_label_new(l10n_util::GetStringFUTF8(
+ IDS_EXTENSION_INSTALLED_OMNIBOX_KEYWORD_INFO,
+ UTF8ToUTF16(extension_->omnibox_keyword())).c_str());
gtk_label_set_line_wrap(GTK_LABEL(info_label), TRUE);
gtk_widget_set_size_request(info_label, kTextColumnWidth, -1);
gtk_box_pack_start(GTK_BOX(text_column), info_label, FALSE, FALSE, 0);
@@ -232,8 +252,23 @@ void ExtensionInstalledBubbleGtk::ShowInternal() {
!base::i18n::IsRTL() ?
InfoBubbleGtk::ARROW_LOCATION_TOP_RIGHT :
InfoBubbleGtk::ARROW_LOCATION_TOP_LEFT;
+
+ gfx::Rect bounds = gtk_util::WidgetBounds(reference_widget);
+ if (type_ == OMNIBOX_KEYWORD) {
+ // Reverse the arrow for omnibox keywords, since the bubble will be on the
+ // other side of the window. We also clear the width to avoid centering
+ // the popup on the URL bar.
+ arrow_location =
+ !base::i18n::IsRTL() ?
+ InfoBubbleGtk::ARROW_LOCATION_TOP_LEFT :
+ InfoBubbleGtk::ARROW_LOCATION_TOP_RIGHT;
+ if (base::i18n::IsRTL())
+ bounds.Offset(bounds.width(), 0);
+ bounds.set_width(0);
+ }
+
info_bubble_ = InfoBubbleGtk::Show(reference_widget,
- NULL,
+ &bounds,
bubble_content,
arrow_location,
true, // match_system_theme
diff --git a/chrome/browser/gtk/extension_installed_bubble_gtk.h b/chrome/browser/gtk/extension_installed_bubble_gtk.h
index 08d6fec..0613283 100644
--- a/chrome/browser/gtk/extension_installed_bubble_gtk.h
+++ b/chrome/browser/gtk/extension_installed_bubble_gtk.h
@@ -22,6 +22,7 @@ class SkBitmap;
// Provides feedback to the user upon successful installation of an
// extension. Depending on the type of extension, the InfoBubble will
// point to:
+// OMNIBOX_KEYWORD-> The omnibox.
// BROWSER_ACTION -> The browserAction icon in the toolbar.
// PAGE_ACTION -> A preview of the page action icon in the location
// bar which is shown while the InfoBubble is shown.
@@ -36,6 +37,7 @@ class ExtensionInstalledBubbleGtk
public:
// The behavior and content of this InfoBubble comes in three varieties.
enum BubbleType {
+ OMNIBOX_KEYWORD,
BROWSER_ACTION,
PAGE_ACTION,
GENERIC
diff --git a/chrome/browser/gtk/extension_popup_gtk.cc b/chrome/browser/gtk/extension_popup_gtk.cc
index 32b32bc..e9ed014 100644
--- a/chrome/browser/gtk/extension_popup_gtk.cc
+++ b/chrome/browser/gtk/extension_popup_gtk.cc
@@ -8,7 +8,6 @@
#include "base/i18n/rtl.h"
#include "base/message_loop.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/debugger/devtools_manager.h"
#include "chrome/browser/profile.h"
@@ -17,6 +16,7 @@
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/render_widget_host_view_gtk.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/notification_service.h"
#include "googleurl/src/gurl.h"
diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc
index 8afba9a..aa3429f 100644
--- a/chrome/browser/gtk/find_bar_gtk.cc
+++ b/chrome/browser/gtk/find_bar_gtk.cc
@@ -16,7 +16,6 @@
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/find_bar_controller.h"
#include "chrome/browser/find_bar_state.h"
#include "chrome/browser/gtk/browser_window_gtk.h"
@@ -33,6 +32,7 @@
#include "chrome/browser/profile.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/native_web_keyboard_event.h"
#include "chrome/common/notification_service.h"
#include "grit/generated_resources.h"
diff --git a/chrome/browser/gtk/first_run_bubble.cc b/chrome/browser/gtk/first_run_bubble.cc
index 81daf73..343f57b 100644
--- a/chrome/browser/gtk/first_run_bubble.cc
+++ b/chrome/browser/gtk/first_run_bubble.cc
@@ -10,11 +10,11 @@
#include "base/command_line.h"
#include "base/i18n/rtl.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/search_engines/util.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/notification_service.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
diff --git a/chrome/browser/gtk/gconf_titlebar_listener.cc b/chrome/browser/gtk/gconf_titlebar_listener.cc
index 81b5ef0..237332f 100644
--- a/chrome/browser/gtk/gconf_titlebar_listener.cc
+++ b/chrome/browser/gtk/gconf_titlebar_listener.cc
@@ -13,10 +13,6 @@
namespace {
-// A default button order string for when we aren't asking gconf for the
-// metacity configuration.
-const char* kDefaultButtonPlacement = ":minimize,maximize,close";
-
// The GConf key we read for the button placement string. Even through the key
// has "metacity" in it, it's shared between metacity and compiz.
const char* kButtonLayoutKey = "/apps/metacity/general/button_layout";
@@ -34,7 +30,7 @@ void GConfTitlebarListener::SetTitlebarButtons(BrowserTitlebar* titlebar) {
titlebar->BuildButtons(current_value_);
titlebars_.insert(titlebar);
} else {
- titlebar->BuildButtons(kDefaultButtonPlacement);
+ titlebar->BuildButtons(BrowserTitlebar::kDefaultButtonString);
}
}
@@ -113,8 +109,8 @@ bool GConfTitlebarListener::HandleGError(GError* error, const char* key) {
void GConfTitlebarListener::ParseAndStoreValue(GConfValue* gconf_value) {
if (gconf_value) {
const char* value = gconf_value_get_string(gconf_value);
- current_value_ = value ? value : kDefaultButtonPlacement;
+ current_value_ = value ? value : BrowserTitlebar::kDefaultButtonString;
} else {
- current_value_ = kDefaultButtonPlacement;
+ current_value_ = BrowserTitlebar::kDefaultButtonString;
}
}
diff --git a/chrome/browser/gtk/gtk_theme_provider.cc b/chrome/browser/gtk/gtk_theme_provider.cc
index 6d04b57..a57ab6b 100644
--- a/chrome/browser/gtk/gtk_theme_provider.cc
+++ b/chrome/browser/gtk/gtk_theme_provider.cc
@@ -14,10 +14,10 @@
#include "base/stl_util-inl.h"
#include "base/nix/xdg_util.h"
#include "chrome/browser/gtk/cairo_cached_surface.h"
+#include "chrome/browser/gtk/chrome_gtk_frame.h"
#include "chrome/browser/gtk/gtk_chrome_button.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/hover_controller_gtk.h"
-#include "chrome/browser/gtk/meta_frames.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
@@ -26,15 +26,18 @@
#include "chrome/common/notification_source.h"
#include "chrome/common/notification_type.h"
#include "chrome/common/pref_names.h"
+#include "gfx/canvas_skia.h"
#include "gfx/color_utils.h"
#include "gfx/gtk_util.h"
#include "gfx/skbitmap_operations.h"
+#include "gfx/skia_util.h"
#include "gfx/skia_utils_gtk.h"
#include "grit/app_resources.h"
#include "grit/theme_resources.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
+#include "third_party/skia/include/core/SkShader.h"
namespace {
@@ -42,8 +45,11 @@ namespace {
const int kToolbarImageWidth = 64;
const int kToolbarImageHeight = 128;
-const color_utils::HSL kExactColor = { -1, -1, -1 };
+// How much to tint the GTK+ color lighter at the top of the window.
+const color_utils::HSL kGtkFrameShift = { -1, -1, 0.58 };
+// How much to tint the GTK+ color when an explicit frame color hasn't been
+// specified.
const color_utils::HSL kDefaultFrameShift = { -1, -1, 0.4 };
// Values used as the new luminance and saturation values in the inactive tab
@@ -53,10 +59,6 @@ const double kLightInactiveLuminance = 0.15;
const double kHeavyInactiveSaturation = 0.7;
const double kLightInactiveSaturation = 0.3;
-// Minimum difference between the toolbar and the button color before we try a
-// different color.
-const double kMinimumLuminanceDifference = 0.1;
-
// Number of times that the background color should be counted when trying to
// calculate the border color in GTK theme mode.
const int kBgWeight = 3;
@@ -227,6 +229,14 @@ void BuildIconFromIDRWithColor(int id,
gtk_icon_source_free(icon);
}
+// Applies an HSL shift to a GdkColor (instead of an SkColor)
+void GdkColorHSLShift(const color_utils::HSL& shift, GdkColor* frame_color) {
+ SkColor shifted = color_utils::HSLShift(GdkToSkColor(frame_color), shift);
+ frame_color->pixel = 0;
+ frame_color->red = SkColorGetR(shifted) * kSkiaToGDKMultiplier;
+ frame_color->green = SkColorGetG(shifted) * kSkiaToGDKMultiplier;
+ frame_color->blue = SkColorGetB(shifted) * kSkiaToGDKMultiplier;
+}
} // namespace
@@ -242,7 +252,7 @@ GtkThemeProvider* GtkThemeProvider::GetFrom(Profile* profile) {
GtkThemeProvider::GtkThemeProvider()
: BrowserThemeProvider(),
fake_window_(gtk_window_new(GTK_WINDOW_TOPLEVEL)),
- fake_frame_(meta_frames_new()),
+ fake_frame_(chrome_gtk_frame_new()),
signals_(new GtkSignalRegistrar),
fullscreen_icon_set_(NULL) {
fake_label_.Own(gtk_label_new(""));
@@ -414,6 +424,24 @@ GtkIconSet* GtkThemeProvider::GetIconSetForId(int id) const {
void GtkThemeProvider::GetScrollbarColors(GdkColor* thumb_active_color,
GdkColor* thumb_inactive_color,
GdkColor* track_color) {
+ const GdkColor* theme_thumb_active = NULL;
+ const GdkColor* theme_thumb_inactive = NULL;
+ const GdkColor* theme_trough_color = NULL;
+ gtk_widget_style_get(GTK_WIDGET(fake_frame_),
+ "scrollbar-slider-prelight-color", &theme_thumb_active,
+ "scrollbar-slider-normal-color", &theme_thumb_inactive,
+ "scrollbar-trough-color", &theme_trough_color,
+ NULL);
+
+ // Ask the theme if the theme specifies all the scrollbar colors and short
+ // circuit the expensive painting/compositing if we have all of them.
+ if (theme_thumb_active && theme_thumb_inactive && theme_trough_color) {
+ *thumb_active_color = *theme_thumb_active;
+ *thumb_inactive_color = *theme_thumb_inactive;
+ *track_color = *theme_trough_color;
+ return;
+ }
+
// Create window containing scrollbar elements
GtkWidget* window = gtk_window_new(GTK_WINDOW_POPUP);
GtkWidget* fixed = gtk_fixed_new();
@@ -479,6 +507,17 @@ void GtkThemeProvider::GetScrollbarColors(GdkColor* thumb_active_color,
g_object_unref(pm);
gtk_widget_destroy(window);
+
+ // Override any of the default colors with ones that were specified by the
+ // theme.
+ if (theme_thumb_active)
+ *thumb_active_color = *theme_thumb_active;
+
+ if (theme_thumb_inactive)
+ *thumb_inactive_color = *theme_thumb_inactive;
+
+ if (theme_trough_color)
+ *track_color = *theme_trough_color;
}
CairoCachedSurface* GtkThemeProvider::GetSurfaceNamed(
@@ -630,87 +669,29 @@ void GtkThemeProvider::LoadGtkValues() {
pref_images->Clear();
GtkStyle* frame_style = gtk_rc_get_style(fake_frame_);
- GdkColor frame_color = frame_style->bg[GTK_STATE_SELECTED];
- GdkColor inactive_frame_color = frame_style->bg[GTK_STATE_INSENSITIVE];
GtkStyle* window_style = gtk_rc_get_style(fake_window_);
+ SetThemeColorFromGtk(BrowserThemeProvider::COLOR_CONTROL_BACKGROUND,
+ &window_style->bg[GTK_STATE_NORMAL]);
+ SetThemeColorFromGtk(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND,
+ &window_style->bg[GTK_STATE_NORMAL]);
+
GdkColor toolbar_color = window_style->bg[GTK_STATE_NORMAL];
+ SetThemeColorFromGtk(BrowserThemeProvider::COLOR_TOOLBAR, &toolbar_color);
+
GdkColor button_color = window_style->bg[GTK_STATE_SELECTED];
+ SetThemeTintFromGtk(BrowserThemeProvider::TINT_BUTTONS, &button_color);
GtkStyle* label_style = gtk_rc_get_style(fake_label_.get());
GdkColor label_color = label_style->fg[GTK_STATE_NORMAL];
-
- GtkSettings* settings = gtk_settings_get_default();
- bool theme_has_frame_color = false;
- if (settings) {
- GHashTable* color_scheme = NULL;
- g_object_get(settings, "color-hash", &color_scheme, NULL);
-
- if (color_scheme) {
- // If we have a "gtk-color-scheme" set in this theme, mine it for hints
- // about what we should actually set the frame color to.
- GdkColor* color = NULL;
- if ((color = static_cast<GdkColor*>(
- g_hash_table_lookup(color_scheme, "frame_color")))) {
- frame_color = *color;
- theme_has_frame_color = true;
- }
-
- if ((color = static_cast<GdkColor*>(
- g_hash_table_lookup(color_scheme, "inactive_frame_color")))) {
- inactive_frame_color = *color;
- }
- }
- }
-
- if (!theme_has_frame_color) {
- // If the theme's gtkrc doesn't explicitly tell us to use a specific frame
- // color, change the luminosity of the frame color downwards to 80% of what
- // it currently is. This is in a futile attempt to match the default
- // metacity and xfwm themes.
- SkColor shifted = color_utils::HSLShift(GdkToSkColor(&frame_color),
- kDefaultFrameShift);
- frame_color.pixel = 0;
- frame_color.red = SkColorGetR(shifted) * kSkiaToGDKMultiplier;
- frame_color.green = SkColorGetG(shifted) * kSkiaToGDKMultiplier;
- frame_color.blue = SkColorGetB(shifted) * kSkiaToGDKMultiplier;
- }
+ SetThemeColorFromGtk(BrowserThemeProvider::COLOR_TAB_TEXT, &label_color);
+ SetThemeColorFromGtk(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, &label_color);
// Build the various icon tints.
GetNormalButtonTintHSL(&button_tint_);
GetNormalEntryForegroundHSL(&entry_tint_);
GetSelectedEntryForegroundHSL(&selected_entry_tint_);
-
- SetThemeTintFromGtk(BrowserThemeProvider::TINT_BUTTONS, &button_color);
- SetThemeTintFromGtk(BrowserThemeProvider::TINT_FRAME, &frame_color);
- SetThemeTintFromGtk(BrowserThemeProvider::TINT_FRAME_INCOGNITO, &frame_color);
- SetThemeTintFromGtk(BrowserThemeProvider::TINT_BACKGROUND_TAB, &frame_color);
-
- // The inactive color/tint is special: We *must* use the exact insensitive
- // color for all inactive windows, otherwise we end up neon pink half the
- // time.
- SetThemeColorFromGtk(BrowserThemeProvider::COLOR_FRAME_INACTIVE,
- &inactive_frame_color);
- SetTintToExactColor(BrowserThemeProvider::TINT_FRAME_INACTIVE,
- &inactive_frame_color);
- SetTintToExactColor(BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE,
- &inactive_frame_color);
-
- SetThemeColorFromGtk(BrowserThemeProvider::COLOR_FRAME, &frame_color);
- BuildTintedFrameColor(BrowserThemeProvider::COLOR_FRAME_INACTIVE,
- BrowserThemeProvider::TINT_FRAME_INACTIVE);
- BuildTintedFrameColor(BrowserThemeProvider::COLOR_FRAME_INCOGNITO,
- BrowserThemeProvider::TINT_FRAME_INCOGNITO);
- BuildTintedFrameColor(BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE,
- BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE);
-
- SetThemeColorFromGtk(BrowserThemeProvider::COLOR_TOOLBAR, &toolbar_color);
- SetThemeColorFromGtk(BrowserThemeProvider::COLOR_TAB_TEXT, &label_color);
- SetThemeColorFromGtk(BrowserThemeProvider::COLOR_BOOKMARK_TEXT, &label_color);
- SetThemeColorFromGtk(BrowserThemeProvider::COLOR_CONTROL_BACKGROUND,
- &window_style->bg[GTK_STATE_NORMAL]);
- SetThemeColorFromGtk(BrowserThemeProvider::COLOR_BUTTON_BACKGROUND,
- &window_style->bg[GTK_STATE_NORMAL]);
+ GdkColor frame_color = BuildFrameColors(frame_style);
// The inactive frame color never occurs naturally in the theme, as it is a
// tinted version of |frame_color|. We generate another color based on the
@@ -794,6 +775,51 @@ void GtkThemeProvider::LoadGtkValues() {
GdkToSkColor(&entry_style->text[GTK_STATE_ACTIVE]);
}
+GdkColor GtkThemeProvider::BuildFrameColors(GtkStyle* frame_style) {
+ const GdkColor* theme_frame = NULL;
+ const GdkColor* theme_inactive_frame = NULL;
+ const GdkColor* theme_incognito_frame = NULL;
+ const GdkColor* theme_incognito_inactive_frame = NULL;
+ gtk_widget_style_get(GTK_WIDGET(fake_frame_),
+ "frame-color", &theme_frame,
+ "inactive-frame-color", &theme_inactive_frame,
+ "incognito-frame-color", &theme_incognito_frame,
+ "incognito-inactive-frame-color",
+ &theme_incognito_inactive_frame,
+ NULL);
+
+ GdkColor frame_color = BuildAndSetFrameColor(
+ &frame_style->bg[GTK_STATE_SELECTED],
+ theme_frame,
+ kDefaultFrameShift,
+ BrowserThemeProvider::COLOR_FRAME,
+ BrowserThemeProvider::TINT_FRAME);
+ SetThemeTintFromGtk(BrowserThemeProvider::TINT_BACKGROUND_TAB, &frame_color);
+
+ BuildAndSetFrameColor(
+ &frame_style->bg[GTK_STATE_INSENSITIVE],
+ theme_inactive_frame,
+ kDefaultFrameShift,
+ BrowserThemeProvider::COLOR_FRAME_INACTIVE,
+ BrowserThemeProvider::TINT_FRAME_INACTIVE);
+
+ BuildAndSetFrameColor(
+ &frame_color,
+ theme_incognito_frame,
+ GetDefaultTint(BrowserThemeProvider::TINT_FRAME_INCOGNITO),
+ BrowserThemeProvider::COLOR_FRAME_INCOGNITO,
+ BrowserThemeProvider::TINT_FRAME_INCOGNITO);
+
+ BuildAndSetFrameColor(
+ &frame_color,
+ theme_incognito_inactive_frame,
+ GetDefaultTint(BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE),
+ BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE,
+ BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE);
+
+ return frame_color;
+}
+
void GtkThemeProvider::LoadDefaultValues() {
focus_ring_color_ = SkColorSetARGB(255, 229, 151, 0);
thumb_active_color_ = SkColorSetRGB(244, 244, 244);
@@ -840,16 +866,24 @@ void GtkThemeProvider::SetThemeTintFromGtk(int id, const GdkColor* color) {
tints_[id] = hsl;
}
-void GtkThemeProvider::BuildTintedFrameColor(int color_id, int tint_id) {
- colors_[color_id] = HSLShift(
- GetDefaultColor(BrowserThemeProvider::COLOR_FRAME),
- tints_[tint_id]);
-}
+GdkColor GtkThemeProvider::BuildAndSetFrameColor(const GdkColor* base,
+ const GdkColor* gtk_base,
+ const color_utils::HSL& tint,
+ int color_id,
+ int tint_id) {
+ GdkColor out_color = *base;
+ if (gtk_base) {
+ // The theme author specified a color to use, use it without modification.
+ out_color = *gtk_base;
+ } else {
+ // Tint the basic color since this is a heuristic color instead of one
+ // specified by the theme author.
+ GdkColorHSLShift(tint, &out_color);
+ }
+ SetThemeColorFromGtk(color_id, &out_color);
+ SetThemeTintFromGtk(tint_id, &out_color);
-void GtkThemeProvider::SetTintToExactColor(int id, const GdkColor* color) {
- color_utils::HSL hsl;
- color_utils::SkColorToHSL(GdkToSkColor(color), &hsl);
- tints_[id] = hsl;
+ return out_color;
}
void GtkThemeProvider::FreePerDisplaySurfaces(
@@ -888,14 +922,18 @@ SkBitmap* GtkThemeProvider::GenerateGtkThemeBitmap(int id) const {
case IDR_THEME_TAB_BACKGROUND_INCOGNITO:
return GenerateTabImage(IDR_THEME_FRAME_INCOGNITO);
case IDR_THEME_FRAME:
- return GenerateFrameImage(BrowserThemeProvider::TINT_FRAME);
+ return GenerateFrameImage(BrowserThemeProvider::COLOR_FRAME,
+ "frame-gradient-color");
case IDR_THEME_FRAME_INACTIVE:
- return GenerateFrameImage(BrowserThemeProvider::TINT_FRAME_INACTIVE);
+ return GenerateFrameImage(BrowserThemeProvider::COLOR_FRAME_INACTIVE,
+ "inactive-frame-gradient-color");
case IDR_THEME_FRAME_INCOGNITO:
- return GenerateFrameImage(BrowserThemeProvider::TINT_FRAME_INCOGNITO);
+ return GenerateFrameImage(BrowserThemeProvider::COLOR_FRAME_INCOGNITO,
+ "incognito-frame-gradient-color");
case IDR_THEME_FRAME_INCOGNITO_INACTIVE: {
return GenerateFrameImage(
- BrowserThemeProvider::TINT_FRAME_INCOGNITO_INACTIVE);
+ BrowserThemeProvider::COLOR_FRAME_INCOGNITO_INACTIVE,
+ "incognito-inactive-frame-gradient-color");
}
// Icons that sit inside the omnibox shouldn't receive TINT_BUTTONS and
// instead should tint based on the foreground text entry color in GTK+
@@ -927,13 +965,42 @@ SkBitmap* GtkThemeProvider::GenerateGtkThemeBitmap(int id) const {
}
}
-SkBitmap* GtkThemeProvider::GenerateFrameImage(int tint_id) const {
- ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- scoped_ptr<SkBitmap> frame(new SkBitmap(*rb.GetBitmapNamed(IDR_THEME_FRAME)));
- TintMap::const_iterator it = tints_.find(tint_id);
- DCHECK(it != tints_.end());
- return new SkBitmap(SkBitmapOperations::CreateHSLShiftedBitmap(*frame,
- it->second));
+SkBitmap* GtkThemeProvider::GenerateFrameImage(
+ int color_id,
+ const char* gradient_name) const {
+ // We use two colors: the main color (passed in) and a lightened version of
+ // that color (which is supposed to match the light gradient at the top of
+ // several GTK+ themes, such as Ambiance, Clearlooks or Bluebird).
+ ColorMap::const_iterator it = colors_.find(color_id);
+ DCHECK(it != colors_.end());
+ SkColor base = it->second;
+
+ gfx::CanvasSkia canvas(kToolbarImageWidth, kToolbarImageHeight, true);
+
+ int gradient_size;
+ const GdkColor* gradient_top_color = NULL;
+ gtk_widget_style_get(GTK_WIDGET(fake_frame_),
+ "frame-gradient-size", &gradient_size,
+ gradient_name, &gradient_top_color,
+ NULL);
+ if (gradient_size) {
+ SkColor lighter = gradient_top_color ? GdkToSkColor(gradient_top_color)
+ : color_utils::HSLShift(base, kGtkFrameShift);
+ SkShader* shader = gfx::CreateGradientShader(
+ 0, gradient_size, lighter, base);
+ SkPaint paint;
+ paint.setStyle(SkPaint::kFill_Style);
+ paint.setAntiAlias(true);
+ paint.setShader(shader);
+ shader->unref();
+
+ canvas.DrawRectInt(0, 0, kToolbarImageWidth, gradient_size, paint);
+ }
+
+ canvas.FillRectInt(base, 0, gradient_size,
+ kToolbarImageWidth,
+ kToolbarImageHeight - gradient_size);
+ return new SkBitmap(canvas.ExtractBitmap());
}
SkBitmap* GtkThemeProvider::GenerateTabImage(int base_id) const {
diff --git a/chrome/browser/gtk/gtk_theme_provider.h b/chrome/browser/gtk/gtk_theme_provider.h
index f31d974..630fdbc 100644
--- a/chrome/browser/gtk/gtk_theme_provider.h
+++ b/chrome/browser/gtk/gtk_theme_provider.h
@@ -84,11 +84,12 @@ class GtkThemeProvider : public BrowserThemeProvider,
// label colors for the IDR resource |id|.
GtkIconSet* GetIconSetForId(int id) const;
- // This method returns averages of the thumb part and of the track colors.
- // Used when rendering scrollbars.
- static void GetScrollbarColors(GdkColor* thumb_active_color,
- GdkColor* thumb_inactive_color,
- GdkColor* track_color);
+ // This method returns the colors webkit will use for the scrollbars. When no
+ // colors are specified by the GTK+ theme, this function averages of the
+ // thumb part and of the track colors.
+ void GetScrollbarColors(GdkColor* thumb_active_color,
+ GdkColor* thumb_inactive_color,
+ GdkColor* track_color);
// Expose the inner label. Only used for testing.
GtkWidget* fake_label() { return fake_label_.get(); }
@@ -162,6 +163,10 @@ class GtkThemeProvider : public BrowserThemeProvider,
// BrowserThemeProvider interface and the colors we send to webkit.
void LoadGtkValues();
+ // Reads in explicit theme frame colors from the ChromeGtkFrame style class
+ // or generates them per our fallback algorithm.
+ GdkColor BuildFrameColors(GtkStyle* frame_style);
+
// Sets the values that we send to webkit to safe defaults.
void LoadDefaultValues();
@@ -173,8 +178,15 @@ class GtkThemeProvider : public BrowserThemeProvider,
// Sets the underlying theme colors/tints from a GTK color.
void SetThemeColorFromGtk(int id, const GdkColor* color);
void SetThemeTintFromGtk(int id, const GdkColor* color);
- void BuildTintedFrameColor(int color_id, int tint_id);
- void SetTintToExactColor(int id, const GdkColor* color);
+
+ // Creates and returns a frame color, either using |gtk_base| verbatim if
+ // non-NULL, or tinting |base| with |tint|. Also sets |color_id| and
+ // |tint_id| to the returned color.
+ GdkColor BuildAndSetFrameColor(const GdkColor* base,
+ const GdkColor* gtk_base,
+ const color_utils::HSL& tint,
+ int color_id,
+ int tint_id);
// Split out from FreePlatformCaches so it can be called in our destructor;
// FreePlatformCaches() is called from the BrowserThemeProvider's destructor,
@@ -188,9 +200,12 @@ class GtkThemeProvider : public BrowserThemeProvider,
// Lazily generates each bitmap used in the gtk theme.
SkBitmap* GenerateGtkThemeBitmap(int id) const;
- // Tints IDR_THEME_FRAME based based on |tint_id|. Used during lazy
- // generation of the gtk theme bitmaps.
- SkBitmap* GenerateFrameImage(int tint_id) const;
+ // Creates a GTK+ version of IDR_THEME_FRAME. Instead of tinting, this
+ // creates a theme configurable gradient ending with |color_id| at the
+ // bottom, and |gradient_name| at the top if that color is specified in the
+ // theme.
+ SkBitmap* GenerateFrameImage(int color_id,
+ const char* gradient_name) const;
// Takes the base frame image |base_id| and tints it with |tint_id|.
SkBitmap* GenerateTabImage(int base_id) const;
diff --git a/chrome/browser/gtk/gtk_util.cc b/chrome/browser/gtk/gtk_util.cc
index 74b7423..e07d990 100644
--- a/chrome/browser/gtk/gtk_util.cc
+++ b/chrome/browser/gtk/gtk_util.cc
@@ -22,11 +22,15 @@
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/autocomplete/autocomplete.h"
+#include "chrome/browser/autocomplete/autocomplete_classifier.h"
#include "chrome/browser/autocomplete/autocomplete_match.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/gtk/cairo_cached_surface.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
+#include "chrome/browser/profile.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
+#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/common/renderer_preferences.h"
#include "gfx/gtk_util.h"
#include "googleurl/src/gurl.h"
@@ -35,10 +39,13 @@
#include "third_party/skia/include/core/SkColor.h"
#if defined(OS_CHROMEOS)
+#include "chrome/browser/chromeos/frame/browser_view.h"
#include "chrome/browser/chromeos/native_dialog_window.h"
#include "chrome/browser/chromeos/options/options_window_view.h"
#include "views/window/window.h"
-#endif // defined(OS_CHROMEOS)
+#else
+#include "chrome/browser/gtk/browser_window_gtk.h"
+#endif
using WebKit::WebDragOperationsMask;
using WebKit::WebDragOperation;
@@ -171,6 +178,40 @@ gboolean PaintNoBackground(GtkWidget* widget,
return TRUE;
}
+#if defined(OS_CHROMEOS)
+
+TabContents* GetBrowserWindowSelectedTabContents(BrowserWindow* window) {
+ chromeos::BrowserView* browser_view = static_cast<chromeos::BrowserView*>(
+ window);
+ return browser_view->GetSelectedTabContents();
+}
+
+GtkWidget* GetBrowserWindowFocusedWidget(BrowserWindow* window) {
+ gfx::NativeView widget = gtk_window_get_focus(window->GetNativeHandle());
+
+ if (widget == NULL) {
+ chromeos::BrowserView* browser_view = static_cast<chromeos::BrowserView*>(
+ window);
+ widget = browser_view->saved_focused_widget();
+ }
+
+ return widget;
+}
+
+#else
+
+TabContents* GetBrowserWindowSelectedTabContents(BrowserWindow* window) {
+ BrowserWindowGtk* browser_window = static_cast<BrowserWindowGtk*>(
+ window);
+ return browser_window->browser()->GetSelectedTabContents();
+}
+
+GtkWidget* GetBrowserWindowFocusedWidget(BrowserWindow* window) {
+ return gtk_window_get_focus(window->GetNativeHandle());
+}
+
+#endif
+
} // namespace
namespace event_utils {
@@ -774,6 +815,7 @@ void DrawTextEntryBackground(GtkWidget* offscreen_entry,
rec->width - 2 * xborder,
rec->height - 2 * yborder);
+ gtk_style_detach(our_style);
g_object_unref(our_style);
}
@@ -959,22 +1001,14 @@ bool URLFromPrimarySelection(Profile* profile, GURL* url) {
// Use autocomplete to clean up the text, going so far as to turn it into
// a search query if necessary.
- AutocompleteController controller(profile);
- controller.Start(UTF8ToWide(selection_text),
- std::wstring(), // desired_tld
- true, // prevent_inline_autocomplete
- false, // prefer_keyword
- true); // synchronous_only
+ AutocompleteMatch match;
+ profile->GetAutocompleteClassifier()->Classify(UTF8ToWide(selection_text),
+ std::wstring(), false, &match, NULL);
g_free(selection_text);
- const AutocompleteResult& result = controller.result();
- AutocompleteResult::const_iterator it = result.default_match();
- if (it == result.end())
- return false;
-
- if (!it->destination_url.is_valid())
+ if (!match.destination_url.is_valid())
return false;
- *url = it->destination_url;
+ *url = match.destination_url;
return true;
}
@@ -1131,6 +1165,7 @@ gfx::Rect GetDialogBounds(GtkWidget* dialog) {
return gfx::Rect(x, y, width, height);
}
+
#endif
string16 GetStockPreferencesMenuLabel() {
@@ -1215,4 +1250,38 @@ void ApplyMessageDialogQuirks(GtkWidget* dialog) {
}
}
+// Performs Cut/Copy/Paste operation on the |window|.
+// If the current render view is focused, then just call the specified |method|
+// against the current render view host, otherwise emit the specified |signal|
+// against the focused widget.
+// TODO(suzhe): This approach does not work for plugins.
+void DoCutCopyPaste(BrowserWindow* window,
+ void (RenderViewHost::*method)(),
+ const char* signal) {
+ GtkWidget* widget = GetBrowserWindowFocusedWidget(window);
+ if (widget == NULL)
+ return; // Do nothing if no focused widget.
+
+ TabContents* current_tab = GetBrowserWindowSelectedTabContents(window);
+ if (current_tab && widget == current_tab->GetContentNativeView()) {
+ (current_tab->render_view_host()->*method)();
+ } else {
+ guint id;
+ if ((id = g_signal_lookup(signal, G_OBJECT_TYPE(widget))) != 0)
+ g_signal_emit(widget, id, 0);
+ }
+}
+
+void DoCut(BrowserWindow* window) {
+ DoCutCopyPaste(window, &RenderViewHost::Cut, "cut-clipboard");
+}
+
+void DoCopy(BrowserWindow* window) {
+ DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard");
+}
+
+void DoPaste(BrowserWindow* window) {
+ DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard");
+}
+
} // namespace gtk_util
diff --git a/chrome/browser/gtk/gtk_util.h b/chrome/browser/gtk/gtk_util.h
index 77beb1f..c8c3c4f 100644
--- a/chrome/browser/gtk/gtk_util.h
+++ b/chrome/browser/gtk/gtk_util.h
@@ -21,6 +21,7 @@ typedef struct _cairo cairo_t;
typedef struct _GdkColor GdkColor;
typedef struct _GtkWidget GtkWidget;
+class BrowserWindow;
class GtkThemeProvider;
class GURL;
class Profile;
@@ -374,6 +375,11 @@ WebKit::WebDragOperationsMask GdkDragActionToWebDragOp(GdkDragAction action);
// gtk_message_dialog_new.
void ApplyMessageDialogQuirks(GtkWidget* dialog);
+// Performs Cut/Copy/Paste operation on the |window|.
+void DoCut(BrowserWindow* window);
+void DoCopy(BrowserWindow* window);
+void DoPaste(BrowserWindow* window);
+
} // namespace gtk_util
#endif // CHROME_BROWSER_GTK_GTK_UTIL_H_
diff --git a/chrome/browser/gtk/hover_controller_gtk.h b/chrome/browser/gtk/hover_controller_gtk.h
index 4806e34..5504720 100644
--- a/chrome/browser/gtk/hover_controller_gtk.h
+++ b/chrome/browser/gtk/hover_controller_gtk.h
@@ -8,6 +8,7 @@
#include <gtk/gtk.h>
+#include "app/animation_delegate.h"
#include "app/gtk_signal.h"
#include "app/gtk_signal_registrar.h"
#include "app/slide_animation.h"
diff --git a/chrome/browser/gtk/html_dialog_gtk.cc b/chrome/browser/gtk/html_dialog_gtk.cc
index 3c9d1fb..2568e83 100644
--- a/chrome/browser/gtk/html_dialog_gtk.cc
+++ b/chrome/browser/gtk/html_dialog_gtk.cc
@@ -7,12 +7,12 @@
#include <gtk/gtk.h>
#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/dom_ui/html_dialog_ui.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/tab_contents_container_gtk.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/native_web_keyboard_event.h"
#include "ipc/ipc_message.h"
diff --git a/chrome/browser/gtk/hung_renderer_dialog_gtk.cc b/chrome/browser/gtk/hung_renderer_dialog_gtk.cc
index 5cdca15..5dbed52 100644
--- a/chrome/browser/gtk/hung_renderer_dialog_gtk.cc
+++ b/chrome/browser/gtk/hung_renderer_dialog_gtk.cc
@@ -6,6 +6,7 @@
#include <gtk/gtk.h>
+#include "app/gtk_signal.h"
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
#include "base/process_util.h"
@@ -42,11 +43,7 @@ class HungRendererDialogGtk {
// Create the gtk dialog and add the widgets.
void Init();
- static void OnDialogResponseThunk(GtkDialog* dialog, gint response_id,
- HungRendererDialogGtk* dialog_gtk) {
- dialog_gtk->OnDialogResponse(response_id);
- }
- void OnDialogResponse(gint response_id);
+ CHROMEGTK_CALLBACK_1(HungRendererDialogGtk, void, OnDialogResponse, gint);
GtkDialog* dialog_;
GtkListStore* model_;
@@ -78,8 +75,8 @@ void HungRendererDialogGtk::Init() {
GTK_RESPONSE_OK,
NULL));
gtk_dialog_set_default_response(dialog_, GTK_RESPONSE_OK);
- g_signal_connect(dialog_, "response", G_CALLBACK(OnDialogResponseThunk),
- this);
+ g_signal_connect(dialog_, "response",
+ G_CALLBACK(OnDialogResponseThunk), this);
// We have an hbox with the frozen icon on the left. On the right,
// we have a vbox with the unresponsive text on top and a table of
@@ -184,7 +181,8 @@ void HungRendererDialogGtk::EndForTabContents(TabContents* contents) {
// When the user clicks a button on the dialog or closes the dialog, this
// callback is called.
-void HungRendererDialogGtk::OnDialogResponse(gint response_id) {
+void HungRendererDialogGtk::OnDialogResponse(GtkWidget* widget,
+ gint response_id) {
DCHECK(g_instance == this);
switch (response_id) {
case kKillPagesButtonResponse:
diff --git a/chrome/browser/gtk/infobar_arrow_model.h b/chrome/browser/gtk/infobar_arrow_model.h
index 369e586..721f32b 100644
--- a/chrome/browser/gtk/infobar_arrow_model.h
+++ b/chrome/browser/gtk/infobar_arrow_model.h
@@ -7,6 +7,7 @@
#include <gtk/gtk.h>
+#include "app/animation_delegate.h"
#include "app/slide_animation.h"
#include "third_party/skia/include/core/SkPaint.h"
diff --git a/chrome/browser/gtk/infobar_gtk.h b/chrome/browser/gtk/infobar_gtk.h
index 4293ea8..d0dd542 100644
--- a/chrome/browser/gtk/infobar_gtk.h
+++ b/chrome/browser/gtk/infobar_gtk.h
@@ -7,7 +7,6 @@
#pragma once
#include "app/gtk_signal.h"
-#include "app/slide_animation.h"
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/gtk/infobar_arrow_model.h"
diff --git a/chrome/browser/gtk/instant_confirm_dialog_gtk.cc b/chrome/browser/gtk/instant_confirm_dialog_gtk.cc
index c313cec..ac4529a 100644
--- a/chrome/browser/gtk/instant_confirm_dialog_gtk.cc
+++ b/chrome/browser/gtk/instant_confirm_dialog_gtk.cc
@@ -10,10 +10,9 @@
#include "chrome/browser/gtk/gtk_chrome_link_button.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/instant/instant_confirm_dialog.h"
-#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/show_options_url.h"
-#include "chrome/common/pref_names.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
@@ -66,13 +65,8 @@ InstantConfirmDialogGtk::~InstantConfirmDialogGtk() {
void InstantConfirmDialogGtk::OnDialogResponse(GtkWidget* dialog,
int response) {
- if (response == GTK_RESPONSE_ACCEPT) {
- PrefService* service = profile_->GetPrefs();
- if (service) {
- service->SetBoolean(prefs::kInstantEnabled, true);
- service->SetBoolean(prefs::kInstantConfirmDialogShown, true);
- }
- }
+ if (response == GTK_RESPONSE_ACCEPT)
+ InstantController::Enable(profile_);
delete this;
}
diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc
index b207665..65b9545 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.cc
+++ b/chrome/browser/gtk/location_bar_view_gtk.cc
@@ -19,7 +19,6 @@
#include "chrome/browser/alternate_nav_url_fetcher.h"
#include "chrome/browser/autocomplete/autocomplete_edit_view_gtk.h"
#include "chrome/browser/autocomplete/autocomplete_popup_model.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/content_setting_bubble_model.h"
@@ -45,6 +44,7 @@
#include "chrome/browser/search_engines/template_url.h"
#include "chrome/browser/search_engines/template_url_model.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_action.h"
#include "chrome/common/extensions/extension_resource.h"
@@ -548,6 +548,10 @@ void LocationBarViewGtk::OnChanged() {
SetSuggestedText(suggested_text);
}
+void LocationBarViewGtk::OnSelectionBoundsChanged() {
+ NOTIMPLEMENTED();
+}
+
void LocationBarViewGtk::CreateStarButton() {
star_image_ = gtk_image_new();
diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h
index 0759549..77e4134 100644
--- a/chrome/browser/gtk/location_bar_view_gtk.h
+++ b/chrome/browser/gtk/location_bar_view_gtk.h
@@ -61,6 +61,9 @@ class LocationBarViewGtk : public AutocompleteEditController,
// Returns the widget the page info bubble should point to.
GtkWidget* location_icon_widget() const { return location_icon_image_; }
+ // Returns the widget the extension installed bubble should point to.
+ GtkWidget* location_entry_widget() const { return entry_box_; }
+
// Returns the current TabContents.
TabContents* GetTabContents() const;
@@ -100,6 +103,7 @@ class LocationBarViewGtk : public AutocompleteEditController,
PageTransition::Type transition,
const GURL& alternate_nav_url);
virtual void OnChanged();
+ virtual void OnSelectionBoundsChanged();
virtual void OnKillFocus();
virtual void OnSetFocus();
virtual void OnInputInProgress(bool in_progress);
diff --git a/chrome/browser/gtk/menu_gtk.cc b/chrome/browser/gtk/menu_gtk.cc
index 86a1ba1..5823f25 100644
--- a/chrome/browser/gtk/menu_gtk.cc
+++ b/chrome/browser/gtk/menu_gtk.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/gtk/gtk_util.h"
#include "gfx/gtk_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "webkit/glue/window_open_disposition.h"
bool MenuGtk::block_activation_ = false;
@@ -693,7 +694,16 @@ void MenuGtk::ExecuteCommand(menus::MenuModel* model, int id) {
if (delegate_)
delegate_->CommandWillBeExecuted();
- model->ActivatedAt(id);
+ GdkEvent* event = gtk_get_current_event();
+ if (event && event->type == GDK_BUTTON_RELEASE) {
+ model->ActivatedAtWithDisposition(
+ id, event_utils::DispositionFromEventFlags(event->button.state));
+ } else {
+ model->ActivatedAt(id);
+ }
+
+ if (event)
+ gdk_event_free(event);
}
void MenuGtk::OnMenuShow(GtkWidget* widget) {
diff --git a/chrome/browser/gtk/meta_frames.cc b/chrome/browser/gtk/meta_frames.cc
deleted file mode 100644
index e95ac87..0000000
--- a/chrome/browser/gtk/meta_frames.cc
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright (c) 2010 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/gtk/meta_frames.h"
-
-G_BEGIN_DECLS
-
-G_DEFINE_TYPE(MetaFrames, meta_frames, GTK_TYPE_WINDOW)
-
-static void meta_frames_class_init(MetaFramesClass* frames_class) {
- // Noop since we don't declare anything.
-}
-
-static void meta_frames_init(MetaFrames* button) {
-}
-
-GtkWidget* meta_frames_new(void) {
- GtkWindow* window =
- GTK_WINDOW(g_object_new(meta_frames_get_type(), NULL));
- window->type = GTK_WINDOW_TOPLEVEL;
- return GTK_WIDGET(window);
-}
-
-G_END_DECLS
diff --git a/chrome/browser/gtk/meta_frames.h b/chrome/browser/gtk/meta_frames.h
deleted file mode 100644
index bc8a493..0000000
--- a/chrome/browser/gtk/meta_frames.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2010 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_GTK_META_FRAMES_H_
-#define CHROME_BROWSER_GTK_META_FRAMES_H_
-#pragma once
-
-#include <gdk/gdk.h>
-#include <gtk/gtkwindow.h>
-
-G_BEGIN_DECLS
-
-// For the sake of gtk+ theme integration, we define a class called
-// "MetaFrames," which is the name of a gobject class in the metacity window
-// manager. To actually get at those values, we need to have an object whose
-// gobject class name string matches the definitions in the gtkrc
-// file. MetaFrames derives from GtkWindow.
-//
-// TODO(erg): http://crbug.com/35317 for getting rid of this hack class, as we
-// should be able to use gtk_rc_get_style_by_path() but can't?
-
-typedef struct _MetaFrames MetaFrames;
-typedef struct _MetaFramesClass MetaFramesClass;
-
-struct _MetaFrames {
- GtkWindow window;
-};
-
-struct _MetaFramesClass {
- GtkWindowClass parent_class;
-};
-
-// Creates a GtkWindow object with the class name "MetaFrames".
-GtkWidget* meta_frames_new();
-
-G_END_DECLS
-
-#endif // CHROME_BROWSER_GTK_META_FRAMES_H_
diff --git a/chrome/browser/gtk/notifications/balloon_view_gtk.h b/chrome/browser/gtk/notifications/balloon_view_gtk.h
index 652a610..dce5869 100644
--- a/chrome/browser/gtk/notifications/balloon_view_gtk.h
+++ b/chrome/browser/gtk/notifications/balloon_view_gtk.h
@@ -8,7 +8,7 @@
#define CHROME_BROWSER_GTK_NOTIFICATIONS_BALLOON_VIEW_GTK_H_
#pragma once
-#include "app/animation.h"
+#include "app/animation_delegate.h"
#include "app/gtk_signal.h"
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
diff --git a/chrome/browser/gtk/options/advanced_contents_gtk.cc b/chrome/browser/gtk/options/advanced_contents_gtk.cc
index f98490e..6ea7a49 100644
--- a/chrome/browser/gtk/options/advanced_contents_gtk.cc
+++ b/chrome/browser/gtk/options/advanced_contents_gtk.cc
@@ -25,6 +25,7 @@
#include "chrome/browser/download/download_manager.h"
#include "chrome/browser/download/download_prefs.h"
#include "chrome/browser/fonts_languages_window.h"
+#include "chrome/browser/google/google_util.h"
#include "chrome/browser/gtk/accessible_widget_helper_gtk.h"
#include "chrome/browser/gtk/clear_browsing_data_dialog_gtk.h"
#include "chrome/browser/gtk/gtk_chrome_link_button.h"
@@ -43,6 +44,7 @@
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/process_watcher.h"
+#include "chrome/common/url_constants.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -882,9 +884,9 @@ void PrivacySection::OnClearBrowsingDataButtonClicked(GtkButton* widget,
// static
void PrivacySection::OnLearnMoreLinkClicked(GtkButton *button,
PrivacySection* privacy_section) {
- browser::ShowOptionsURL(
- privacy_section->profile(),
- GURL(l10n_util::GetStringUTF8(IDS_LEARN_MORE_PRIVACY_URL)));
+ GURL url = google_util::AppendGoogleLocaleParam(
+ GURL(chrome::kPrivacyLearnMoreURL));
+ browser::ShowOptionsURL(privacy_section->profile(), url);
}
// static
diff --git a/chrome/browser/gtk/options/content_filter_page_gtk.cc b/chrome/browser/gtk/options/content_filter_page_gtk.cc
index 6645a22..93c804e 100644
--- a/chrome/browser/gtk/options/content_filter_page_gtk.cc
+++ b/chrome/browser/gtk/options/content_filter_page_gtk.cc
@@ -6,12 +6,11 @@
#include "app/l10n_util.h"
#include "base/command_line.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/geolocation/geolocation_content_settings_map.h"
#include "chrome/browser/geolocation/geolocation_exceptions_table_model.h"
-#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/plugin_exceptions_table_model.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/gtk/browser_window_gtk.h"
#include "chrome/browser/gtk/gtk_chrome_link_button.h"
#include "chrome/browser/gtk/gtk_util.h"
@@ -20,8 +19,8 @@
#include "chrome/browser/notifications/desktop_notification_service.h"
#include "chrome/browser/notifications/notification_exceptions_table_model.h"
#include "chrome/browser/show_options_url.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -30,7 +29,8 @@ ContentFilterPageGtk::ContentFilterPageGtk(Profile* profile,
ContentSettingsType content_type)
: OptionsPageBase(profile),
content_type_(content_type),
- ask_radio_(NULL) {
+ ask_radio_(NULL),
+ ignore_toggle_(false) {
static const int kTitleIDs[] = {
0, // This dialog isn't used for cookies.
IDS_IMAGES_SETTING_LABEL,
@@ -83,10 +83,17 @@ GtkWidget* ContentFilterPageGtk::InitGroup() {
};
COMPILE_ASSERT(arraysize(kAskIDs) == CONTENT_SETTINGS_NUM_TYPES,
kAskIDs_IncorrectSize);
- if (kAskIDs[content_type_]) {
+ int askID = kAskIDs[content_type_];
+ if (content_type_ == CONTENT_SETTINGS_TYPE_PLUGINS &&
+ !CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableClickToPlay)) {
+ askID = 0;
+ }
+
+ if (askID) {
ask_radio_ = gtk_radio_button_new_with_label_from_widget(
GTK_RADIO_BUTTON(allow_radio_),
- l10n_util::GetStringUTF8(kAskIDs[content_type_]).c_str());
+ l10n_util::GetStringUTF8(askID).c_str());
gtk_box_pack_start(GTK_BOX(vbox), ask_radio_, FALSE, FALSE, 0);
}
@@ -106,31 +113,12 @@ GtkWidget* ContentFilterPageGtk::InitGroup() {
l10n_util::GetStringUTF8(kBlockIDs[content_type_]).c_str());
gtk_box_pack_start(GTK_BOX(vbox), block_radio_, FALSE, FALSE, 0);
- ContentSetting default_setting;
- if (content_type_ == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
- default_setting = profile()->GetGeolocationContentSettingsMap()->
- GetDefaultContentSetting();
- } else if (content_type_ == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
- default_setting = profile()->GetDesktopNotificationService()->
- GetDefaultContentSetting();
- } else {
- default_setting = profile()->GetHostContentSettingsMap()->
- GetDefaultContentSetting(content_type_);
- }
- // Now that these have been added to the view hierarchy, it's safe to call
- // SetChecked() on them.
- if (default_setting == CONTENT_SETTING_ALLOW) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(allow_radio_), TRUE);
- } else if (default_setting == CONTENT_SETTING_ASK) {
- DCHECK(ask_radio_);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ask_radio_), TRUE);
- } else {
- DCHECK(default_setting == CONTENT_SETTING_BLOCK);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(block_radio_), TRUE);
- }
+ exceptions_button_ = gtk_button_new_with_label(
+ l10n_util::GetStringUTF8(IDS_COOKIES_EXCEPTIONS_BUTTON).c_str());
+ GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), exceptions_button_, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
- // Now that we've set the default value, we can connect to the radio button's
- // toggled signal.
g_signal_connect(G_OBJECT(allow_radio_), "toggled",
G_CALLBACK(OnAllowToggledThunk), this);
if (ask_radio_) {
@@ -140,15 +128,9 @@ GtkWidget* ContentFilterPageGtk::InitGroup() {
g_signal_connect(G_OBJECT(block_radio_), "toggled",
G_CALLBACK(OnAllowToggledThunk), this);
- GtkWidget* exceptions_button = gtk_button_new_with_label(
- l10n_util::GetStringUTF8(IDS_COOKIES_EXCEPTIONS_BUTTON).c_str());
- g_signal_connect(G_OBJECT(exceptions_button), "clicked",
+ g_signal_connect(G_OBJECT(exceptions_button_), "clicked",
G_CALLBACK(OnExceptionsClickedThunk), this);
- GtkWidget* hbox = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start(GTK_BOX(hbox), exceptions_button, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
-
// Add the "Disable individual plug-ins..." link on the plug-ins page.
if (content_type_ == CONTENT_SETTINGS_TYPE_PLUGINS) {
GtkWidget* plugins_page_link = gtk_chrome_link_button_new(
@@ -161,18 +143,75 @@ GtkWidget* ContentFilterPageGtk::InitGroup() {
gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
}
+ // Now that the buttons have been added to the view hierarchy, it's safe to
+ // call SetChecked() on them. So Update the Buttons.
+ ignore_toggle_ = true;
+ UpdateButtonsState();
+ ignore_toggle_ = false;
+
+ // Register for CONTENT_SETTINGS_CHANGED notifications to update the UI
+ // aften content settings change.
+ registrar_.Add(this, NotificationType::CONTENT_SETTINGS_CHANGED,
+ NotificationService::AllSources());
+
return vbox;
}
+void ContentFilterPageGtk::UpdateButtonsState() {
+ // Get default_setting.
+ ContentSetting default_setting;
+ if (content_type_ == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
+ default_setting = profile()->GetGeolocationContentSettingsMap()->
+ GetDefaultContentSetting();
+ } else if (content_type_ == CONTENT_SETTINGS_TYPE_NOTIFICATIONS) {
+ default_setting = profile()->GetDesktopNotificationService()->
+ GetDefaultContentSetting();
+ } else {
+ default_setting = profile()->GetHostContentSettingsMap()->
+ GetDefaultContentSetting(content_type_);
+ }
+ // Set UI state.
+ if (default_setting == CONTENT_SETTING_ALLOW) {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(allow_radio_), TRUE);
+ } else if (default_setting == CONTENT_SETTING_ASK) {
+ DCHECK(ask_radio_);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ask_radio_), TRUE);
+ } else {
+ DCHECK(default_setting == CONTENT_SETTING_BLOCK);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(block_radio_), TRUE);
+ }
+
+ // Disable the UI if the default content setting is managed.
+ bool sensitive = !profile()->GetHostContentSettingsMap()->
+ IsDefaultContentSettingManaged(content_type_);
+ gtk_widget_set_sensitive(allow_radio_, sensitive);
+ gtk_widget_set_sensitive(block_radio_, sensitive);
+ if (ask_radio_)
+ gtk_widget_set_sensitive(ask_radio_, sensitive);
+ gtk_widget_set_sensitive(exceptions_button_, sensitive);
+}
+
void ContentFilterPageGtk::OnAllowToggled(GtkWidget* toggle_button) {
+ if (ignore_toggle_)
+ return;
+
+ if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button))) {
+ // When selecting a radio button, we get two signals (one for the old radio
+ // being toggled off, one for the new one being toggled on.) Ignore the
+ // signal for toggling off the old button.
+ return;
+ }
+
DCHECK((toggle_button == allow_radio_) ||
(toggle_button == ask_radio_) ||
(toggle_button == block_radio_));
+
ContentSetting default_setting =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(allow_radio_)) ?
CONTENT_SETTING_ALLOW :
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(block_radio_)) ?
CONTENT_SETTING_BLOCK : CONTENT_SETTING_ASK;
+
DCHECK(ask_radio_ || default_setting != CONTENT_SETTING_ASK);
if (content_type_ == CONTENT_SETTINGS_TYPE_GEOLOCATION) {
profile()->GetGeolocationContentSettingsMap()->SetDefaultContentSetting(
@@ -229,3 +268,25 @@ void ContentFilterPageGtk::OnExceptionsClicked(GtkWidget* button) {
void ContentFilterPageGtk::OnPluginsPageLinkClicked(GtkWidget* button) {
browser::ShowOptionsURL(profile(), GURL(chrome::kChromeUIPluginsURL));
}
+
+void ContentFilterPageGtk::Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+
+ if (type == NotificationType::CONTENT_SETTINGS_CHANGED) {
+ NotifyContentSettingsChanged(
+ Details<HostContentSettingsMap::ContentSettingsDetails>(details).ptr());
+ } else {
+ OptionsPageBase::Observe(type, source, details);
+ }
+}
+
+void ContentFilterPageGtk::NotifyContentSettingsChanged(
+ const HostContentSettingsMap::ContentSettingsDetails *details) {
+ if (details->type() == CONTENT_SETTINGS_TYPE_DEFAULT ||
+ details->type() == content_type_) {
+ ignore_toggle_ = true;
+ UpdateButtonsState();
+ ignore_toggle_ = false;
+ }
+}
diff --git a/chrome/browser/gtk/options/content_filter_page_gtk.h b/chrome/browser/gtk/options/content_filter_page_gtk.h
index 614178e..e3c2d6a 100644
--- a/chrome/browser/gtk/options/content_filter_page_gtk.h
+++ b/chrome/browser/gtk/options/content_filter_page_gtk.h
@@ -10,7 +10,10 @@
#include "app/gtk_signal.h"
#include "chrome/browser/options_page_base.h"
+#include "chrome/browser/host_content_settings_map.h"
+#include "chrome/common/content_settings.h"
#include "chrome/common/content_settings_types.h"
+#include "chrome/common/notification_registrar.h"
// A page in the content settings window. Used for everything but the Cookies
// page (which has a much more complex dialog). A |content_type| is passed into
@@ -24,7 +27,19 @@ class ContentFilterPageGtk : public OptionsPageBase {
return page_;
}
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details);
+
private:
+ // This method is called during initialization to set the initial state of the
+ // buttons and called after a default content setting change (either value
+ // change or "is managed" state).
+ virtual void UpdateButtonsState();
+
+ virtual void NotifyContentSettingsChanged(
+ const HostContentSettingsMap::ContentSettingsDetails *details);
+
// Builds the content of the dialog.
GtkWidget* InitGroup();
@@ -41,6 +56,14 @@ class ContentFilterPageGtk : public OptionsPageBase {
GtkWidget* ask_radio_;
GtkWidget* block_radio_;
+ GtkWidget* exceptions_button_;
+
+ NotificationRegistrar registrar_;
+
+ // If state of the UI is not changed by a user-action we need to ignore
+ // "toggled" events.
+ bool ignore_toggle_;
+
DISALLOW_COPY_AND_ASSIGN(ContentFilterPageGtk);
};
diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc
index c75028a..5cfe3b7 100644
--- a/chrome/browser/gtk/options/content_page_gtk.cc
+++ b/chrome/browser/gtk/options/content_page_gtk.cc
@@ -9,9 +9,6 @@
#include "app/l10n_util.h"
#include "base/command_line.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_list.h"
-#include "chrome/browser/browser_window.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/gtk/gtk_chrome_link_button.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
@@ -22,6 +19,9 @@
#include "chrome/browser/importer/importer_data_types.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/sync/sync_ui_util.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
diff --git a/chrome/browser/gtk/options/content_settings_window_gtk.cc b/chrome/browser/gtk/options/content_settings_window_gtk.cc
index 7b2c9e5..d890a2a 100644
--- a/chrome/browser/gtk/options/content_settings_window_gtk.cc
+++ b/chrome/browser/gtk/options/content_settings_window_gtk.cc
@@ -9,8 +9,6 @@
#include "app/l10n_util.h"
#include "base/command_line.h"
#include "base/message_loop.h"
-#include "chrome/browser/browser.h"
-#include "chrome/browser/browser_list.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/gtk/accessible_widget_helper_gtk.h"
#include "chrome/browser/gtk/browser_window_gtk.h"
@@ -18,6 +16,8 @@
#include "chrome/browser/gtk/gtk_tree.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/content_settings_types.h"
#include "chrome/common/notification_service.h"
diff --git a/chrome/browser/gtk/options/cookie_filter_page_gtk.cc b/chrome/browser/gtk/options/cookie_filter_page_gtk.cc
index 9b63262..66eac73 100644
--- a/chrome/browser/gtk/options/cookie_filter_page_gtk.cc
+++ b/chrome/browser/gtk/options/cookie_filter_page_gtk.cc
@@ -5,8 +5,8 @@
#include "chrome/browser/gtk/options/cookie_filter_page_gtk.h"
#include "app/l10n_util.h"
+#include "base/auto_reset.h"
#include "base/command_line.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/browsing_data_local_storage_helper.h"
#include "chrome/browser/gtk/browser_window_gtk.h"
#include "chrome/browser/gtk/gtk_chrome_link_button.h"
@@ -16,6 +16,7 @@
#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/show_options_url.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/pref_names.h"
#include "grit/generated_resources.h"
@@ -34,32 +35,40 @@ GtkWidget* WrapInHBox(GtkWidget* widget) {
CookieFilterPageGtk::CookieFilterPageGtk(Profile* profile)
: OptionsPageBase(profile),
- initializing_(true) {
+ ignore_toggle_(false) {
+ // The pref members must be initialized first since the pref values are read
+ // afterwards when we initialize the cookie storing group.
+ clear_site_data_on_exit_.Init(prefs::kClearSiteDataOnExit,
+ profile->GetPrefs(), this);
+
+ block_third_party_cookies_.Init(prefs::kBlockThirdPartyCookies,
+ profile->GetPrefs(), this);
+
+ managed_default_cookies_setting_.Init(prefs::kManagedDefaultCookiesSetting,
+ profile->GetPrefs(), this);
+
GtkWidget* title_label = gtk_util::CreateBoldLabel(
l10n_util::GetStringUTF8(IDS_MODIFY_COOKIE_STORING_LABEL));
page_ = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
gtk_box_pack_start(GTK_BOX(page_), title_label, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(page_), InitCookieStoringGroup());
-
- clear_site_data_on_exit_.Init(prefs::kClearSiteDataOnExit,
- profile->GetPrefs(), NULL);
-
- // Load initial values
- NotifyPrefChanged(NULL);
}
CookieFilterPageGtk::~CookieFilterPageGtk() {
}
void CookieFilterPageGtk::NotifyPrefChanged(const std::string* pref_name) {
- initializing_ = true;
+ AutoReset<bool> toggle_guard(&ignore_toggle_, true);
if (!pref_name || *pref_name == prefs::kClearSiteDataOnExit) {
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(clear_on_close_check_),
- clear_site_data_on_exit_.GetValue());
+ UpdateUiState();
+ }
+ if (!pref_name || *pref_name == prefs::kManagedDefaultCookiesSetting) {
+ UpdateUiState();
+ }
+ if (!pref_name || *pref_name == prefs::kBlockThirdPartyCookies) {
+ UpdateUiState();
}
-
- initializing_ = false;
}
void CookieFilterPageGtk::HighlightGroup(OptionsGroup highlight_group) {
@@ -82,36 +91,15 @@ GtkWidget* CookieFilterPageGtk::InitCookieStoringGroup() {
G_CALLBACK(OnCookiesAllowToggledThunk), this);
gtk_box_pack_start(GTK_BOX(vbox), block_radio_, FALSE, FALSE, 0);
- // Set up the current value for the button.
- const HostContentSettingsMap* settings_map =
- profile()->GetHostContentSettingsMap();
- ContentSetting default_setting =
- settings_map->GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES);
- // Now that these have been added to the view hierarchy, it's safe to call
- // SetChecked() on them.
- GtkWidget* radio_button = NULL;
- if (default_setting == CONTENT_SETTING_ALLOW) {
- radio_button = allow_radio_;
- } else if (default_setting == CONTENT_SETTING_BLOCK) {
- radio_button = block_radio_;
- } else {
- DCHECK(default_setting == CONTENT_SETTING_ASK);
- radio_button = ask_every_time_radio_;
- }
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_button), TRUE);
-
- // Exception button.
- GtkWidget* exceptions_button = gtk_button_new_with_label(
+ exceptions_button_ = gtk_button_new_with_label(
l10n_util::GetStringUTF8(IDS_COOKIES_EXCEPTIONS_BUTTON).c_str());
- g_signal_connect(G_OBJECT(exceptions_button), "clicked",
+ g_signal_connect(G_OBJECT(exceptions_button_), "clicked",
G_CALLBACK(OnExceptionsClickedThunk), this);
- gtk_box_pack_start(GTK_BOX(vbox), WrapInHBox(exceptions_button),
+ gtk_box_pack_start(GTK_BOX(vbox), WrapInHBox(exceptions_button_),
FALSE, FALSE, 0);
block_3rdparty_check_ = gtk_check_button_new_with_label(
l10n_util::GetStringUTF8(IDS_COOKIES_BLOCK_3RDPARTY_CHKBOX).c_str());
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(block_3rdparty_check_),
- settings_map->BlockThirdPartyCookies());
g_signal_connect(G_OBJECT(block_3rdparty_check_), "toggled",
G_CALLBACK(OnBlockThirdPartyToggledThunk), this);
gtk_box_pack_start(GTK_BOX(vbox), block_3rdparty_check_, FALSE, FALSE, 0);
@@ -136,11 +124,47 @@ GtkWidget* CookieFilterPageGtk::InitCookieStoringGroup() {
gtk_box_pack_start(GTK_BOX(vbox), WrapInHBox(flash_settings_link),
FALSE, FALSE, 0);
+ ignore_toggle_ = true;
+ UpdateUiState();
+ ignore_toggle_ = false;
+
return vbox;
};
+void CookieFilterPageGtk::UpdateUiState() {
+ // Get default_setting.
+ ContentSetting default_setting;
+ default_setting = profile()->GetHostContentSettingsMap()->
+ GetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES);
+
+ // Set UI state.
+ if (default_setting == CONTENT_SETTING_ALLOW) {
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(allow_radio_), TRUE);
+ } else {
+ DCHECK(default_setting == CONTENT_SETTING_BLOCK);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(block_radio_), TRUE);
+ }
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(clear_on_close_check_),
+ clear_site_data_on_exit_.GetValue());
+ gtk_toggle_button_set_active(
+ GTK_TOGGLE_BUTTON(block_3rdparty_check_),
+ block_third_party_cookies_.GetValue());
+
+ // Disable the UI if the default content setting is managed.
+ gtk_widget_set_sensitive(block_3rdparty_check_,
+ !block_third_party_cookies_.IsManaged());
+ bool sensitive = true;
+ if (profile()->GetHostContentSettingsMap()->IsDefaultContentSettingManaged(
+ CONTENT_SETTINGS_TYPE_COOKIES)) {
+ sensitive = false;
+ }
+ gtk_widget_set_sensitive(allow_radio_, sensitive);
+ gtk_widget_set_sensitive(block_radio_, sensitive);
+ gtk_widget_set_sensitive(exceptions_button_, sensitive);
+}
+
void CookieFilterPageGtk::OnCookiesAllowToggled(GtkWidget* toggle_button) {
- if (initializing_)
+ if (ignore_toggle_)
return;
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button))) {
@@ -153,8 +177,6 @@ void CookieFilterPageGtk::OnCookiesAllowToggled(GtkWidget* toggle_button) {
ContentSetting setting = CONTENT_SETTING_ALLOW;
if (toggle_button == allow_radio_)
setting = CONTENT_SETTING_ALLOW;
- else if (toggle_button == ask_every_time_radio_)
- setting = CONTENT_SETTING_ASK;
else if (toggle_button == block_radio_)
setting = CONTENT_SETTING_BLOCK;
@@ -174,7 +196,7 @@ void CookieFilterPageGtk::OnExceptionsClicked(GtkWidget* button) {
}
void CookieFilterPageGtk::OnBlockThirdPartyToggled(GtkWidget* toggle_button) {
- if (initializing_)
+ if (ignore_toggle_)
return;
HostContentSettingsMap* settings_map = profile()->GetHostContentSettingsMap();
@@ -183,7 +205,7 @@ void CookieFilterPageGtk::OnBlockThirdPartyToggled(GtkWidget* toggle_button) {
}
void CookieFilterPageGtk::OnClearOnCloseToggled(GtkWidget* toggle_button) {
- if (initializing_)
+ if (ignore_toggle_)
return;
clear_site_data_on_exit_.SetValue(
diff --git a/chrome/browser/gtk/options/cookie_filter_page_gtk.h b/chrome/browser/gtk/options/cookie_filter_page_gtk.h
index 2825d0e..37c0ce3 100644
--- a/chrome/browser/gtk/options/cookie_filter_page_gtk.h
+++ b/chrome/browser/gtk/options/cookie_filter_page_gtk.h
@@ -11,6 +11,7 @@
#include <string>
#include "app/gtk_signal.h"
+#include "chrome/browser/host_content_settings_map.h"
#include "chrome/browser/options_page_base.h"
#include "chrome/browser/prefs/pref_member.h"
@@ -29,6 +30,9 @@ class CookieFilterPageGtk : public OptionsPageBase {
}
private:
+ // Updates the UI state.
+ virtual void UpdateUiState();
+
// Overridden from OptionsPageBase
virtual void NotifyPrefChanged(const std::string* pref_name);
virtual void HighlightGroup(OptionsGroup highlight_group);
@@ -44,7 +48,6 @@ class CookieFilterPageGtk : public OptionsPageBase {
// Widgets of the cookie storing group
GtkWidget* allow_radio_;
- GtkWidget* ask_every_time_radio_;
GtkWidget* block_radio_;
GtkWidget* exceptions_button_;
@@ -55,13 +58,19 @@ class CookieFilterPageGtk : public OptionsPageBase {
// The parent GtkTable widget
GtkWidget* page_;
- // Whether we're currently setting values (and thus should ignore "toggled"
- // events).
- bool initializing_;
+ // If state of the UI is not changed by a user-action we need to ignore
+ // "toggled" events.
+ bool ignore_toggle_;
// Clear locally stored site data on exit pref.
BooleanPrefMember clear_site_data_on_exit_;
+ // Block third-party-cookies.
+ BooleanPrefMember block_third_party_cookies_;
+
+ // Managed default-cookies-setting.
+ IntegerPrefMember managed_default_cookies_setting_;
+
DISALLOW_COPY_AND_ASSIGN(CookieFilterPageGtk);
};
diff --git a/chrome/browser/gtk/options/general_page_gtk.cc b/chrome/browser/gtk/options/general_page_gtk.cc
index 01aef9e..3ce8f45 100644
--- a/chrome/browser/gtk/options/general_page_gtk.cc
+++ b/chrome/browser/gtk/options/general_page_gtk.cc
@@ -20,6 +20,7 @@
#include "chrome/browser/gtk/options/options_layout_gtk.h"
#include "chrome/browser/gtk/options/url_picker_dialog_gtk.h"
#include "chrome/browser/instant/instant_confirm_dialog.h"
+#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/net/url_fixer_upper.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/session_startup_pref.h"
@@ -555,7 +556,7 @@ void GeneralPageGtk::OnInstantToggled(GtkWidget* toggle_button) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(instant_checkbox_), false);
browser::ShowInstantConfirmDialogIfNecessary(GetWindow(), profile());
} else {
- instant_.SetValue(enabled);
+ InstantController::Disable(profile());
}
// TODO(estade): UMA?
diff --git a/chrome/browser/gtk/page_info_bubble_gtk.cc b/chrome/browser/gtk/page_info_bubble_gtk.cc
index cfb54de..6bfa77c 100644
--- a/chrome/browser/gtk/page_info_bubble_gtk.cc
+++ b/chrome/browser/gtk/page_info_bubble_gtk.cc
@@ -11,6 +11,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/certificate_viewer.h"
+#include "chrome/browser/google/google_util.h"
#include "chrome/browser/gtk/browser_toolbar_gtk.h"
#include "chrome/browser/gtk/browser_window_gtk.h"
#include "chrome/browser/gtk/gtk_chrome_link_button.h"
@@ -23,6 +24,7 @@
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_service.h"
+#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
@@ -270,7 +272,8 @@ void PageInfoBubbleGtk::OnViewCertLinkClicked(GtkWidget* widget) {
}
void PageInfoBubbleGtk::OnHelpLinkClicked(GtkWidget* widget) {
- GURL url = GURL(l10n_util::GetStringUTF16(IDS_PAGE_INFO_HELP_CENTER));
+ GURL url = google_util::AppendGoogleLocaleParam(
+ GURL(chrome::kPageInfoHelpCenterURL));
Browser* browser = BrowserList::GetLastActive();
browser->OpenURL(url, GURL(), NEW_FOREGROUND_TAB, PageTransition::LINK);
bubble_->Close();
diff --git a/chrome/browser/gtk/reload_button_gtk.cc b/chrome/browser/gtk/reload_button_gtk.cc
index 70ae71e..6725dbb 100644
--- a/chrome/browser/gtk/reload_button_gtk.cc
+++ b/chrome/browser/gtk/reload_button_gtk.cc
@@ -7,11 +7,11 @@
#include "app/l10n_util.h"
#include "base/logging.h"
#include "chrome/app/chrome_command_ids.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/gtk/gtk_chrome_button.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/location_bar_view_gtk.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/notification_service.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
diff --git a/chrome/browser/gtk/sad_tab_gtk.cc b/chrome/browser/gtk/sad_tab_gtk.cc
index 569c53f..80612f7 100644
--- a/chrome/browser/gtk/sad_tab_gtk.cc
+++ b/chrome/browser/gtk/sad_tab_gtk.cc
@@ -8,9 +8,11 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "chrome/browser/google/google_util.h"
#include "chrome/browser/gtk/gtk_chrome_link_button.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
@@ -112,7 +114,8 @@ SadTabGtk::~SadTabGtk() {
void SadTabGtk::OnLinkButtonClick(GtkWidget* sender) {
if (tab_contents_ != NULL) {
- tab_contents_->OpenURL(GURL(l10n_util::GetStringUTF8(IDS_CRASH_REASON_URL)),
- GURL(), CURRENT_TAB, PageTransition::LINK);
+ GURL help_url =
+ google_util::AppendGoogleLocaleParam(GURL(chrome::kCrashReasonURL));
+ tab_contents_->OpenURL(help_url, GURL(), CURRENT_TAB, PageTransition::LINK);
}
}
diff --git a/chrome/browser/gtk/slide_animator_gtk.h b/chrome/browser/gtk/slide_animator_gtk.h
index df6d29b..dabdd70 100644
--- a/chrome/browser/gtk/slide_animator_gtk.h
+++ b/chrome/browser/gtk/slide_animator_gtk.h
@@ -17,7 +17,7 @@
#include <gtk/gtk.h>
-#include "app/animation.h"
+#include "app/animation_delegate.h"
#include "base/scoped_ptr.h"
#include "chrome/browser/gtk/owned_widget_gtk.h"
diff --git a/chrome/browser/gtk/status_bubble_gtk.cc b/chrome/browser/gtk/status_bubble_gtk.cc
index fbb8989..08eab1a 100644
--- a/chrome/browser/gtk/status_bubble_gtk.cc
+++ b/chrome/browser/gtk/status_bubble_gtk.cc
@@ -8,6 +8,7 @@
#include <algorithm>
+#include "app/slide_animation.h"
#include "app/text_elider.h"
#include "base/i18n/rtl.h"
#include "base/message_loop.h"
diff --git a/chrome/browser/gtk/status_bubble_gtk.h b/chrome/browser/gtk/status_bubble_gtk.h
index 1706665..b951b79 100644
--- a/chrome/browser/gtk/status_bubble_gtk.h
+++ b/chrome/browser/gtk/status_bubble_gtk.h
@@ -10,8 +10,8 @@
#include <string>
+#include "app/animation_delegate.h"
#include "app/gtk_signal.h"
-#include "app/slide_animation.h"
#include "base/scoped_ptr.h"
#include "base/timer.h"
#include "chrome/browser/gtk/owned_widget_gtk.h"
@@ -23,6 +23,7 @@
class GtkThemeProvider;
class Profile;
+class SlideAnimation;
// GTK implementation of StatusBubble. Unlike Windows, our status bubble
// doesn't have the nice leave-the-window effect since we can't rely on the
diff --git a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
index 5df0ea7..8ae9fd5 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
+++ b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
@@ -7,7 +7,6 @@
#include <algorithm>
#include "base/callback.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/gtk/browser_window_gtk.h"
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/gtk/tabs/dragged_tab_gtk.h"
@@ -15,6 +14,7 @@
#include "chrome/browser/platform_util.h"
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tabs/tab_strip_model.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/notification_service.h"
namespace {
diff --git a/chrome/browser/gtk/tabs/dragged_tab_gtk.h b/chrome/browser/gtk/tabs/dragged_tab_gtk.h
index 38c6525..6d7fcc4 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_gtk.h
+++ b/chrome/browser/gtk/tabs/dragged_tab_gtk.h
@@ -8,6 +8,7 @@
#include <gtk/gtk.h>
+#include "app/animation_delegate.h"
#include "app/slide_animation.h"
#include "base/callback.h"
#include "base/scoped_ptr.h"
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
index 318fcbe..5afd379 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.cc
@@ -9,9 +9,9 @@
#include "app/l10n_util.h"
#include "app/resource_bundle.h"
+#include "app/slide_animation.h"
#include "app/throb_animation.h"
#include "base/utf_string_conversions.h"
-#include "chrome/browser/browser.h"
#include "chrome/browser/defaults.h"
#include "chrome/browser/gtk/bookmark_utils_gtk.h"
#include "chrome/browser/gtk/custom_button.h"
@@ -19,9 +19,11 @@
#include "chrome/browser/gtk/gtk_util.h"
#include "chrome/browser/profile.h"
#include "chrome/browser/tab_contents/tab_contents.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/notification_service.h"
#include "gfx/canvas_skia_paint.h"
#include "gfx/favicon_size.h"
+#include "gfx/platform_font_gtk.h"
#include "gfx/skbitmap_operations.h"
#include "grit/app_resources.h"
#include "grit/generated_resources.h"
@@ -1070,10 +1072,11 @@ void TabRendererGtk::InitResources() {
LoadTabImages();
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
- // Force the font size to 9pt, which matches Windows' default font size
- // (taken from the system).
const gfx::Font& base_font = rb.GetFont(ResourceBundle::BaseFont);
- title_font_ = new gfx::Font(base_font.GetFontName(), 9);
+ // Dividing by the pango scale factor maintains an absolute pixel size across
+ // all DPIs.
+ int size = static_cast<int>(13 / gfx::PlatformFontGtk::GetPangoScaleFactor());
+ title_font_ = new gfx::Font(base_font.GetFontName(), size);
title_font_height_ = title_font_->GetHeight();
crashed_fav_icon = rb.GetBitmapNamed(IDR_SAD_FAVICON);
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
index 51f11b7..6849a2a 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
@@ -9,9 +9,8 @@
#include <gtk/gtk.h>
#include <map>
-#include "app/animation.h"
+#include "app/animation_delegate.h"
#include "app/gtk_signal.h"
-#include "app/slide_animation.h"
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "base/string16.h"
@@ -29,6 +28,7 @@ class Size;
class CustomDrawButton;
class GtkThemeProvider;
+class SlideAnimation;
class TabContents;
class ThemeProvider;
class ThrobAnimation;
diff --git a/chrome/browser/gtk/tabs/tab_strip_gtk.cc b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
index 0547815..41d1e27 100644
--- a/chrome/browser/gtk/tabs/tab_strip_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_strip_gtk.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "app/animation_delegate.h"
#include "app/gtk_dnd_util.h"
#include "app/resource_bundle.h"
#include "app/slide_animation.h"
@@ -21,6 +22,8 @@
#include "chrome/browser/tab_contents/tab_contents.h"
#include "chrome/browser/tabs/tab_strip_model_delegate.h"
#include "chrome/browser/themes/browser_theme_provider.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/notification_type.h"
#include "gfx/gtk_util.h"
@@ -1612,20 +1615,19 @@ bool TabStripGtk::CompleteDrop(guchar* data) {
if (!url.is_valid())
return false;
+ browser::NavigateParams params(window()->browser(), url,
+ PageTransition::LINK);
+ params.tabstrip_index = drop_index;
+
if (drop_before) {
- // Insert a new tab.
- TabContents* contents =
- model_->delegate()->CreateTabContentsForURL(
- url, GURL(), model_->profile(), PageTransition::TYPED, false,
- NULL);
- model_->AddTabContents(contents, drop_index, PageTransition::GENERATED,
- TabStripModel::ADD_SELECTED);
+ params.disposition = NEW_FOREGROUND_TAB;
} else {
- model_->GetTabContentsAt(drop_index)->controller().LoadURL(
- url, GURL(), PageTransition::GENERATED);
- model_->SelectTabContentsAt(drop_index, true);
+ params.disposition = CURRENT_TAB;
+ params.source_contents = model_->GetTabContentsAt(drop_index);
}
+ browser::Navigate(&params);
+
return true;
}
@@ -1974,19 +1976,9 @@ void TabStripGtk::OnNewTabClicked(GtkWidget* widget) {
if (!gtk_util::URLFromPrimarySelection(model_->profile(), &url))
return;
- TabContents* contents =
- model_->delegate()->CreateTabContentsForURL(
- url,
- GURL(), // referrer
- model_->profile(),
- PageTransition::TYPED,
- false, // defer_load
- NULL); // instance
- model_->AddTabContents(
- contents,
- -1, // index
- PageTransition::TYPED,
- TabStripModel::ADD_SELECTED);
+ Browser* browser = window_->browser();
+ DCHECK(browser);
+ browser->AddSelectedTabWithURL(url, PageTransition::TYPED);
break;
}
default:
diff --git a/chrome/browser/gtk/task_manager_gtk.cc b/chrome/browser/gtk/task_manager_gtk.cc
index ad7137d..fcb9817 100644
--- a/chrome/browser/gtk/task_manager_gtk.cc
+++ b/chrome/browser/gtk/task_manager_gtk.cc
@@ -19,6 +19,7 @@
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/defaults.h"
#include "chrome/browser/gtk/gtk_chrome_link_button.h"
#include "chrome/browser/gtk/gtk_theme_provider.h"
#include "chrome/browser/gtk/gtk_tree.h"
@@ -426,6 +427,12 @@ void TaskManagerGtk::Init() {
kTaskManagerPurgeMemory);
}
+ if (browser_defaults::kShowCancelButtonInTaskManager) {
+ gtk_dialog_add_button(GTK_DIALOG(dialog_),
+ l10n_util::GetStringUTF8(IDS_CLOSE).c_str(),
+ GTK_RESPONSE_DELETE_EVENT);
+ }
+
gtk_dialog_add_button(GTK_DIALOG(dialog_),
l10n_util::GetStringUTF8(IDS_TASK_MANAGER_KILL).c_str(),
kTaskManagerResponseKill);
diff --git a/chrome/browser/gtk/translate/translate_infobar_base_gtk.h b/chrome/browser/gtk/translate/translate_infobar_base_gtk.h
index ce851f9..8b2303b 100644
--- a/chrome/browser/gtk/translate/translate_infobar_base_gtk.h
+++ b/chrome/browser/gtk/translate/translate_infobar_base_gtk.h
@@ -6,6 +6,7 @@
#define CHROME_BROWSER_GTK_TRANSLATE_TRANSLATE_INFOBAR_BASE_GTK_H_
#pragma once
+#include "app/animation_delegate.h"
#include "chrome/browser/translate/translate_infobar_view.h"
#include "chrome/browser/gtk/infobar_gtk.h"
diff --git a/chrome/browser/gtk/view_id_util_browsertest.cc b/chrome/browser/gtk/view_id_util_browsertest.cc
index be4f38c..58ff80d 100644
--- a/chrome/browser/gtk/view_id_util_browsertest.cc
+++ b/chrome/browser/gtk/view_id_util_browsertest.cc
@@ -4,9 +4,9 @@
#include <gtk/gtk.h>
-#include "chrome/browser/browser.h"
#include "chrome/browser/browser_window.h"
#include "chrome/browser/gtk/view_id_util.h"
+#include "chrome/browser/ui/browser.h"
#include "chrome/common/url_constants.h"
#include "chrome/test/in_process_browser_test.h"