1 // Copyright 2016 The Chromium Embedded Framework Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be found 3 // in the LICENSE file. 4 5 #ifndef CEF_LIBCEF_BROWSER_VIEWS_VIEW_ADAPTER_H_ 6 #define CEF_LIBCEF_BROWSER_VIEWS_VIEW_ADAPTER_H_ 7 #pragma once 8 9 #include "include/views/cef_view.h" 10 11 namespace base { 12 class DictionaryValue; 13 } 14 15 namespace views { 16 class View; 17 } 18 19 // Exposes a common interface from all CefView implementation objects to 20 // simplify the view_util implementation. See comments in view_impl.h for a 21 // usage overview. 22 class CefViewAdapter { 23 public: CefViewAdapter()24 CefViewAdapter() {} 25 26 // Returns the CefViewAdapter for the specified |view|. 27 static CefViewAdapter* GetFor(CefRefPtr<CefView> view); 28 static CefViewAdapter* GetFor(views::View* view); 29 30 // Returns the underlying views::View object. Does not transfer ownership. 31 virtual views::View* Get() const = 0; 32 33 // Pass ownership of the underlying views::View object to the caller. This 34 // object keeps an unowned reference to the views::View object. This is called 35 // when the views::View is parented to another views::View. 36 virtual std::unique_ptr<views::View> PassOwnership() = 0; 37 38 // Resume ownership of the underlying views::View object. This is called when 39 // the views::View is no longer parented to another views::View. 40 virtual void ResumeOwnership() = 0; 41 42 // Release all references to the views::View object. This is called when the 43 // views::View is deleted after being parented to another views::View. 44 virtual void Detach() = 0; 45 46 // Override this method to provide a string representation of the View type. 47 // Only implement this method in concrete classes. 48 virtual std::string GetDebugType() = 0; 49 50 // Override this method to provide debug info specific to the View type. 51 virtual void GetDebugInfo(base::DictionaryValue* info, 52 bool include_children) = 0; 53 54 protected: ~CefViewAdapter()55 virtual ~CefViewAdapter() {} 56 }; 57 58 #endif // CEF_LIBCEF_BROWSER_VIEWS_VIEW_ADAPTER_H_ 59