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

Side by Side Diff: apps/shell_window_geometry_cache.h

Issue 17564005: Place newly created app windows on screen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment; Fix name of CallAdjust... Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | apps/shell_window_geometry_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_
6 #define CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_ 6 #define CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 62
63 virtual ~ShellWindowGeometryCache(); 63 virtual ~ShellWindowGeometryCache();
64 64
65 // Returns the instance for the given browsing context. 65 // Returns the instance for the given browsing context.
66 static ShellWindowGeometryCache* Get(content::BrowserContext* context); 66 static ShellWindowGeometryCache* Get(content::BrowserContext* context);
67 67
68 // Save the geometry and state associated with |extension_id| and |window_id|. 68 // Save the geometry and state associated with |extension_id| and |window_id|.
69 void SaveGeometry(const std::string& extension_id, 69 void SaveGeometry(const std::string& extension_id,
70 const std::string& window_id, 70 const std::string& window_id,
71 const gfx::Rect& bounds, 71 const gfx::Rect& bounds,
72 const gfx::Rect& screen_bounds,
72 ui::WindowShowState state); 73 ui::WindowShowState state);
73 74
74 // Get any saved geometry and state associated with |extension_id| and 75 // Get any saved geometry and state associated with |extension_id| and
75 // |window_id|. If saved data exists, sets |bounds| and |state| if not NULL 76 // |window_id|. If saved data exists, sets |bounds| and |state| if not NULL
76 // and returns true. 77 // and returns true.
77 bool GetGeometry(const std::string& extension_id, 78 bool GetGeometry(const std::string& extension_id,
78 const std::string& window_id, 79 const std::string& window_id,
79 gfx::Rect* bounds, 80 gfx::Rect* bounds,
81 gfx::Rect* screen_bounds,
80 ui::WindowShowState* state); 82 ui::WindowShowState* state);
81 83
82 // BrowserContextKeyedService 84 // BrowserContextKeyedService
83 virtual void Shutdown() OVERRIDE; 85 virtual void Shutdown() OVERRIDE;
84 86
85 // Maximum number of windows we'll cache the geometry for per app. 87 // Maximum number of windows we'll cache the geometry for per app.
86 static const size_t kMaxCachedWindows = 100; 88 static const size_t kMaxCachedWindows = 100;
87 89
88 protected: 90 protected:
89 friend class ShellWindowGeometryCacheTest; 91 friend class ShellWindowGeometryCacheTest;
90 92
91 // For tests, this modifies the timeout delay for saving changes from calls 93 // For tests, this modifies the timeout delay for saving changes from calls
92 // to SaveGeometry. (Note that even if this is set to 0, you still need to 94 // to SaveGeometry. (Note that even if this is set to 0, you still need to
93 // run the message loop to see the results of any SyncToStorage call). 95 // run the message loop to see the results of any SyncToStorage call).
94 void SetSyncDelayForTests(int timeout_ms); 96 void SetSyncDelayForTests(int timeout_ms);
95 97
96 private: 98 private:
97 // Data stored for each window. 99 // Data stored for each window.
98 struct WindowData { 100 struct WindowData {
99 WindowData() : window_state(ui::SHOW_STATE_DEFAULT) {} 101 WindowData();
102 ~WindowData();
100 gfx::Rect bounds; 103 gfx::Rect bounds;
104 gfx::Rect screen_bounds;
101 ui::WindowShowState window_state; 105 ui::WindowShowState window_state;
102 base::Time last_change; 106 base::Time last_change;
103 }; 107 };
104 108
105 // Data stored for each extension. 109 // Data stored for each extension.
106 typedef std::map<std::string, WindowData> ExtensionData; 110 typedef std::map<std::string, WindowData> ExtensionData;
107 111
108 // content::NotificationObserver 112 // content::NotificationObserver
109 virtual void Observe(int type, 113 virtual void Observe(int type,
110 const content::NotificationSource& source, 114 const content::NotificationSource& source,
(...skipping 17 matching lines...) Expand all
128 132
129 // The timeout value we'll use for |sync_timer_|. 133 // The timeout value we'll use for |sync_timer_|.
130 base::TimeDelta sync_delay_; 134 base::TimeDelta sync_delay_;
131 135
132 content::NotificationRegistrar registrar_; 136 content::NotificationRegistrar registrar_;
133 }; 137 };
134 138
135 } // namespace apps 139 } // namespace apps
136 140
137 #endif // CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_ 141 #endif // CHROME_BROWSER_EXTENSIONS_SHELL_WINDOW_GEOMETRY_CACHE_H_
OLDNEW
« no previous file with comments | « no previous file | apps/shell_window_geometry_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698