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

Side by Side Diff: ui/views/controls/webview/webview.cc

Issue 10181007: Revert 133490 - Make sure the WebContents has focus after being attached to a WebView, if that WebV… (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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium 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 #include "ui/views/controls/webview/webview.h" 5 #include "ui/views/controls/webview/webview.h"
6 6
7 #include "content/public/browser/browser_context.h" 7 #include "content/public/browser/browser_context.h"
8 #include "content/public/browser/navigation_controller.h" 8 #include "content/public/browser/navigation_controller.h"
9 #include "content/public/browser/notification_details.h" 9 #include "content/public/browser/notification_details.h"
10 #include "content/public/browser/notification_registrar.h" 10 #include "content/public/browser/notification_registrar.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 // Prevents attachment if the WebView isn't already in a Widget, or it's 173 // Prevents attachment if the WebView isn't already in a Widget, or it's
174 // already attached. 174 // already attached.
175 if (!GetWidget() || !web_contents_ || 175 if (!GetWidget() || !web_contents_ ||
176 wcv_holder_->native_view() == web_contents_->GetNativeView()) { 176 wcv_holder_->native_view() == web_contents_->GetNativeView()) {
177 return; 177 return;
178 } 178 }
179 179
180 if (web_contents_) { 180 if (web_contents_) {
181 wcv_holder_->Attach(web_contents_->GetNativeView()); 181 wcv_holder_->Attach(web_contents_->GetNativeView());
182 182
183 // The WebContentsView will not be focused automatically when it is
184 // attached, so we need to pass on focus to it if the FocusManager thinks
185 // the WebView is focused.
186 if (GetFocusManager()->GetFocusedView() == this)
187 web_contents_->Focus();
188
189 registrar_.Add( 183 registrar_.Add(
190 this, 184 this,
191 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, 185 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED,
192 content::Source<content::NavigationController>( 186 content::Source<content::NavigationController>(
193 &web_contents_->GetController())); 187 &web_contents_->GetController()));
194 registrar_.Add( 188 registrar_.Add(
195 this, 189 this,
196 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 190 content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
197 content::Source<content::WebContents>(web_contents_)); 191 content::Source<content::WebContents>(web_contents_));
198 } 192 }
(...skipping 18 matching lines...) Expand all
217 if (GetFocusManager()->GetFocusedView() == this) 211 if (GetFocusManager()->GetFocusedView() == this)
218 web_contents_->Focus(); 212 web_contents_->Focus();
219 } 213 }
220 214
221 void WebView::WebContentsDestroyed(content::WebContents* web_contents) { 215 void WebView::WebContentsDestroyed(content::WebContents* web_contents) {
222 DCHECK(web_contents == web_contents_); 216 DCHECK(web_contents == web_contents_);
223 SetWebContents(NULL); 217 SetWebContents(NULL);
224 } 218 }
225 219
226 } // namespace views 220 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698