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

Side by Side Diff: chrome/browser/ui/webui/constrained_web_dialog_ui.cc

Issue 2798583002: WebUI: prevent WebContent to hold invalid pointer. (Closed)
Patch Set: Remove reference to |this| when the WebContent is no more owned. Created 3 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
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 "chrome/browser/ui/webui/constrained_web_dialog_ui.h" 5 #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 // static 103 // static
104 void ConstrainedWebDialogUI::SetConstrainedDelegate( 104 void ConstrainedWebDialogUI::SetConstrainedDelegate(
105 content::WebContents* web_contents, 105 content::WebContents* web_contents,
106 ConstrainedWebDialogDelegate* delegate) { 106 ConstrainedWebDialogDelegate* delegate) {
107 web_contents->SetUserData(&kConstrainedWebDialogDelegateUserDataKey, 107 web_contents->SetUserData(&kConstrainedWebDialogDelegateUserDataKey,
108 new ConstrainedWebDialogDelegateUserData(delegate)); 108 new ConstrainedWebDialogDelegateUserData(delegate));
109 } 109 }
110 110
111 // static
112 void ConstrainedWebDialogUI::ClearConstrainedDelegate(
113 content::WebContents* web_contents) {
114 web_contents->RemoveUserData(&kConstrainedWebDialogDelegateUserDataKey);
115 }
116
111 ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() { 117 ConstrainedWebDialogDelegate* ConstrainedWebDialogUI::GetConstrainedDelegate() {
112 ConstrainedWebDialogDelegateUserData* user_data = 118 ConstrainedWebDialogDelegateUserData* user_data =
113 static_cast<ConstrainedWebDialogDelegateUserData*>( 119 static_cast<ConstrainedWebDialogDelegateUserData*>(
114 web_ui()->GetWebContents()-> 120 web_ui()->GetWebContents()->
Lei Zhang 2017/04/06 09:12:54 Another idea is for ConstrainedWebDialogUI to be a
115 GetUserData(&kConstrainedWebDialogDelegateUserDataKey)); 121 GetUserData(&kConstrainedWebDialogDelegateUserDataKey));
116 122
117 return user_data ? user_data->delegate() : NULL; 123 return user_data ? user_data->delegate() : NULL;
118 } 124 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698