summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/cocoa/html_dialog_window_controller.h11
-rw-r--r--chrome/browser/cocoa/html_dialog_window_controller.mm10
-rw-r--r--chrome/browser/cocoa/html_dialog_window_controller_cppsafe.h10
-rw-r--r--chrome/browser/sync/profile_sync_service.cc13
-rw-r--r--chrome/browser/sync/profile_sync_service.h3
-rw-r--r--chrome/browser/sync/sync_setup_flow.cc31
-rw-r--r--chrome/browser/sync/sync_setup_flow.h17
7 files changed, 42 insertions, 53 deletions
diff --git a/chrome/browser/cocoa/html_dialog_window_controller.h b/chrome/browser/cocoa/html_dialog_window_controller.h
index 9c871b1..c8e3884 100644
--- a/chrome/browser/cocoa/html_dialog_window_controller.h
+++ b/chrome/browser/cocoa/html_dialog_window_controller.h
@@ -29,13 +29,10 @@ class TabContents;
}
// Creates and shows an HtmlDialogWindowController with the given
-// delegate and profile. The window is automatically destroyed when
-// it is closed. Returns the created window.
-//
-// Make sure to use the returned window only when you know it is safe
-// to do so, i.e. before OnDialogClosed() is called on the delegate.
-+ (NSWindow*)showHtmlDialog:(HtmlDialogUIDelegate*)delegate
- profile:(Profile*)profile;
+// delegate and profile. The window is automatically destroyed when it is
+// closed.
++ (void)showHtmlDialog:(HtmlDialogUIDelegate*)delegate
+ profile:(Profile*)profile;
@end
diff --git a/chrome/browser/cocoa/html_dialog_window_controller.mm b/chrome/browser/cocoa/html_dialog_window_controller.mm
index 32b2096..f2b79ea 100644
--- a/chrome/browser/cocoa/html_dialog_window_controller.mm
+++ b/chrome/browser/cocoa/html_dialog_window_controller.mm
@@ -72,9 +72,8 @@ private:
namespace html_dialog_window_controller {
-gfx::NativeWindow ShowHtmlDialog(
- HtmlDialogUIDelegate* delegate, Profile* profile) {
- return [HtmlDialogWindowController showHtmlDialog:delegate profile:profile];
+void ShowHtmlDialog(HtmlDialogUIDelegate* delegate, Profile* profile) {
+ [HtmlDialogWindowController showHtmlDialog:delegate profile:profile];
}
} // namespace html_dialog_window_controller
@@ -218,14 +217,13 @@ void HtmlDialogWindowDelegateBridge::HandleKeyboardEvent(
// NOTE(akalin): We'll probably have to add the parentWindow parameter back
// in once we implement modal dialogs.
-+ (NSWindow*)showHtmlDialog:(HtmlDialogUIDelegate*)delegate
- profile:(Profile*)profile {
++ (void)showHtmlDialog:(HtmlDialogUIDelegate*)delegate
+ profile:(Profile*)profile {
HtmlDialogWindowController* htmlDialogWindowController =
[[HtmlDialogWindowController alloc] initWithDelegate:delegate
profile:profile];
[htmlDialogWindowController loadDialogContents];
[htmlDialogWindowController showWindow:nil];
- return [htmlDialogWindowController window];
}
- (id)initWithDelegate:(HtmlDialogUIDelegate*)delegate
diff --git a/chrome/browser/cocoa/html_dialog_window_controller_cppsafe.h b/chrome/browser/cocoa/html_dialog_window_controller_cppsafe.h
index 9bcd975..15c4576 100644
--- a/chrome/browser/cocoa/html_dialog_window_controller_cppsafe.h
+++ b/chrome/browser/cocoa/html_dialog_window_controller_cppsafe.h
@@ -5,8 +5,6 @@
#ifndef CHROME_BROWSER_COCOA_HTML_DIALOG_WINDOW_CONTROLLER_CPPSAFE_H_
#define CHROME_BROWSER_COCOA_HTML_DIALOG_WINDOW_CONTROLLER_CPPSAFE_H_
-#include "gfx/native_widget_types.h"
-
// We declare this in a separate file that is safe for including in C++ code.
// TODO(akalin): It would be nice if there were a platform-agnostic way to
@@ -18,12 +16,8 @@ namespace html_dialog_window_controller {
// Creates and shows an HtmlDialogWindowController with the given
// delegate and profile. The window is automatically destroyed when it is
-// closed. Returns the created window.
-//
-// Make sure to use the returned window only when you know it is safe
-// to do so, i.e. before OnDialogClosed() is called on the delegate.
-gfx::NativeWindow ShowHtmlDialog(
- HtmlDialogUIDelegate* delegate, Profile* profile);
+// closed.
+void ShowHtmlDialog(HtmlDialogUIDelegate* delegate, Profile* profile);
} // namespace html_dialog_window_controller
diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc
index 5c502a4..da9c1d3 100644
--- a/chrome/browser/sync/profile_sync_service.cc
+++ b/chrome/browser/sync/profile_sync_service.cc
@@ -23,6 +23,11 @@
#include "chrome/browser/sync/glue/data_type_controller.h"
#include "chrome/browser/sync/glue/data_type_manager.h"
#include "chrome/browser/sync/profile_sync_factory.h"
+#if defined(OS_WIN)
+#include "chrome/browser/views/options/customize_sync_window_view.h"
+#elif defined(OS_LINUX)
+#include "chrome/browser/gtk/options/customize_sync_window_gtk.h"
+#endif
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_details.h"
#include "chrome/common/notification_service.h"
@@ -444,6 +449,14 @@ string16 ProfileSyncService::GetAuthenticatedUsername() const {
return backend_->GetAuthenticatedUsername();
}
+void ProfileSyncService::OnUserClickedCustomize() {
+#if defined(OS_WIN)
+ CustomizeSyncWindowView::Show(NULL, profile_);
+#elif defined(OS_LINUX)
+ ShowCustomizeSyncWindow(profile_);
+#endif
+}
+
void ProfileSyncService::OnUserSubmittedAuth(
const std::string& username, const std::string& password,
const std::string& captcha) {
diff --git a/chrome/browser/sync/profile_sync_service.h b/chrome/browser/sync/profile_sync_service.h
index 7777e1a..ceacc59 100644
--- a/chrome/browser/sync/profile_sync_service.h
+++ b/chrome/browser/sync/profile_sync_service.h
@@ -150,6 +150,9 @@ class ProfileSyncService : public browser_sync::SyncFrontend,
virtual void OnSyncCycleCompleted();
virtual void OnAuthError();
+ // Called when a user clicks the "customize" button while setting up sync.
+ virtual void OnUserClickedCustomize();
+
// Called when a user enters credentials through UI.
virtual void OnUserSubmittedAuth(const std::string& username,
const std::string& password,
diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc
index 595b3a3..1ccc8a3 100644
--- a/chrome/browser/sync/sync_setup_flow.cc
+++ b/chrome/browser/sync/sync_setup_flow.cc
@@ -55,11 +55,9 @@ static std::string GetJsonResponse(const Value* content) {
}
void FlowHandler::RegisterMessages() {
+#if defined(OS_WIN) || defined(OS_LINUX)
dom_ui_->RegisterMessageCallback("ShowCustomize",
NewCallback(this, &FlowHandler::HandleUserClickedCustomize));
- // On OS X, the customize dialog is modal to the HTML window so we
- // don't need to hook up the two functions below.
-#if defined(OS_WIN) || defined(OS_LINUX)
dom_ui_->RegisterMessageCallback("ClickCustomizeOk",
NewCallback(this, &FlowHandler::ClickCustomizeOk));
dom_ui_->RegisterMessageCallback("ClickCustomizeCancel",
@@ -179,8 +177,7 @@ SyncSetupFlow::SyncSetupFlow(SyncSetupWizard::State start_state,
login_start_time_(base::TimeTicks::Now()),
flow_handler_(new FlowHandler()),
owns_flow_handler_(true),
- service_(service),
- html_dialog_window_(NULL) {
+ service_(service) {
flow_handler_->set_flow(this);
}
@@ -264,7 +261,11 @@ void SyncSetupFlow::GetArgsForGaiaLogin(const ProfileSyncService* service,
args->SetString(L"captchaUrl", error.captcha().image_url.spec());
+#if defined(OS_WIN) || defined(OS_LINUX)
args->SetBoolean(L"showCustomize", true);
+#else
+ args->SetBoolean(L"showCustomize", false);
+#endif
}
void SyncSetupFlow::GetDOMMessageHandlers(
@@ -337,23 +338,21 @@ SyncSetupFlow* SyncSetupFlow::Run(ProfileSyncService* service,
SyncSetupFlow* flow = new SyncSetupFlow(start, end, json_args,
container, service);
-#if defined(OS_MACOSX)
- // TODO(akalin): Figure out a cleaner way to do this than to have this
- // gross per-OS behavior, i.e. have a cross-platform ShowHtmlDialog()
- // function that is not tied to a browser instance. Note that if we do
- // that, we'll have to fix sync_setup_wizard_unittest.cc as it relies on
- // being able to intercept ShowHtmlDialog() calls.
- flow->html_dialog_window_ =
- html_dialog_window_controller::ShowHtmlDialog(
- flow, service->profile());
-#else
Browser* b = BrowserList::GetLastActive();
if (b) {
b->BrowserShowHtmlDialog(flow, NULL);
} else {
+ // TODO(akalin): Figure out a cleaner way to do this than to have this
+ // gross per-OS behavior, i.e. have a cross-platform ShowHtmlDialog()
+ // function that is not tied to a browser instance. Note that if we do
+ // that, we'll have to fix sync_setup_wizard_unittest.cc as it relies on
+ // being able to intercept ShowHtmlDialog() calls.
+#if defined(OS_MACOSX)
+ html_dialog_window_controller::ShowHtmlDialog(flow, service->profile());
+#else
delete flow;
return NULL;
+#endif
}
-#endif // defined(OS_MACOSX)
return flow;
}
diff --git a/chrome/browser/sync/sync_setup_flow.h b/chrome/browser/sync/sync_setup_flow.h
index 35ac55e..3a711a9 100644
--- a/chrome/browser/sync/sync_setup_flow.h
+++ b/chrome/browser/sync/sync_setup_flow.h
@@ -17,10 +17,7 @@
#include "chrome/browser/views/options/customize_sync_window_view.h"
#elif defined(OS_LINUX)
#include "chrome/browser/gtk/options/customize_sync_window_gtk.h"
-#elif defined(OS_MACOSX)
-#include "chrome/browser/cocoa/sync_customize_controller_cppsafe.h"
#endif
-#include "gfx/native_widget_types.h"
#include "grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest_prod.h"
@@ -85,14 +82,7 @@ class SyncSetupFlow : public HtmlDialogUIDelegate {
}
void OnUserClickedCustomize() {
-#if defined(OS_WIN)
- CustomizeSyncWindowView::Show(NULL, service_->profile());
-#elif defined(OS_LINUX)
- ShowCustomizeSyncWindow(service_->profile());
-#elif defined(OS_MACOSX)
- DCHECK(html_dialog_window_);
- ShowSyncCustomizeDialog(html_dialog_window_, service_);
-#endif
+ service_->OnUserClickedCustomize();
}
void ClickCustomizeOk() {
@@ -153,11 +143,6 @@ class SyncSetupFlow : public HtmlDialogUIDelegate {
// We need this to write the sentinel "setup completed" pref.
ProfileSyncService* service_;
- // Currently used only on OS X
- // TODO(akalin): Add the necessary support to the other OSes and use
- // this for them.
- gfx::NativeWindow html_dialog_window_;
-
DISALLOW_COPY_AND_ASSIGN(SyncSetupFlow);
};