| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // DOMView is a ChromeView that displays the content of a web DOM. | |
| 6 // It should be used with data: URLs. | |
| 7 | |
| 8 #ifndef CHROME_BROWSER_UI_VIEWS_DOM_VIEW_H_ | |
| 9 #define CHROME_BROWSER_UI_VIEWS_DOM_VIEW_H_ | |
| 10 #pragma once | |
| 11 | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | |
| 14 #include "googleurl/src/gurl.h" | |
| 15 #include "ui/views/controls/native/native_view_host.h" | |
| 16 #include "ui/views/events/event.h" | |
| 17 | |
| 18 class Profile; | |
| 19 | |
| 20 namespace content { | |
| 21 class SiteInstance; | |
| 22 }; | |
| 23 | |
| 24 class DOMView : public views::NativeViewHost { | |
| 25 public: | |
| 26 // Internal class name. | |
| 27 static const char kViewClassName[]; | |
| 28 | |
| 29 DOMView(); | |
| 30 virtual ~DOMView(); | |
| 31 | |
| 32 // Overridden from View. | |
| 33 virtual std::string GetClassName() const OVERRIDE; | |
| 34 | |
| 35 // Initialize the view, creating the contents. This should be | |
| 36 // called once the view has been added to a container. | |
| 37 // | |
| 38 // If |instance| is not null, then the view will be loaded in the same | |
| 39 // process as the given instance. | |
| 40 bool Init(Profile* profile, content::SiteInstance* instance); | |
| 41 | |
| 42 // Loads the given URL into the page. You must have previously called Init(). | |
| 43 void LoadURL(const GURL& url); | |
| 44 | |
| 45 // The TabContentsWrapper displaying the DOM contents; may be null. | |
| 46 TabContentsWrapper* dom_contents() const { return dom_contents_.get(); } | |
| 47 | |
| 48 protected: | |
| 49 // Overridden from View. | |
| 50 virtual bool SkipDefaultKeyEventProcessing(const views::KeyEvent& e) OVERRIDE; | |
| 51 virtual void OnFocus() OVERRIDE; | |
| 52 virtual void ViewHierarchyChanged(bool is_add, views::View* parent, | |
| 53 views::View* child) OVERRIDE; | |
| 54 | |
| 55 // AttachTabContents calls Attach to hook up the NativeViewHost. This is | |
| 56 // here because depending on whether this is a touch build or not the | |
| 57 // implementation varies slightly, while Detach is the same in both cases. | |
| 58 void AttachTabContents(); | |
| 59 | |
| 60 // Returns new allocated WebContents instance, caller is responsible deleting. | |
| 61 // Override in derived classes to replace WebContents with derivative. | |
| 62 virtual content::WebContents* CreateTabContents( | |
| 63 Profile* profile, content::SiteInstance* instance); | |
| 64 | |
| 65 scoped_ptr<TabContentsWrapper> dom_contents_; | |
| 66 | |
| 67 private: | |
| 68 bool initialized_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(DOMView); | |
| 71 }; | |
| 72 | |
| 73 #endif // CHROME_BROWSER_UI_VIEWS_DOM_VIEW_H_ | |
| OLD | NEW |