Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(522)

Unified Diff: chrome/browser/sessions/session_service.cc

Issue 11085053: Improving window auto management between workspaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed as requested. Corner cases will have to be addressed as they show Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/sessions/session_service.cc
diff --git a/chrome/browser/sessions/session_service.cc b/chrome/browser/sessions/session_service.cc
index 229b3607b6a877472e3ac35922c596aab23e7da8..e46b4107ab62b0947d70cb592fdddd004a865154 100644
--- a/chrome/browser/sessions/session_service.cc
+++ b/chrome/browser/sessions/session_service.cc
@@ -45,6 +45,10 @@
#include "chrome/browser/app_controller_mac.h"
#endif
+#if defined(USE_ASH)
+#include "ash/wm/window_util.h"
+#endif
+
using base::Time;
using content::NavigationEntry;
using content::WebContents;
@@ -77,6 +81,7 @@ static const SessionCommand::id_type kCommandWindowClosed = 17;
static const SessionCommand::id_type kCommandSetTabUserAgentOverride = 18;
static const SessionCommand::id_type kCommandSessionStorageAssociated = 19;
static const SessionCommand::id_type kCommandSetActiveWindow = 20;
+static const SessionCommand::id_type kCommandSetWindowBounds4 = 21;
// Every kWritesPerReset commands triggers recreating the file.
static const int kWritesPerReset = 250;
@@ -130,6 +135,16 @@ struct WindowBoundsPayload3 {
int32 show_state;
};
+struct WindowBoundsPayload4 {
+ SessionID::id_type window_id;
+ int32 x;
+ int32 y;
+ int32 w;
+ int32 h;
+ int32 show_state;
+ bool user_has_changed_window_or_position;
+};
+
typedef SessionID::id_type ActiveWindowPayload;
struct IDAndIndexPayload {
@@ -257,13 +272,18 @@ void SessionService::SetTabWindow(const SessionID& window_id,
ScheduleCommand(CreateSetTabWindowCommand(window_id, tab_id));
}
-void SessionService::SetWindowBounds(const SessionID& window_id,
- const gfx::Rect& bounds,
- ui::WindowShowState show_state) {
+void SessionService::SetWindowBounds(
+ const SessionID& window_id,
+ const gfx::Rect& bounds,
+ ui::WindowShowState show_state,
+ bool user_has_changed_window_or_position) {
if (!ShouldTrackChangesToWindow(window_id))
return;
-
- ScheduleCommand(CreateSetWindowBoundsCommand(window_id, bounds, show_state));
+ ScheduleCommand(CreateSetWindowBoundsCommand(
+ window_id,
+ bounds,
+ show_state,
+ user_has_changed_window_or_position));
}
void SessionService::SetTabIndexInWindow(const SessionID& window_id,
@@ -744,15 +764,18 @@ SessionCommand* SessionService::CreateSetTabWindowCommand(
SessionCommand* SessionService::CreateSetWindowBoundsCommand(
const SessionID& window_id,
const gfx::Rect& bounds,
- ui::WindowShowState show_state) {
- WindowBoundsPayload3 payload = { 0 };
+ ui::WindowShowState show_state,
+ bool user_has_changed_window_or_position) {
+ WindowBoundsPayload4 payload = { 0 };
payload.window_id = window_id.id();
payload.x = bounds.x();
payload.y = bounds.y();
payload.w = bounds.width();
payload.h = bounds.height();
payload.show_state = AdjustShowState(show_state);
- SessionCommand* command = new SessionCommand(kCommandSetWindowBounds3,
+ payload.user_has_changed_window_or_position =
+ user_has_changed_window_or_position;
+ SessionCommand* command = new SessionCommand(kCommandSetWindowBounds4,
sizeof(payload));
memcpy(command->contents(), &payload, sizeof(payload));
return command;
@@ -1086,6 +1109,32 @@ bool SessionService::CreateTabsAndWindows(
break;
}
+ case kCommandSetWindowBounds4: {
+ WindowBoundsPayload4 payload;
+ if (!command->GetPayload(&payload, sizeof(payload))) {
+ VLOG(1) << "Failed reading command " << command->id();
+ return true;
+ }
+ GetWindow(payload.window_id, windows)->bounds.SetRect(payload.x,
+ payload.y,
+ payload.w,
+ payload.h);
+ // SHOW_STATE_INACTIVE is not persisted.
+ ui::WindowShowState show_state = ui::SHOW_STATE_NORMAL;
+ if (payload.show_state > ui::SHOW_STATE_DEFAULT &&
+ payload.show_state < ui::SHOW_STATE_END &&
+ payload.show_state != ui::SHOW_STATE_INACTIVE) {
+ show_state = static_cast<ui::WindowShowState>(payload.show_state);
+ } else {
+ NOTREACHED();
+ }
+ GetWindow(payload.window_id, windows)->show_state = show_state;
+ GetWindow(payload.window_id,
+ windows)->user_has_changed_window_or_position =
+ payload.user_has_changed_window_or_position;
+ break;
+ }
+
case kCommandSetTabIndexInWindow: {
TabIndexInWindowPayload payload;
if (!command->GetPayload(&payload, sizeof(payload))) {
@@ -1374,10 +1423,17 @@ void SessionService::BuildCommandsForBrowser(
else if (browser->window()->IsMinimized())
show_state = ui::SHOW_STATE_MINIMIZED;
+ bool user_has_changed_window_or_position = false;
+#if defined(USE_ASH)
+ user_has_changed_window_or_position =
+ ash::wm::HasUserChangedWindowPositionOrSize(
+ browser->window()->GetNativeWindow());
+#endif
commands->push_back(
CreateSetWindowBoundsCommand(browser->session_id(),
browser->window()->GetRestoredBounds(),
- show_state));
+ show_state,
+ user_has_changed_window_or_position));
commands->push_back(CreateSetWindowTypeCommand(
browser->session_id(), WindowTypeForBrowserType(browser->type())));

Powered by Google App Engine
This is Rietveld 408576698