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

Side by Side Diff: chrome/browser/extensions/execute_code_in_tab_function.cc

Issue 1238001: Avoid calling ExecuteCode() on a NULL TabContents. The problem was an extra s... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fix indentation Created 10 years, 9 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/extensions/execute_code_in_tab_function.h" 5 #include "chrome/browser/extensions/execute_code_in_tab_function.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "chrome/browser/browser.h" 9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/extensions/extension_tabs_module.h" 10 #include "chrome/browser/extensions/extension_tabs_module.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 WideToUTF8(resource_.relative_path().value())); 121 WideToUTF8(resource_.relative_path().value()));
122 #endif // OS_WIN 122 #endif // OS_WIN
123 SendResponse(false); 123 SendResponse(false);
124 } 124 }
125 Release(); // Balance the AddRef taken in RunImpl 125 Release(); // Balance the AddRef taken in RunImpl
126 } 126 }
127 127
128 bool ExecuteCodeInTabFunction::Execute(const std::string& code_string) { 128 bool ExecuteCodeInTabFunction::Execute(const std::string& code_string) {
129 TabContents* contents = NULL; 129 TabContents* contents = NULL;
130 Browser* browser = NULL; 130 Browser* browser = NULL;
131 if (!ExtensionTabUtil::GetTabById(execute_tab_id_, profile(), 131
132 include_incognito(), &browser, NULL, 132 bool success = ExtensionTabUtil::GetTabById(
133 &contents, NULL) && contents && browser) { 133 execute_tab_id_, profile(), include_incognito(), &browser, NULL,
134 &contents, NULL) && contents && browser;
135
136 if (!success) {
134 SendResponse(false); 137 SendResponse(false);
135 return false; 138 return false;
136 } 139 }
137 140
138 Extension* extension = GetExtension(); 141 Extension* extension = GetExtension();
139 if (!extension) { 142 if (!extension) {
140 SendResponse(false); 143 SendResponse(false);
141 return false; 144 return false;
142 } 145 }
143 146
(...skipping 19 matching lines...) Expand all
163 void ExecuteCodeInTabFunction::Observe(NotificationType type, 166 void ExecuteCodeInTabFunction::Observe(NotificationType type,
164 const NotificationSource& source, 167 const NotificationSource& source,
165 const NotificationDetails& details) { 168 const NotificationDetails& details) {
166 std::pair<int, bool>* result_details = 169 std::pair<int, bool>* result_details =
167 Details<std::pair<int, bool> >(details).ptr(); 170 Details<std::pair<int, bool> >(details).ptr();
168 if (result_details->first == request_id()) { 171 if (result_details->first == request_id()) {
169 SendResponse(result_details->second); 172 SendResponse(result_details->second);
170 Release(); // balanced in Execute() 173 Release(); // balanced in Execute()
171 } 174 }
172 } 175 }
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