| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 5 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 class DefaultStateProvider : public WindowSizer::StateProvider { | 38 class DefaultStateProvider : public WindowSizer::StateProvider { |
| 39 public: | 39 public: |
| 40 DefaultStateProvider(const std::string& app_name, const Browser* browser) | 40 DefaultStateProvider(const std::string& app_name, const Browser* browser) |
| 41 : app_name_(app_name), browser_(browser) { | 41 : app_name_(app_name), browser_(browser) { |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Overridden from WindowSizer::StateProvider: | 44 // Overridden from WindowSizer::StateProvider: |
| 45 virtual bool GetPersistentState( | 45 virtual bool GetPersistentState( |
| 46 gfx::Rect* bounds, | 46 gfx::Rect* bounds, |
| 47 gfx::Rect* work_area, | 47 gfx::Rect* work_area, |
| 48 ui::WindowShowState* show_state) const OVERRIDE { | 48 ui::WindowShowState* show_state) const override { |
| 49 DCHECK(bounds); | 49 DCHECK(bounds); |
| 50 DCHECK(show_state); | 50 DCHECK(show_state); |
| 51 | 51 |
| 52 if (!browser_ || !browser_->profile()->GetPrefs()) | 52 if (!browser_ || !browser_->profile()->GetPrefs()) |
| 53 return false; | 53 return false; |
| 54 | 54 |
| 55 const base::DictionaryValue* wp_pref = | 55 const base::DictionaryValue* wp_pref = |
| 56 chrome::GetWindowPlacementDictionaryReadOnly( | 56 chrome::GetWindowPlacementDictionaryReadOnly( |
| 57 chrome::GetWindowName(browser_), browser_->profile()->GetPrefs()); | 57 chrome::GetWindowName(browser_), browser_->profile()->GetPrefs()); |
| 58 int top = 0, left = 0, bottom = 0, right = 0; | 58 int top = 0, left = 0, bottom = 0, right = 0; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 80 } | 80 } |
| 81 work_area->SetRect(work_area_left, work_area_top, | 81 work_area->SetRect(work_area_left, work_area_top, |
| 82 std::max(0, work_area_right - work_area_left), | 82 std::max(0, work_area_right - work_area_left), |
| 83 std::max(0, work_area_bottom - work_area_top)); | 83 std::max(0, work_area_bottom - work_area_top)); |
| 84 | 84 |
| 85 return has_prefs; | 85 return has_prefs; |
| 86 } | 86 } |
| 87 | 87 |
| 88 virtual bool GetLastActiveWindowState( | 88 virtual bool GetLastActiveWindowState( |
| 89 gfx::Rect* bounds, | 89 gfx::Rect* bounds, |
| 90 ui::WindowShowState* show_state) const OVERRIDE { | 90 ui::WindowShowState* show_state) const override { |
| 91 DCHECK(show_state); | 91 DCHECK(show_state); |
| 92 // Applications are always restored with the same position. | 92 // Applications are always restored with the same position. |
| 93 if (!app_name_.empty()) | 93 if (!app_name_.empty()) |
| 94 return false; | 94 return false; |
| 95 | 95 |
| 96 // If a reference browser is set, use its window. Otherwise find last | 96 // If a reference browser is set, use its window. Otherwise find last |
| 97 // active. Panels are never used as reference browsers as panels are | 97 // active. Panels are never used as reference browsers as panels are |
| 98 // specially positioned. | 98 // specially positioned. |
| 99 BrowserWindow* window = NULL; | 99 BrowserWindow* window = NULL; |
| 100 // Window may be null if browser is just starting up. | 100 // Window may be null if browser is just starting up. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 DISALLOW_COPY_AND_ASSIGN(DefaultStateProvider); | 138 DISALLOW_COPY_AND_ASSIGN(DefaultStateProvider); |
| 139 }; | 139 }; |
| 140 | 140 |
| 141 class DefaultTargetDisplayProvider : public WindowSizer::TargetDisplayProvider { | 141 class DefaultTargetDisplayProvider : public WindowSizer::TargetDisplayProvider { |
| 142 public: | 142 public: |
| 143 DefaultTargetDisplayProvider() {} | 143 DefaultTargetDisplayProvider() {} |
| 144 virtual ~DefaultTargetDisplayProvider() {} | 144 virtual ~DefaultTargetDisplayProvider() {} |
| 145 | 145 |
| 146 virtual gfx::Display GetTargetDisplay( | 146 virtual gfx::Display GetTargetDisplay( |
| 147 const gfx::Screen* screen, | 147 const gfx::Screen* screen, |
| 148 const gfx::Rect& bounds) const OVERRIDE { | 148 const gfx::Rect& bounds) const override { |
| 149 #if defined(USE_ASH) | 149 #if defined(USE_ASH) |
| 150 bool force_ash = false; | 150 bool force_ash = false; |
| 151 // On Windows check if the browser is launched to serve ASH. If yes then | 151 // On Windows check if the browser is launched to serve ASH. If yes then |
| 152 // we should get the display for the corresponding root window created for | 152 // we should get the display for the corresponding root window created for |
| 153 // ASH. This ensures that the display gets the correct workarea, etc. | 153 // ASH. This ensures that the display gets the correct workarea, etc. |
| 154 // If the ASH shell does not exist then the current behavior is to open | 154 // If the ASH shell does not exist then the current behavior is to open |
| 155 // browser windows if any on the desktop. Preserve that for now. | 155 // browser windows if any on the desktop. Preserve that for now. |
| 156 // TODO(ananta). | 156 // TODO(ananta). |
| 157 // This effectively means that the running browser process is in a split | 157 // This effectively means that the running browser process is in a split |
| 158 // personality mode, part of it running in ASH and the other running in | 158 // personality mode, part of it running in ASH and the other running in |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 | 436 |
| 437 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) | 437 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) |
| 438 return ui::SHOW_STATE_MAXIMIZED; | 438 return ui::SHOW_STATE_MAXIMIZED; |
| 439 | 439 |
| 440 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) | 440 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) |
| 441 return browser_->initial_show_state(); | 441 return browser_->initial_show_state(); |
| 442 | 442 |
| 443 // Otherwise we use the default which can be overridden later on. | 443 // Otherwise we use the default which can be overridden later on. |
| 444 return ui::SHOW_STATE_DEFAULT; | 444 return ui::SHOW_STATE_DEFAULT; |
| 445 } | 445 } |
| OLD | NEW |