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 "apps/app_window_geometry_cache.h" | 5 #include "apps/app_window_geometry_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 143 |
144 prefs_->SetGeometryCache(extension_id, dict.Pass()); | 144 prefs_->SetGeometryCache(extension_id, dict.Pass()); |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 bool AppWindowGeometryCache::GetGeometry(const std::string& extension_id, | 148 bool AppWindowGeometryCache::GetGeometry(const std::string& extension_id, |
149 const std::string& window_id, | 149 const std::string& window_id, |
150 gfx::Rect* bounds, | 150 gfx::Rect* bounds, |
151 gfx::Rect* screen_bounds, | 151 gfx::Rect* screen_bounds, |
152 ui::WindowShowState* window_state) { | 152 ui::WindowShowState* window_state) { |
153 | |
154 std::map<std::string, ExtensionData>::const_iterator extension_data_it = | 153 std::map<std::string, ExtensionData>::const_iterator extension_data_it = |
155 cache_.find(extension_id); | 154 cache_.find(extension_id); |
156 | 155 |
157 // Not in the map means loading data for the extension didn't finish yet or | 156 // Not in the map means loading data for the extension didn't finish yet or |
158 // the cache was not constructed until after the extension was loaded. | 157 // the cache was not constructed until after the extension was loaded. |
159 // Attempt to load from sync to address the latter case. | 158 // Attempt to load from sync to address the latter case. |
160 if (extension_data_it == cache_.end()) { | 159 if (extension_data_it == cache_.end()) { |
161 LoadGeometryFromStorage(extension_id); | 160 LoadGeometryFromStorage(extension_id); |
162 extension_data_it = cache_.find(extension_id); | 161 extension_data_it = cache_.find(extension_id); |
163 DCHECK(extension_data_it != cache_.end()); | 162 DCHECK(extension_data_it != cache_.end()); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 | 325 |
327 void AppWindowGeometryCache::AddObserver(Observer* observer) { | 326 void AppWindowGeometryCache::AddObserver(Observer* observer) { |
328 observers_.AddObserver(observer); | 327 observers_.AddObserver(observer); |
329 } | 328 } |
330 | 329 |
331 void AppWindowGeometryCache::RemoveObserver(Observer* observer) { | 330 void AppWindowGeometryCache::RemoveObserver(Observer* observer) { |
332 observers_.RemoveObserver(observer); | 331 observers_.RemoveObserver(observer); |
333 } | 332 } |
334 | 333 |
335 } // namespace apps | 334 } // namespace apps |
OLD | NEW |