tree: 7e7d7ef719e17d483a77753416c5c7deec70daab [path history] [tgz]
  1. app_menu_button.cc
  2. app_menu_button.h
  3. app_menu_button_observer.h
  4. browser_caption_button_container_win.cc
  5. browser_caption_button_container_win.h
  6. browser_desktop_window_tree_host.h
  7. browser_desktop_window_tree_host_linux.cc
  8. browser_desktop_window_tree_host_linux.h
  9. browser_desktop_window_tree_host_win.cc
  10. browser_desktop_window_tree_host_win.h
  11. browser_frame_ash_browsertest.cc
  12. browser_frame_header_chromeos.cc
  13. browser_frame_header_chromeos.h
  14. browser_frame_view.cc
  15. browser_frame_view.h
  16. browser_frame_view_browsertest.cc
  17. browser_frame_view_browsertest_win.cc
  18. browser_frame_view_chromeos.cc
  19. browser_frame_view_chromeos.h
  20. browser_frame_view_chromeos_browsertest.cc
  21. browser_frame_view_factory_chromeos.cc
  22. browser_frame_view_factory_mac.mm
  23. browser_frame_view_factory_views.cc
  24. browser_frame_view_layout_linux.cc
  25. browser_frame_view_layout_linux.h
  26. browser_frame_view_layout_linux_native.cc
  27. browser_frame_view_layout_linux_native.h
  28. browser_frame_view_layout_linux_native_unittest.cc
  29. browser_frame_view_layout_linux_unittest.cc
  30. browser_frame_view_linux.cc
  31. browser_frame_view_linux.h
  32. browser_frame_view_linux_native.cc
  33. browser_frame_view_linux_native.h
  34. browser_frame_view_mac.h
  35. browser_frame_view_mac.mm
  36. browser_frame_view_mac_browsertest.mm
  37. browser_frame_view_mac_unittest.mm
  38. browser_frame_view_paint_utils_linux.cc
  39. browser_frame_view_paint_utils_linux.h
  40. browser_frame_view_unittest.cc
  41. browser_frame_view_win.cc
  42. browser_frame_view_win.h
  43. browser_native_widget.h
  44. browser_native_widget_ash.cc
  45. browser_native_widget_ash.h
  46. browser_native_widget_aura.cc
  47. browser_native_widget_aura.h
  48. browser_native_widget_aura_linux.cc
  49. browser_native_widget_aura_linux.h
  50. browser_native_widget_aura_linux_interactive_uitest.cc
  51. browser_native_widget_factory.cc
  52. browser_native_widget_factory.h
  53. browser_native_widget_factory_aura.cc
  54. browser_native_widget_factory_chromeos.cc
  55. browser_native_widget_factory_mac.mm
  56. browser_native_widget_mac.h
  57. browser_native_widget_mac.mm
  58. browser_root_view.cc
  59. browser_root_view.h
  60. browser_root_view_browsertest.cc
  61. browser_view.cc
  62. browser_view.h
  63. browser_view_ash.cc
  64. browser_view_ash.h
  65. browser_view_browsertest.cc
  66. browser_view_focus_uitest.cc
  67. browser_view_interactive_uitest.cc
  68. browser_view_layout.cc
  69. browser_view_layout.h
  70. browser_view_layout_delegate.h
  71. browser_view_layout_delegate_impl.cc
  72. browser_view_layout_delegate_impl.h
  73. browser_view_layout_delegate_impl_browsertest.cc
  74. browser_view_layout_unittest.cc
  75. browser_view_unittest.cc
  76. browser_widget.cc
  77. browser_widget.h
  78. browser_widget_browsertest.cc
  79. browser_window_factory.cc
  80. browser_window_property_manager_browsertest_win.cc
  81. browser_window_property_manager_win.cc
  82. browser_window_property_manager_win.h
  83. BUILD.gn
  84. caption_button_placeholder_container.cc
  85. caption_button_placeholder_container.h
  86. contents_border_controller.cc
  87. contents_border_controller.h
  88. contents_capture_border_view.cc
  89. contents_capture_border_view.h
  90. contents_container_outline.cc
  91. contents_container_outline.h
  92. contents_container_view.cc
  93. contents_container_view.h
  94. contents_layout_manager.cc
  95. contents_layout_manager.h
  96. contents_rounded_corner.cc
  97. contents_rounded_corner.h
  98. contents_separator.cc
  99. contents_separator.h
  100. contents_web_view.cc
  101. contents_web_view.h
  102. dbus_appmenu.cc
  103. dbus_appmenu.h
  104. dbus_appmenu_registrar.cc
  105. dbus_appmenu_registrar.h
  106. DEPS
  107. find_bar_owner_views.cc
  108. find_bar_owner_views.h
  109. immersive_mode_browser_view_test.cc
  110. immersive_mode_controller.cc
  111. immersive_mode_controller.h
  112. immersive_mode_controller_chromeos.cc
  113. immersive_mode_controller_chromeos.h
  114. immersive_mode_controller_chromeos_browsertest.cc
  115. immersive_mode_controller_chromeos_unittest.cc
  116. immersive_mode_controller_factory_views.cc
  117. immersive_mode_controller_mac.h
  118. immersive_mode_controller_mac.mm
  119. immersive_mode_controller_mac_interactive_uitest.mm
  120. immersive_mode_controller_stub.cc
  121. immersive_mode_controller_stub.h
  122. immersive_mode_tester.cc
  123. immersive_mode_tester.h
  124. minimize_button_metrics_win.cc
  125. minimize_button_metrics_win.h
  126. mock_immersive_mode_controller.cc
  127. mock_immersive_mode_controller.h
  128. multi_contents_background_view.cc
  129. multi_contents_background_view.h
  130. multi_contents_drop_target_view.cc
  131. multi_contents_drop_target_view.h
  132. multi_contents_drop_target_view_unittest.cc
  133. multi_contents_resize_area.cc
  134. multi_contents_resize_area.h
  135. multi_contents_view.cc
  136. multi_contents_view.h
  137. multi_contents_view_browsertest.cc
  138. multi_contents_view_delegate.cc
  139. multi_contents_view_delegate.h
  140. multi_contents_view_drop_target_controller.cc
  141. multi_contents_view_drop_target_controller.h
  142. multi_contents_view_drop_target_controller_browsertest.cc
  143. multi_contents_view_drop_target_controller_unittest.cc
  144. multi_contents_view_interactive_uitest.cc
  145. multi_contents_view_mini_toolbar.cc
  146. multi_contents_view_mini_toolbar.h
  147. multi_contents_view_tab_drag_interactive_uitest.cc
  148. opaque_browser_frame_view.cc
  149. opaque_browser_frame_view.h
  150. opaque_browser_frame_view_browsertest.cc
  151. opaque_browser_frame_view_layout.cc
  152. opaque_browser_frame_view_layout.h
  153. opaque_browser_frame_view_layout_delegate.cc
  154. opaque_browser_frame_view_layout_delegate.h
  155. opaque_browser_frame_view_layout_unittest.cc
  156. OWNERS
  157. picture_in_picture_browser_frame_view.cc
  158. picture_in_picture_browser_frame_view.h
  159. picture_in_picture_browser_frame_view_ash.cc
  160. picture_in_picture_browser_frame_view_ash.h
  161. picture_in_picture_browser_frame_view_interactive_uitest.cc
  162. picture_in_picture_browser_frame_view_linux.cc
  163. picture_in_picture_browser_frame_view_linux.h
  164. README.md
  165. scrim_view.cc
  166. scrim_view.h
  167. scrim_view_controller.cc
  168. scrim_view_controller.h
  169. system_menu_insertion_delegate_win.cc
  170. system_menu_insertion_delegate_win.h
  171. system_menu_model_builder.cc
  172. system_menu_model_builder.h
  173. system_menu_model_builder_browsertest.cc
  174. system_menu_model_builder_browsertest_chromeos.cc
  175. system_menu_model_delegate.cc
  176. system_menu_model_delegate.h
  177. system_web_app_frame_view_browsertest.cc
  178. tab_modal_dialog_host.cc
  179. tab_modal_dialog_host.h
  180. tab_strip_region_view.cc
  181. tab_strip_region_view.h
  182. tab_strip_region_view_browsertest.cc
  183. tab_strip_region_view_interactive_uitest.cc
  184. tab_strip_view_interface.h
  185. test_with_browser_view.cc
  186. test_with_browser_view.h
  187. toolbar_button_provider.h
  188. top_container_background.cc
  189. top_container_background.h
  190. top_container_loading_bar.cc
  191. top_container_loading_bar.h
  192. top_container_view.cc
  193. top_container_view.h
  194. top_controls_slide_controller.h
  195. top_controls_slide_controller_chromeos.cc
  196. top_controls_slide_controller_chromeos.h
  197. top_controls_slide_controller_chromeos_browsertest.cc
  198. vertical_tab_strip_region_view.cc
  199. vertical_tab_strip_region_view.h
  200. vertical_tab_strip_region_view_browsertest.cc
  201. web_contents_close_handler.cc
  202. web_contents_close_handler.h
  203. web_contents_close_handler_delegate.h
  204. web_contents_close_handler_unittest.cc
  205. webui_tab_strip_container_view.cc
  206. webui_tab_strip_container_view.h
  207. webui_tab_strip_container_view_browsertest.cc
  208. webui_tab_strip_field_trial.cc
  209. webui_tab_strip_field_trial.h
  210. webui_tab_strip_field_trial_browsertest.cc
  211. webui_tab_strip_interactive_uitest.cc
  212. windows_caption_button.cc
  213. windows_caption_button.h
  214. windows_caption_button_unittest.cc
  215. windows_icon_painter.cc
  216. windows_icon_painter.h
  217. windows_taskbar_icon_updater.cc
  218. windows_taskbar_icon_updater.h
chrome/browser/ui/views/frame/README.md

Browser Window Explainer

Each browser window has the same structure, depicted below:

  • BrowserWidget - The widget hosting the browser window. This should only provide general widget-y information.
    • BrowserNativeWidget - Provides platform-specific browser behavior. Every implementation of this interface is also a NativeWidget.
    • NonClientView - Standard non-client view for processing events, etc.
      • BrowserFrameView - Provides information about the frame around the browser content, including border and layout information, caption buttons, window icon, title, etc. Implementation may be dependent on both browser type and platform.
        • BrowserView - The browser itself.
          • BrowserViewLayout - Responsible for laying out the browser. Only knows about BrowserViewLayoutDelegate.
            • BrowserViewLayoutDelegate - Conduit through which the BrowserViewLayout retrieves information about the layout. Implemented by BrowserView; designed to be able to be mocked.

Diagram

┌─────────────────────────────────────┐   ┌───────────────────────┐
│ BrowserWidget                       │ ↔ │ BrowserNativeWidget + │
│ ┌─────────────────────────────────┐ │   │ NativeWidget          │
│ │ RootView                        │ │   └───────────────────────┘
│ │ ┌─────────────────────────────┐ │ │
│ │ │ NonClientView               │ │ │
│ │ │ ┌─────────────────────────┐ │ │ │
│ │ │ │ BrowserFrameView        | │ │ │
│ │ │ │ ┌─────────────────────┐ │ │ │ │
│ │ │ │ │ BrowserView         │ │ │ │ │
│ │ │ │ │ (ClientView)        │ │ │ │ │
│ │ │ │ │                     │ │ │ │ │
│ │ │ │ └─────────────────────┘ │ │ │ │
│ │ │ └─────────────────────────┘ │ │ │
│ │ └─────────────────────────────┘ │ │
│ └─────────────────────────────────┘ │
└─────────────────────────────────────┘

Usage and Implementation Notes

Where do specific functions go?

If you're not sure where some piece of functionality goes:

  • Anything relating to the content of the browser window goes in BrowserView.

    • Unless it's general layout-related logic, in which case it goes in BrowserViewLayout.
  • Anything relating to the frame and titlebar of the browser window goes in BrowserFrameView, including but not limited to:

    • Border
    • Shadow
    • App icon
    • Title
    • Caption buttons
    • Where the client area or can and cannot lay itself out
    • Hit-testing
    • Platform-specific information relating to any of the above (implemented in platform-specific subclasses)
  • Any information or features of the whole window that are platform-specific go in BrowserNativeWidget and are implemented in its platform-specific subclasses.

  • Any views::Widget-specific stuff, like window event handling, goes in BrowserWidget

    • But note that platform-specific logic can be handed off to BrowserNativeWidget.

Platform-agnostic vs. platform-specific logic

Cross-desktop-platform code should have access to BrowserView, BrowserWidget, BrowserFrameView, and BrowserNativeWidget. Therefore it is not necessary to pipe calls through another class if the class that actually has the method in question is available.

(The one exception is BrowserViewLayout, which has access only to BrowserViewLayoutDelegate, so calls must be piped through that class.)

Platform-specific logic should be behind a platform-agnostic API when possible, and if it actually applies to multiple platforms. If there is a logic path that only applies to one platform, try to encapsulate it in a platform-specific implementation; if it absolutely must be referenced outside of that implementation, place any required references in #if BUILDFLAG() blocks.

For example, BrowserFrameView::CaptionButtonsOnLeadingEdge() is a general question one might ask about any browser frame - “are the caption buttons on the leading (vs. trailing) edge of the window?” since caption buttons are present on every desktop platform, and it is used in cross-platform code. Therefore it goes in BrowserFrameView, and should be called directly if that information is needed.

On the other hand, GetMinimizeButtonOffset() lives in BrowserFrameViewWin not because it‘s a question that could be asked about any browser, but is only ever actually used on Windows. It’s an implementation detail that doesn't need to be in the general interface.