| 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/browser_window_state.h" | 5 #include "chrome/browser/ui/browser_window_state.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "chrome/browser/defaults.h" | 13 #include "chrome/browser/defaults.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/sessions/session_service.h" | 15 #include "chrome/browser/sessions/session_service.h" |
| 15 #include "chrome/browser/sessions/session_service_factory.h" | 16 #include "chrome/browser/sessions/session_service_factory.h" |
| 16 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 18 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| 18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 20 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } // namespace | 73 } // namespace |
| 73 | 74 |
| 74 std::string GetWindowName(const Browser* browser) { | 75 std::string GetWindowName(const Browser* browser) { |
| 75 if (browser->app_name().empty()) { | 76 if (browser->app_name().empty()) { |
| 76 return browser->is_type_popup() ? | 77 return browser->is_type_popup() ? |
| 77 prefs::kBrowserWindowPlacementPopup : prefs::kBrowserWindowPlacement; | 78 prefs::kBrowserWindowPlacementPopup : prefs::kBrowserWindowPlacement; |
| 78 } | 79 } |
| 79 return browser->app_name(); | 80 return browser->app_name(); |
| 80 } | 81 } |
| 81 | 82 |
| 82 scoped_ptr<DictionaryPrefUpdate> GetWindowPlacementDictionaryReadWrite( | 83 std::unique_ptr<DictionaryPrefUpdate> GetWindowPlacementDictionaryReadWrite( |
| 83 const std::string& window_name, | 84 const std::string& window_name, |
| 84 PrefService* prefs) { | 85 PrefService* prefs) { |
| 85 DCHECK(!window_name.empty()); | 86 DCHECK(!window_name.empty()); |
| 86 // A normal DictionaryPrefUpdate will suffice for non-app windows. | 87 // A normal DictionaryPrefUpdate will suffice for non-app windows. |
| 87 if (prefs->FindPreference(window_name.c_str())) { | 88 if (prefs->FindPreference(window_name.c_str())) { |
| 88 return make_scoped_ptr( | 89 return base::WrapUnique( |
| 89 new DictionaryPrefUpdate(prefs, window_name.c_str())); | 90 new DictionaryPrefUpdate(prefs, window_name.c_str())); |
| 90 } | 91 } |
| 91 return scoped_ptr<DictionaryPrefUpdate>( | 92 return std::unique_ptr<DictionaryPrefUpdate>( |
| 92 new WindowPlacementPrefUpdate(prefs, window_name)); | 93 new WindowPlacementPrefUpdate(prefs, window_name)); |
| 93 } | 94 } |
| 94 | 95 |
| 95 const base::DictionaryValue* GetWindowPlacementDictionaryReadOnly( | 96 const base::DictionaryValue* GetWindowPlacementDictionaryReadOnly( |
| 96 const std::string& window_name, | 97 const std::string& window_name, |
| 97 PrefService* prefs) { | 98 PrefService* prefs) { |
| 98 DCHECK(!window_name.empty()); | 99 DCHECK(!window_name.empty()); |
| 99 if (prefs->FindPreference(window_name.c_str())) | 100 if (prefs->FindPreference(window_name.c_str())) |
| 100 return prefs->GetDictionary(window_name.c_str()); | 101 return prefs->GetDictionary(window_name.c_str()); |
| 101 | 102 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 if (parsed_command_line.HasSwitch(switches::kWindowPosition)) { | 162 if (parsed_command_line.HasSwitch(switches::kWindowPosition)) { |
| 162 std::string str = | 163 std::string str = |
| 163 parsed_command_line.GetSwitchValueASCII(switches::kWindowPosition); | 164 parsed_command_line.GetSwitchValueASCII(switches::kWindowPosition); |
| 164 int x, y; | 165 int x, y; |
| 165 if (ParseCommaSeparatedIntegers(str, &x, &y)) | 166 if (ParseCommaSeparatedIntegers(str, &x, &y)) |
| 166 bounds->set_origin(gfx::Point(x, y)); | 167 bounds->set_origin(gfx::Point(x, y)); |
| 167 } | 168 } |
| 168 } | 169 } |
| 169 | 170 |
| 170 } // namespace chrome | 171 } // namespace chrome |
| OLD | NEW |