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

Side by Side Diff: chrome/browser/ui/window_sizer/window_sizer.cc

Issue 671653002: Standardize usage of virtual/override/final in chrome/browser/ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 unified diff | Download patch
OLDNEW
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 24 matching lines...) Expand all
35 /////////////////////////////////////////////////////////////////////////////// 35 ///////////////////////////////////////////////////////////////////////////////
36 // An implementation of WindowSizer::StateProvider that gets the last active 36 // An implementation of WindowSizer::StateProvider that gets the last active
37 // and persistent state from the browser window and the user's profile. 37 // and persistent state from the browser window and the user's profile.
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 bool GetPersistentState(gfx::Rect* bounds,
46 gfx::Rect* bounds, 46 gfx::Rect* work_area,
47 gfx::Rect* work_area, 47 ui::WindowShowState* show_state) const override {
48 ui::WindowShowState* show_state) const override {
49 DCHECK(bounds); 48 DCHECK(bounds);
50 DCHECK(show_state); 49 DCHECK(show_state);
51 50
52 if (!browser_ || !browser_->profile()->GetPrefs()) 51 if (!browser_ || !browser_->profile()->GetPrefs())
53 return false; 52 return false;
54 53
55 const base::DictionaryValue* wp_pref = 54 const base::DictionaryValue* wp_pref =
56 chrome::GetWindowPlacementDictionaryReadOnly( 55 chrome::GetWindowPlacementDictionaryReadOnly(
57 chrome::GetWindowName(browser_), browser_->profile()->GetPrefs()); 56 chrome::GetWindowName(browser_), browser_->profile()->GetPrefs());
58 int top = 0, left = 0, bottom = 0, right = 0; 57 int top = 0, left = 0, bottom = 0, right = 0;
(...skipping 19 matching lines...) Expand all
78 if (*show_state == ui::SHOW_STATE_DEFAULT && maximized) 77 if (*show_state == ui::SHOW_STATE_DEFAULT && maximized)
79 *show_state = ui::SHOW_STATE_MAXIMIZED; 78 *show_state = ui::SHOW_STATE_MAXIMIZED;
80 } 79 }
81 work_area->SetRect(work_area_left, work_area_top, 80 work_area->SetRect(work_area_left, work_area_top,
82 std::max(0, work_area_right - work_area_left), 81 std::max(0, work_area_right - work_area_left),
83 std::max(0, work_area_bottom - work_area_top)); 82 std::max(0, work_area_bottom - work_area_top));
84 83
85 return has_prefs; 84 return has_prefs;
86 } 85 }
87 86
88 virtual bool GetLastActiveWindowState( 87 bool GetLastActiveWindowState(
89 gfx::Rect* bounds, 88 gfx::Rect* bounds,
90 ui::WindowShowState* show_state) const override { 89 ui::WindowShowState* show_state) const override {
91 DCHECK(show_state); 90 DCHECK(show_state);
92 // Applications are always restored with the same position. 91 // Applications are always restored with the same position.
93 if (!app_name_.empty()) 92 if (!app_name_.empty())
94 return false; 93 return false;
95 94
96 // If a reference browser is set, use its window. Otherwise find last 95 // If a reference browser is set, use its window. Otherwise find last
97 // active. Panels are never used as reference browsers as panels are 96 // active. Panels are never used as reference browsers as panels are
98 // specially positioned. 97 // specially positioned.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 std::string app_name_; 133 std::string app_name_;
135 134
136 // If set, is used as the reference browser for GetLastActiveWindowState. 135 // If set, is used as the reference browser for GetLastActiveWindowState.
137 const Browser* browser_; 136 const Browser* browser_;
138 DISALLOW_COPY_AND_ASSIGN(DefaultStateProvider); 137 DISALLOW_COPY_AND_ASSIGN(DefaultStateProvider);
139 }; 138 };
140 139
141 class DefaultTargetDisplayProvider : public WindowSizer::TargetDisplayProvider { 140 class DefaultTargetDisplayProvider : public WindowSizer::TargetDisplayProvider {
142 public: 141 public:
143 DefaultTargetDisplayProvider() {} 142 DefaultTargetDisplayProvider() {}
144 virtual ~DefaultTargetDisplayProvider() {} 143 ~DefaultTargetDisplayProvider() override {}
145 144
146 virtual gfx::Display GetTargetDisplay( 145 gfx::Display GetTargetDisplay(const gfx::Screen* screen,
147 const gfx::Screen* screen, 146 const gfx::Rect& bounds) const override {
148 const gfx::Rect& bounds) const override {
149 #if defined(USE_ASH) 147 #if defined(USE_ASH)
150 bool force_ash = false; 148 bool force_ash = false;
151 // On Windows check if the browser is launched to serve ASH. If yes then 149 // 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 150 // we should get the display for the corresponding root window created for
153 // ASH. This ensures that the display gets the correct workarea, etc. 151 // 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 152 // 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. 153 // browser windows if any on the desktop. Preserve that for now.
156 // TODO(ananta). 154 // TODO(ananta).
157 // This effectively means that the running browser process is in a split 155 // 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 156 // 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
436 434
437 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized)) 435 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kStartMaximized))
438 return ui::SHOW_STATE_MAXIMIZED; 436 return ui::SHOW_STATE_MAXIMIZED;
439 437
440 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT) 438 if (browser_->initial_show_state() != ui::SHOW_STATE_DEFAULT)
441 return browser_->initial_show_state(); 439 return browser_->initial_show_state();
442 440
443 // Otherwise we use the default which can be overridden later on. 441 // Otherwise we use the default which can be overridden later on.
444 return ui::SHOW_STATE_DEFAULT; 442 return ui::SHOW_STATE_DEFAULT;
445 } 443 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698