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

Side by Side Diff: chrome/browser/ui/views/dom_view.cc

Issue 10171006: Convert more users away from DOMView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | « chrome/browser/ui/views/dom_view.h ('k') | chrome/browser/ui/views/dom_view_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #include "chrome/browser/ui/views/dom_view.h"
6
7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/renderer_preferences_util.h"
9 #include "content/public/browser/site_instance.h"
10 #include "content/public/browser/web_contents.h"
11 #include "ui/views/focus/focus_manager.h"
12
13 using content::SiteInstance;
14 using content::WebContents;
15
16 // static
17 const char DOMView::kViewClassName[] =
18 "browser/ui/views/DOMView";
19
20 DOMView::DOMView() : initialized_(false) {
21 set_focusable(true);
22 }
23
24 DOMView::~DOMView() {
25 if (native_view())
26 Detach();
27 }
28
29 std::string DOMView::GetClassName() const {
30 return kViewClassName;
31 }
32
33 bool DOMView::Init(Profile* profile, SiteInstance* instance) {
34 if (initialized_)
35 return true;
36
37 initialized_ = true;
38 WebContents* web_contents = CreateTabContents(profile, instance);
39 dom_contents_.reset(new TabContentsWrapper(web_contents));
40
41 renderer_preferences_util::UpdateFromSystemSettings(
42 web_contents->GetMutableRendererPrefs(), profile);
43
44 // Attach the native_view now if the view is already added to Widget.
45 if (GetWidget())
46 AttachTabContents();
47
48 return true;
49 }
50
51 WebContents* DOMView::CreateTabContents(Profile* profile,
52 SiteInstance* instance) {
53 return WebContents::Create(profile, instance, MSG_ROUTING_NONE, NULL, NULL);
54 }
55
56 void DOMView::LoadURL(const GURL& url) {
57 DCHECK(initialized_);
58 dom_contents_->web_contents()->GetController().LoadURL(
59 url, content::Referrer(), content::PAGE_TRANSITION_START_PAGE,
60 std::string());
61 }
62
63 bool DOMView::SkipDefaultKeyEventProcessing(const views::KeyEvent& e) {
64 // Don't move the focus to the next view when tab is pressed, we want the
65 // key event to be propagated to the render view for doing the tab traversal
66 // there.
67 return views::FocusManager::IsTabTraversalKeyEvent(e);
68 }
69
70 void DOMView::OnFocus() {
71 dom_contents_->web_contents()->Focus();
72 }
73
74 void DOMView::ViewHierarchyChanged(bool is_add, views::View* parent,
75 views::View* child) {
76 // Attach the native_view when this is added to Widget if
77 // the native view has not been attached yet and tab_contents_ exists.
78 views::NativeViewHost::ViewHierarchyChanged(is_add, parent, child);
79 if (is_add && GetWidget() && !native_view() && dom_contents_.get())
80 AttachTabContents();
81 else if (!is_add && child == this && native_view())
82 Detach();
83 }
84
85 void DOMView::AttachTabContents() {
86 Attach(dom_contents_->web_contents()->GetNativeView());
87 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/dom_view.h ('k') | chrome/browser/ui/views/dom_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698