| 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 <utility> |
| 10 |
| 9 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 12 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 12 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 13 #include "chrome/browser/defaults.h" | 15 #include "chrome/browser/defaults.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/sessions/session_service.h" | 17 #include "chrome/browser/sessions/session_service.h" |
| 16 #include "chrome/browser/sessions/session_service_factory.h" | 18 #include "chrome/browser/sessions/session_service_factory.h" |
| 17 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 18 #include "chrome/browser/ui/window_sizer/window_sizer.h" | 20 #include "chrome/browser/ui/window_sizer/window_sizer.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 49 public: | 51 public: |
| 50 WindowPlacementPrefUpdate(PrefService* service, | 52 WindowPlacementPrefUpdate(PrefService* service, |
| 51 const std::string& window_name) | 53 const std::string& window_name) |
| 52 : DictionaryPrefUpdate(service, prefs::kAppWindowPlacement), | 54 : DictionaryPrefUpdate(service, prefs::kAppWindowPlacement), |
| 53 window_name_(window_name) {} | 55 window_name_(window_name) {} |
| 54 | 56 |
| 55 ~WindowPlacementPrefUpdate() override {} | 57 ~WindowPlacementPrefUpdate() override {} |
| 56 | 58 |
| 57 base::DictionaryValue* Get() override { | 59 base::DictionaryValue* Get() override { |
| 58 base::DictionaryValue* all_apps_dict = DictionaryPrefUpdate::Get(); | 60 base::DictionaryValue* all_apps_dict = DictionaryPrefUpdate::Get(); |
| 59 base::DictionaryValue* this_app_dict = NULL; | 61 base::DictionaryValue* this_app_dict_weak = NULL; |
| 60 if (!all_apps_dict->GetDictionary(window_name_, &this_app_dict)) { | 62 if (!all_apps_dict->GetDictionary(window_name_, &this_app_dict_weak)) { |
| 61 this_app_dict = new base::DictionaryValue; | 63 auto this_app_dict = base::MakeUnique<base::DictionaryValue>(); |
| 62 all_apps_dict->Set(window_name_, this_app_dict); | 64 this_app_dict_weak = this_app_dict.get(); |
| 65 all_apps_dict->Set(window_name_, std::move(this_app_dict)); |
| 63 } | 66 } |
| 64 return this_app_dict; | 67 return this_app_dict_weak; |
| 65 } | 68 } |
| 66 | 69 |
| 67 private: | 70 private: |
| 68 const std::string window_name_; | 71 const std::string window_name_; |
| 69 | 72 |
| 70 DISALLOW_COPY_AND_ASSIGN(WindowPlacementPrefUpdate); | 73 DISALLOW_COPY_AND_ASSIGN(WindowPlacementPrefUpdate); |
| 71 }; | 74 }; |
| 72 | 75 |
| 73 } // namespace | 76 } // namespace |
| 74 | 77 |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (parsed_command_line.HasSwitch(switches::kWindowPosition)) { | 171 if (parsed_command_line.HasSwitch(switches::kWindowPosition)) { |
| 169 std::string str = | 172 std::string str = |
| 170 parsed_command_line.GetSwitchValueASCII(switches::kWindowPosition); | 173 parsed_command_line.GetSwitchValueASCII(switches::kWindowPosition); |
| 171 int x, y; | 174 int x, y; |
| 172 if (ParseCommaSeparatedIntegers(str, &x, &y)) | 175 if (ParseCommaSeparatedIntegers(str, &x, &y)) |
| 173 bounds->set_origin(gfx::Point(x, y)); | 176 bounds->set_origin(gfx::Point(x, y)); |
| 174 } | 177 } |
| 175 } | 178 } |
| 176 | 179 |
| 177 } // namespace chrome | 180 } // namespace chrome |
| OLD | NEW |