OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/app_window/app_window_geometry_cache.h" | 5 #include "extensions/browser/app_window/app_window_geometry_cache.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/memory/ptr_util.h" |
12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
13 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
14 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 15 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
15 #include "extensions/browser/extension_prefs.h" | 16 #include "extensions/browser/extension_prefs.h" |
16 #include "extensions/browser/extension_prefs_factory.h" | 17 #include "extensions/browser/extension_prefs_factory.h" |
17 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
18 #include "extensions/browser/extensions_browser_client.h" | 19 #include "extensions/browser/extensions_browser_client.h" |
19 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
20 | 21 |
21 namespace { | 22 namespace { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 it != eit; | 105 it != eit; |
105 ++it) { | 106 ++it) { |
106 const std::string& extension_id = *it; | 107 const std::string& extension_id = *it; |
107 const ExtensionData& extension_data = cache_[extension_id]; | 108 const ExtensionData& extension_data = cache_[extension_id]; |
108 | 109 |
109 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); | 110 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
110 for (ExtensionData::const_iterator it = extension_data.begin(), | 111 for (ExtensionData::const_iterator it = extension_data.begin(), |
111 eit = extension_data.end(); | 112 eit = extension_data.end(); |
112 it != eit; | 113 it != eit; |
113 ++it) { | 114 ++it) { |
114 base::DictionaryValue* value = new base::DictionaryValue; | 115 std::unique_ptr<base::DictionaryValue> value = |
| 116 base::MakeUnique<base::DictionaryValue>(); |
115 const gfx::Rect& bounds = it->second.bounds; | 117 const gfx::Rect& bounds = it->second.bounds; |
116 const gfx::Rect& screen_bounds = it->second.screen_bounds; | 118 const gfx::Rect& screen_bounds = it->second.screen_bounds; |
117 DCHECK(!bounds.IsEmpty()); | 119 DCHECK(!bounds.IsEmpty()); |
118 DCHECK(!screen_bounds.IsEmpty()); | 120 DCHECK(!screen_bounds.IsEmpty()); |
119 DCHECK(it->second.window_state != ui::SHOW_STATE_DEFAULT); | 121 DCHECK(it->second.window_state != ui::SHOW_STATE_DEFAULT); |
120 value->SetInteger("x", bounds.x()); | 122 value->SetInteger("x", bounds.x()); |
121 value->SetInteger("y", bounds.y()); | 123 value->SetInteger("y", bounds.y()); |
122 value->SetInteger("w", bounds.width()); | 124 value->SetInteger("w", bounds.width()); |
123 value->SetInteger("h", bounds.height()); | 125 value->SetInteger("h", bounds.height()); |
124 value->SetInteger("screen_bounds_x", screen_bounds.x()); | 126 value->SetInteger("screen_bounds_x", screen_bounds.x()); |
125 value->SetInteger("screen_bounds_y", screen_bounds.y()); | 127 value->SetInteger("screen_bounds_y", screen_bounds.y()); |
126 value->SetInteger("screen_bounds_w", screen_bounds.width()); | 128 value->SetInteger("screen_bounds_w", screen_bounds.width()); |
127 value->SetInteger("screen_bounds_h", screen_bounds.height()); | 129 value->SetInteger("screen_bounds_h", screen_bounds.height()); |
128 value->SetInteger("state", it->second.window_state); | 130 value->SetInteger("state", it->second.window_state); |
129 value->SetString( | 131 value->SetString( |
130 "ts", base::Int64ToString(it->second.last_change.ToInternalValue())); | 132 "ts", base::Int64ToString(it->second.last_change.ToInternalValue())); |
131 dict->SetWithoutPathExpansion(it->first, value); | 133 dict->SetWithoutPathExpansion(it->first, std::move(value)); |
132 | 134 |
133 FOR_EACH_OBSERVER( | 135 FOR_EACH_OBSERVER( |
134 Observer, | 136 Observer, |
135 observers_, | 137 observers_, |
136 OnGeometryCacheChanged(extension_id, it->first, bounds)); | 138 OnGeometryCacheChanged(extension_id, it->first, bounds)); |
137 } | 139 } |
138 | 140 |
139 prefs_->SetGeometryCache(extension_id, std::move(dict)); | 141 prefs_->SetGeometryCache(extension_id, std::move(dict)); |
140 } | 142 } |
141 } | 143 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 302 |
301 void AppWindowGeometryCache::AddObserver(Observer* observer) { | 303 void AppWindowGeometryCache::AddObserver(Observer* observer) { |
302 observers_.AddObserver(observer); | 304 observers_.AddObserver(observer); |
303 } | 305 } |
304 | 306 |
305 void AppWindowGeometryCache::RemoveObserver(Observer* observer) { | 307 void AppWindowGeometryCache::RemoveObserver(Observer* observer) { |
306 observers_.RemoveObserver(observer); | 308 observers_.RemoveObserver(observer); |
307 } | 309 } |
308 | 310 |
309 } // namespace extensions | 311 } // namespace extensions |
OLD | NEW |