diff options
author | csilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-03 17:15:22 +0000 |
---|---|---|
committer | csilv@chromium.org <csilv@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-03 17:15:22 +0000 |
commit | 9fa8af659705465662679b7663aa501b5cdb0861 (patch) | |
tree | 03556da50a4349f5a079c89baee166a6e326d841 /chrome | |
parent | 684c407d7da343e29a98e115cc66eb7f3057a35a (diff) | |
download | chromium_src-9fa8af659705465662679b7663aa501b5cdb0861.zip chromium_src-9fa8af659705465662679b7663aa501b5cdb0861.tar.gz chromium_src-9fa8af659705465662679b7663aa501b5cdb0861.tar.bz2 |
Changes to allow focusing the syncronization dialog, useful for the case where the user
chooses to sync, but the window is already open and obscured by another window. For now
this only works on Mac due to how browser dialogs are handled on different platforms.
BUG=30649
TEST=Choose to 'Sync' when the sync window is already open behind a browser window.
Review URL: http://codereview.chromium.org/2121017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48840 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/platform_util.h | 3 | ||||
-rw-r--r-- | chrome/browser/platform_util_common_linux.cc | 4 | ||||
-rw-r--r-- | chrome/browser/platform_util_mac.mm | 4 | ||||
-rw-r--r-- | chrome/browser/platform_util_win.cc | 4 | ||||
-rw-r--r-- | chrome/browser/sync/profile_sync_service.cc | 6 | ||||
-rw-r--r-- | chrome/browser/sync/sync_setup_flow.cc | 14 | ||||
-rw-r--r-- | chrome/browser/sync/sync_setup_flow.h | 4 | ||||
-rw-r--r-- | chrome/browser/sync/sync_setup_wizard.cc | 7 | ||||
-rw-r--r-- | chrome/browser/sync/sync_setup_wizard.h | 4 |
9 files changed, 48 insertions, 2 deletions
diff --git a/chrome/browser/platform_util.h b/chrome/browser/platform_util.h index b75e7ff..4ab45b2 100644 --- a/chrome/browser/platform_util.h +++ b/chrome/browser/platform_util.h @@ -29,6 +29,9 @@ gfx::NativeWindow GetTopLevel(gfx::NativeView view); // Returns true if |window| is the foreground top level window. bool IsWindowActive(gfx::NativeWindow window); +// Activate the window, bringing it to the foreground top level. +void ActivateWindow(gfx::NativeWindow window); + // Returns true if the view is visible. The exact definition of this is // platform-specific, but it is generally not "visible to the user", rather // whether the view has the visible attribute set. diff --git a/chrome/browser/platform_util_common_linux.cc b/chrome/browser/platform_util_common_linux.cc index 328d260..4d64833 100644 --- a/chrome/browser/platform_util_common_linux.cc +++ b/chrome/browser/platform_util_common_linux.cc @@ -27,6 +27,10 @@ bool IsWindowActive(gfx::NativeWindow window) { return gtk_window_is_active(window); } +void ActivateWindow(gfx::NativeWindow window) { + gtk_window_present(window); +} + bool IsVisible(gfx::NativeView view) { return GTK_WIDGET_VISIBLE(view); } diff --git a/chrome/browser/platform_util_mac.mm b/chrome/browser/platform_util_mac.mm index 745b9f5..79dca7c 100644 --- a/chrome/browser/platform_util_mac.mm +++ b/chrome/browser/platform_util_mac.mm @@ -48,6 +48,10 @@ bool IsWindowActive(gfx::NativeWindow window) { return [window isKeyWindow] || [window isMainWindow]; } +void ActivateWindow(gfx::NativeWindow window) { + [window makeKeyAndOrderFront:nil]; +} + bool IsVisible(gfx::NativeView view) { // A reasonable approximation of how you'd expect this to behave. return (view && diff --git a/chrome/browser/platform_util_win.cc b/chrome/browser/platform_util_win.cc index 7738fe3..cef8155e 100644 --- a/chrome/browser/platform_util_win.cc +++ b/chrome/browser/platform_util_win.cc @@ -143,6 +143,10 @@ bool IsWindowActive(gfx::NativeWindow window) { return ::GetForegroundWindow() == window; } +void ActivateWindow(gfx::NativeWindow window) { + ::SetForegroundWindow(window); +} + bool IsVisible(gfx::NativeView view) { // MSVC complains if we don't include != 0. return ::IsWindowVisible(view) != 0; diff --git a/chrome/browser/sync/profile_sync_service.cc b/chrome/browser/sync/profile_sync_service.cc index ae4a211..e6cd161 100644 --- a/chrome/browser/sync/profile_sync_service.cc +++ b/chrome/browser/sync/profile_sync_service.cc @@ -325,7 +325,7 @@ void ProfileSyncService::Shutdown(bool sync_disabled) { void ProfileSyncService::EnableForUser() { if (WizardIsVisible()) { - // TODO(timsteele): Focus wizard. + wizard_.Focus(); return; } expecting_first_run_auth_needed_event_ = true; @@ -476,8 +476,10 @@ void ProfileSyncService::OnAuthError() { } void ProfileSyncService::ShowLoginDialog() { - if (WizardIsVisible()) + if (WizardIsVisible()) { + wizard_.Focus(); return; + } if (!auth_error_time_.is_null()) { UMA_HISTOGRAM_LONG_TIMES("Sync.ReauthorizationTime", diff --git a/chrome/browser/sync/sync_setup_flow.cc b/chrome/browser/sync/sync_setup_flow.cc index b1b9fa1..92e345e 100644 --- a/chrome/browser/sync/sync_setup_flow.cc +++ b/chrome/browser/sync/sync_setup_flow.cc @@ -19,6 +19,7 @@ #endif #include "chrome/browser/dom_ui/dom_ui_util.h" #include "chrome/browser/google_service_auth_error.h" +#include "chrome/browser/platform_util.h" #include "chrome/browser/pref_service.h" #include "chrome/browser/profile.h" #include "chrome/browser/renderer_host/render_view_host.h" @@ -323,6 +324,19 @@ void SyncSetupFlow::Advance(SyncSetupWizard::State advance_state) { current_state_ = advance_state; } +void SyncSetupFlow::Focus() { +#if defined(OS_MACOSX) + if (html_dialog_window_) { + platform_util::ActivateWindow(html_dialog_window_); + } +#else + // TODO(csilv): We don't currently have a way to get the reference to the + // dialog on windows/linux. This can be resolved by a cross platform + // implementation of HTML dialogs as described by akalin below. + NOTIMPLEMENTED(); +#endif // defined(OS_MACOSX) +} + // static SyncSetupFlow* SyncSetupFlow::Run(ProfileSyncService* service, SyncSetupFlowContainer* container, diff --git a/chrome/browser/sync/sync_setup_flow.h b/chrome/browser/sync/sync_setup_flow.h index db9de27..9aa4379 100644 --- a/chrome/browser/sync/sync_setup_flow.h +++ b/chrome/browser/sync/sync_setup_flow.h @@ -50,6 +50,10 @@ class SyncSetupFlow : public HtmlDialogUIDelegate { // Triggers a state machine transition to advance_state. void Advance(SyncSetupWizard::State advance_state); + // Focuses the dialog. This is useful in cases where the dialog has been + // obscured by a browser window. + void Focus(); + // HtmlDialogUIDelegate implementation. // Get the HTML file path for the content to load in the dialog. virtual GURL GetDialogContentURL() const { diff --git a/chrome/browser/sync/sync_setup_wizard.cc b/chrome/browser/sync/sync_setup_wizard.cc index 7b4d940..25b537b 100644 --- a/chrome/browser/sync/sync_setup_wizard.cc +++ b/chrome/browser/sync/sync_setup_wizard.cc @@ -212,6 +212,13 @@ bool SyncSetupWizard::IsVisible() const { return flow_container_->get_flow() != NULL; } +void SyncSetupWizard::Focus() { + SyncSetupFlow* flow = flow_container_->get_flow(); + if (flow) { + flow->Focus(); + } +} + // static SyncSetupWizard::State SyncSetupWizard::GetEndStateForDiscreteRun( State start_state) { diff --git a/chrome/browser/sync/sync_setup_wizard.h b/chrome/browser/sync/sync_setup_wizard.h index ad3c8e1..1e3c242 100644 --- a/chrome/browser/sync/sync_setup_wizard.h +++ b/chrome/browser/sync/sync_setup_wizard.h @@ -46,6 +46,10 @@ class SyncSetupWizard { // if various buttons in the UI should be enabled or disabled. bool IsVisible() const; + // Focus the dialog if it is already open. Does nothing if the dialog is + // not visible. + void Focus(); + private: // If we just need to pop open an individual dialog, say to collect // gaia credentials in the event of a steady-state auth failure, this is |