OLD | NEW |
1 // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium OS 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 __PLATFORM_WINDOW_MANAGER_MOCK_CHROME_H__ | 5 #ifndef WINDOW_MANAGER_MOCK_CHROME_H_ |
6 #define __PLATFORM_WINDOW_MANAGER_MOCK_CHROME_H__ | 6 #define WINDOW_MANAGER_MOCK_CHROME_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 #include <tr1/memory> | 10 #include <tr1/memory> |
11 | 11 |
12 #include <gflags/gflags.h> | 12 #include <gflags/gflags.h> |
13 #include <gtkmm.h> | 13 #include <gtkmm.h> |
14 extern "C" { | 14 extern "C" { |
15 #include <gdk/gdkx.h> | 15 #include <gdk/gdkx.h> |
16 } | 16 } |
17 | 17 |
18 #include "base/basictypes.h" | 18 #include "base/basictypes.h" |
19 #include "base/scoped_ptr.h" | 19 #include "base/scoped_ptr.h" |
20 #include "window_manager/util.h" | 20 #include "window_manager/util.h" |
21 | 21 |
22 // This file implements a small app that displays windows containing Chrome | 22 // This file implements a small app that displays windows containing Chrome |
23 // screenshots and allows tabs to be dragged between them. Its intent is | 23 // screenshots and allows tabs to be dragged between them. Its intent is |
24 // to provide a way to quickly mock out different types of interactions | 24 // to provide a way to quickly mock out different types of interactions |
25 // between Chrome and the window manager. | 25 // between Chrome and the window manager. |
26 | 26 |
27 typedef ::Window XWindow; | 27 typedef ::Window XWindow; |
28 | 28 |
29 namespace chromeos { | 29 namespace window_manager { |
30 class AtomCache; | 30 class AtomCache; |
31 class WmIpc; | 31 class WmIpc; |
32 class XConnection; | 32 class XConnection; |
33 } | 33 } |
34 | 34 |
35 namespace mock_chrome { | 35 namespace mock_chrome { |
36 | 36 |
37 class ChromeWindow; | 37 class ChromeWindow; |
38 class MockChrome; | 38 class MockChrome; |
39 class Panel; | 39 class Panel; |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 bool expanded_; | 340 bool expanded_; |
341 std::string title_; | 341 std::string title_; |
342 | 342 |
343 DISALLOW_COPY_AND_ASSIGN(Panel); | 343 DISALLOW_COPY_AND_ASSIGN(Panel); |
344 }; | 344 }; |
345 | 345 |
346 class MockChrome { | 346 class MockChrome { |
347 public: | 347 public: |
348 MockChrome(); | 348 MockChrome(); |
349 | 349 |
350 chromeos::WmIpc* wm_ipc() { return wm_ipc_.get(); } | 350 window_manager::WmIpc* wm_ipc() { return wm_ipc_.get(); } |
351 | 351 |
352 // Create a new window, ownership of which remains with the MockChrome | 352 // Create a new window, ownership of which remains with the MockChrome |
353 // object. | 353 // object. |
354 ChromeWindow* CreateWindow(int width, int height); | 354 ChromeWindow* CreateWindow(int width, int height); |
355 | 355 |
356 // Close a window. | 356 // Close a window. |
357 void CloseWindow(ChromeWindow* win); | 357 void CloseWindow(ChromeWindow* win); |
358 | 358 |
359 // Create a new panel, ownership of which remains with the MockChrome | 359 // Create a new panel, ownership of which remains with the MockChrome |
360 // object. | 360 // object. |
361 Panel* CreatePanel(const std::string& image_filename, | 361 Panel* CreatePanel(const std::string& image_filename, |
362 const std::string &title); | 362 const std::string &title); |
363 | 363 |
364 // Close a panel. | 364 // Close a panel. |
365 void ClosePanel(Panel* panel); | 365 void ClosePanel(Panel* panel); |
366 | 366 |
367 // Handle a notification about a floating tab getting moved into or out | 367 // Handle a notification about a floating tab getting moved into or out |
368 // of a window. We track this so we'll know which window the tab is in | 368 // of a window. We track this so we'll know which window the tab is in |
369 // when it gets dropped. | 369 // when it gets dropped. |
370 void NotifyAboutFloatingTab( | 370 void NotifyAboutFloatingTab( |
371 XWindow tab_xid, ChromeWindow* win, bool entered); | 371 XWindow tab_xid, ChromeWindow* win, bool entered); |
372 | 372 |
373 // Deal with a dropped floating tab. Ownership of 'tab' is passed to | 373 // Deal with a dropped floating tab. Ownership of 'tab' is passed to |
374 // this method. | 374 // this method. |
375 void HandleDroppedFloatingTab(Tab* tab); | 375 void HandleDroppedFloatingTab(Tab* tab); |
376 | 376 |
377 private: | 377 private: |
378 scoped_ptr<chromeos::XConnection> xconn_; | 378 scoped_ptr<window_manager::XConnection> xconn_; |
379 scoped_ptr<chromeos::AtomCache> atom_cache_; | 379 scoped_ptr<window_manager::AtomCache> atom_cache_; |
380 scoped_ptr<chromeos::WmIpc> wm_ipc_; | 380 scoped_ptr<window_manager::WmIpc> wm_ipc_; |
381 | 381 |
382 typedef std::map<XWindow, std::tr1::shared_ptr<ChromeWindow> > ChromeWindows; | 382 typedef std::map<XWindow, std::tr1::shared_ptr<ChromeWindow> > ChromeWindows; |
383 ChromeWindows windows_; | 383 ChromeWindows windows_; |
384 | 384 |
385 // Map from the panel window's XID to the corresponding Panel object. | 385 // Map from the panel window's XID to the corresponding Panel object. |
386 typedef std::map<XWindow, std::tr1::shared_ptr<Panel> > Panels; | 386 typedef std::map<XWindow, std::tr1::shared_ptr<Panel> > Panels; |
387 Panels panels_; | 387 Panels panels_; |
388 | 388 |
389 // The window currently under the floating tab. | 389 // The window currently under the floating tab. |
390 ChromeWindow* window_under_floating_tab_; | 390 ChromeWindow* window_under_floating_tab_; |
391 | 391 |
392 DISALLOW_COPY_AND_ASSIGN(MockChrome); | 392 DISALLOW_COPY_AND_ASSIGN(MockChrome); |
393 }; | 393 }; |
394 | 394 |
395 } // namespace mock_chrome | 395 } // namespace mock_chrome |
396 | 396 |
397 #endif | 397 #endif |
OLD | NEW |