summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.cc31
-rw-r--r--chrome/browser/gtk/bookmark_bar_gtk.h25
-rw-r--r--chrome/browser/gtk/standard_menus.cc5
-rw-r--r--chrome/browser/gtk/sync_setup_wizard_gtk.cc121
-rw-r--r--chrome/browser/gtk/sync_setup_wizard_gtk.h51
5 files changed, 232 insertions, 1 deletions
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.cc b/chrome/browser/gtk/bookmark_bar_gtk.cc
index eb71258..191844c 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.cc
+++ b/chrome/browser/gtk/bookmark_bar_gtk.cc
@@ -118,6 +118,10 @@ BookmarkBarGtk::BookmarkBarGtk(BrowserWindowGtk* window,
model_(NULL),
instructions_label_(NULL),
instructions_(NULL),
+#ifdef CHROME_PERSONALIZATION
+ sync_error_button_(NULL),
+ sync_service_(NULL),
+#endif
dragged_node_(NULL),
toolbar_drop_item_(NULL),
theme_provider_(GtkThemeProvider::GetFrom(profile)),
@@ -125,6 +129,15 @@ BookmarkBarGtk::BookmarkBarGtk(BrowserWindowGtk* window,
menu_bar_helper_(this),
floating_(false),
last_allocation_width_(-1) {
+#ifdef CHROME_PERSONALIZATION
+ if (profile->GetProfileSyncService()) {
+ // Obtain a pointer to the profile sync service and add our instance as an
+ // observer.
+ sync_service_ = profile->GetProfileSyncService();
+ sync_service_->AddObserver(this);
+ }
+#endif
+
Init(profile);
SetProfile(profile);
// Force an update by simulating being in the wrong state.
@@ -142,6 +155,11 @@ BookmarkBarGtk::~BookmarkBarGtk() {
RemoveAllBookmarkButtons();
bookmark_toolbar_.Destroy();
event_box_.Destroy();
+
+#ifdef CHROME_PERSONALIZATION
+ if (sync_service_)
+ sync_service_->RemoveObserver(this);
+#endif
}
void BookmarkBarGtk::SetProfile(Profile* profile) {
@@ -248,6 +266,13 @@ void BookmarkBarGtk::Init(Profile* profile) {
g_signal_connect(vseparator, "expose-event",
G_CALLBACK(OnSeparatorExpose), this);
+#ifdef CHROME_PERSONALIZATION
+ sync_error_button_ = theme_provider_->BuildChromeButton();
+ ConnectFolderButtonEvents(sync_error_button_);
+ gtk_box_pack_start(GTK_BOX(bookmark_hbox_), sync_error_button_,
+ FALSE, FALSE, 0);
+#endif
+
// We pack the button manually (rather than using gtk_button_set_*) so that
// we can have finer control over its label.
other_bookmarks_button_ = theme_provider_->BuildChromeButton();
@@ -311,6 +336,12 @@ void BookmarkBarGtk::Hide(bool animate) {
}
}
+#ifdef CHROME_PERSONALIZATION
+void BookmarkBarGtk::OnStateChanged() {
+ // TODO(zork): TODO
+}
+#endif
+
void BookmarkBarGtk::EnterFullscreen() {
UpdateFloatingState();
if (!floating_)
diff --git a/chrome/browser/gtk/bookmark_bar_gtk.h b/chrome/browser/gtk/bookmark_bar_gtk.h
index e353ec1..bc9b24c 100644
--- a/chrome/browser/gtk/bookmark_bar_gtk.h
+++ b/chrome/browser/gtk/bookmark_bar_gtk.h
@@ -15,6 +15,7 @@
#include "chrome/browser/bookmarks/bookmark_model_observer.h"
#include "chrome/browser/gtk/menu_bar_helper.h"
#include "chrome/browser/gtk/view_id_util.h"
+#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/owned_widget_gtk.h"
@@ -31,6 +32,9 @@ class TabstripOriginProvider;
struct GtkThemeProvider;
class BookmarkBarGtk : public AnimationDelegate,
+#ifdef CHROME_PERSONALIZATION
+ public ProfileSyncServiceObserver,
+#endif
public BookmarkModelObserver,
public MenuBarHelper::Delegate,
public NotificationObserver {
@@ -247,6 +251,18 @@ class BookmarkBarGtk : public AnimationDelegate,
static gboolean OnSeparatorExpose(GtkWidget* widget, GdkEventExpose* event,
BookmarkBarGtk* window);
+#ifdef CHROME_PERSONALIZATION
+ // ProfileSyncServiceObserver method.
+ virtual void OnStateChanged();
+
+ // Determines whether the sync error button should appear on the bookmarks
+ // bar.
+ bool ShouldShowSyncErrorButton();
+
+ // Creates the sync error button and adds it as a child view.
+ GtkWidget* CreateSyncErrorButton();
+#endif
+
Profile* profile_;
// Used for opening urls.
@@ -291,6 +307,15 @@ class BookmarkBarGtk : public AnimationDelegate,
// The other bookmarks button.
GtkWidget* other_bookmarks_button_;
+#ifdef CHROME_PERSONALIZATION
+ // The sync re-login indicator which appears when the user needs to re-enter
+ // credentials in order to continue syncing.
+ GtkWidget* sync_error_button_;
+
+ // A pointer to the ProfileSyncService instance if one exists.
+ ProfileSyncService* sync_service_;
+#endif
+
// The BookmarkNode from the model being dragged. NULL when we aren't
// dragging.
const BookmarkNode* dragged_node_;
diff --git a/chrome/browser/gtk/standard_menus.cc b/chrome/browser/gtk/standard_menus.cc
index 261375e..ce71769 100644
--- a/chrome/browser/gtk/standard_menus.cc
+++ b/chrome/browser/gtk/standard_menus.cc
@@ -93,7 +93,10 @@ struct MenuCreateMaterial standard_app_menu_materials[] = {
{ MENU_NORMAL, IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS, 0, NULL,
GDK_j, GDK_CONTROL_MASK },
{ MENU_SEPARATOR },
- // TODO(erg): P13N stuff goes here as soon as they get IDS strings.
+#ifdef CHROME_PERSONALIZATION
+ { MENU_NORMAL, IDC_SYNC_BOOKMARKS, IDS_SYNC_MY_BOOKMARKS_LABEL},
+ { MENU_SEPARATOR },
+#endif
{ MENU_NORMAL, IDC_OPTIONS, IDS_OPTIONS, IDS_PRODUCT_NAME },
{ MENU_NORMAL, IDC_ABOUT, IDS_ABOUT, IDS_PRODUCT_NAME },
{ MENU_NORMAL, IDC_HELP_PAGE, IDS_HELP_PAGE, 0, NULL, GDK_F1 },
diff --git a/chrome/browser/gtk/sync_setup_wizard_gtk.cc b/chrome/browser/gtk/sync_setup_wizard_gtk.cc
new file mode 100644
index 0000000..e2f46a9
--- /dev/null
+++ b/chrome/browser/gtk/sync_setup_wizard_gtk.cc
@@ -0,0 +1,121 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/gtk/sync_setup_wizard_gtk.h"
+
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/sync/profile_sync_service.h"
+#include "chrome/browser/views/sync/sync_setup_wizard.h"
+#include "chrome/common/gtk_util.h"
+
+SyncSetupWizard::SyncSetupWizard(ProfileSyncService* service)
+ : username_textbox_(NULL),
+ password_textbox_(NULL),
+ service_(service),
+ visible_(false) {
+}
+
+SyncSetupWizard::~SyncSetupWizard() {
+}
+
+void SyncSetupWizard::Step(State advance_state) {
+ switch (advance_state) {
+ case GAIA_LOGIN:
+ SyncSetupWizardGtk::Show(service_, this);
+ break;
+ case GAIA_SUCCESS:
+ case MERGE_AND_SYNC:
+ case FATAL_ERROR:
+ case DONE:
+ // TODO(zork): Implement
+ break;
+ default:
+ NOTREACHED();
+ }
+}
+
+bool SyncSetupWizard::IsVisible() const {
+ return visible_;
+}
+
+// static
+void SyncSetupWizardGtk::Show(ProfileSyncService* service,
+ SyncSetupWizard *wizard) {
+ Browser* b = BrowserList::GetLastActive();
+ new SyncSetupWizardGtk(b->window()->GetNativeHandle(), service, wizard);
+}
+
+SyncSetupWizardGtk::SyncSetupWizardGtk(GtkWindow* parent,
+ ProfileSyncService* service,
+ SyncSetupWizard *wizard)
+ : service_(service),
+ wizard_(wizard) {
+ // TODO(zork): Put in proper localized strings.
+ //
+ // Build the dialog.
+ GtkWidget* dialog = gtk_dialog_new_with_buttons(
+ "Setting up Bookmarks Sync",
+ parent,
+ (GtkDialogFlags) (GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_REJECT,
+ NULL);
+ gtk_util::AddButtonToDialog(dialog,
+ "Accept",
+ GTK_STOCK_APPLY, GTK_RESPONSE_ACCEPT);
+
+ GtkWidget* content_area = GTK_DIALOG(dialog)->vbox;
+ gtk_box_set_spacing(GTK_BOX(content_area), gtk_util::kContentAreaSpacing);
+
+ GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
+ gtk_container_add(GTK_CONTAINER(content_area), vbox);
+
+ // Description.
+ GtkWidget* description = gtk_label_new(
+ "Google Chrome can store your bookmark data with your Google account.\n"
+ "Bookmarks that you create on this computer will instantly be made\n"
+ "available on all the computers synced to this account.\n");
+ gtk_misc_set_alignment(GTK_MISC(description), 0, 0);
+ gtk_container_add(GTK_CONTAINER(content_area), description);
+
+ // Label on top of the username.
+ GtkWidget* email = gtk_label_new("Email:");
+ gtk_misc_set_alignment(GTK_MISC(email), 0, 0);
+ gtk_container_add(GTK_CONTAINER(content_area), email);
+
+ // Username text box
+ username_textbox_= gtk_entry_new();
+ gtk_container_add(GTK_CONTAINER(content_area), username_textbox_);
+
+ // Label on top of the password.
+ GtkWidget* password = gtk_label_new("Password:");
+ gtk_misc_set_alignment(GTK_MISC(password), 0, 0);
+ gtk_container_add(GTK_CONTAINER(content_area), password);
+
+ // Password text box
+ password_textbox_= gtk_entry_new();
+ gtk_entry_set_visibility(GTK_ENTRY(password_textbox_), FALSE);
+ gtk_container_add(GTK_CONTAINER(content_area), password_textbox_);
+
+ g_signal_connect(dialog, "response",
+ G_CALLBACK(HandleOnResponseDialog), this);
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+ gtk_widget_show_all(dialog);
+}
+
+void SyncSetupWizardGtk::OnDialogResponse(GtkWidget* widget, int response) {
+ wizard_->SetVisible(false);
+ if (response == GTK_RESPONSE_ACCEPT) {
+ service_->OnUserSubmittedAuth(
+ gtk_entry_get_text(GTK_ENTRY(username_textbox_)),
+ gtk_entry_get_text(GTK_ENTRY(password_textbox_)));
+
+ service_->SetSyncSetupCompleted();
+ }
+ service_->OnUserCancelledDialog();
+
+ delete this;
+ gtk_widget_destroy(GTK_WIDGET(widget));
+}
diff --git a/chrome/browser/gtk/sync_setup_wizard_gtk.h b/chrome/browser/gtk/sync_setup_wizard_gtk.h
new file mode 100644
index 0000000..2d76046
--- /dev/null
+++ b/chrome/browser/gtk/sync_setup_wizard_gtk.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_GTK_SYNC_SETUP_WIZARD_GTK_H_
+#define CHROME_BROWSER_GTK_SYNC_SETUP_WIZARD_GTK_H_
+
+#include <gtk/gtk.h>
+
+#include "base/basictypes.h"
+#include "base/string16.h"
+#include "googleurl/src/gurl.h"
+
+typedef struct _GtkWidget GtkWidget;
+typedef struct _GtkWindow GtkWindow;
+
+class ProfileSyncService;
+
+class SyncSetupWizard;
+
+class SyncSetupWizardGtk {
+ public:
+ // Displays the dialog box to setup sync.
+ static void Show(ProfileSyncService* service,
+ SyncSetupWizard *wizard);
+
+ private:
+ SyncSetupWizardGtk(GtkWindow* parent, ProfileSyncService* service,
+ SyncSetupWizard *wizard);
+ ~SyncSetupWizardGtk() { }
+
+ // Handler to respond to Ok and Cancel responses from the dialog.
+ static void HandleOnResponseDialog(GtkWidget* widget,
+ int response, SyncSetupWizardGtk* setup_wizard) {
+ setup_wizard->OnDialogResponse(widget, response);
+ }
+
+ void OnDialogResponse(GtkWidget* widget, int response);
+
+ // UI elements.
+ GtkWidget* username_textbox_;
+ GtkWidget* password_textbox_;
+
+ // We need this to write the sentinel "setup completed" pref.
+ ProfileSyncService* service_;
+ SyncSetupWizard* wizard_;
+
+ DISALLOW_COPY_AND_ASSIGN(SyncSetupWizardGtk);
+};
+
+#endif // CHROME_BROWSER_GTK_SYNC_SETUP_WIZARD_GTK_H_