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

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

Issue 10826141: Formalise a CHECK for the NULL NavigationEntry in ScriptBadgeController, and (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add URL parameter Created 8 years, 4 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/extensions/api/tabs/execute_code_in_tab_function.h" 5 #include "chrome/browser/extensions/api/tabs/execute_code_in_tab_function.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/api/tabs/tabs.h" 10 #include "chrome/browser/extensions/api/tabs/tabs.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 return false; 93 return false;
94 } 94 }
95 95
96 scoped_refptr<FileReader> file_reader(new FileReader( 96 scoped_refptr<FileReader> file_reader(new FileReader(
97 resource_, base::Bind(&ExecuteCodeInTabFunction::DidLoadFile, this))); 97 resource_, base::Bind(&ExecuteCodeInTabFunction::DidLoadFile, this)));
98 file_reader->Start(); 98 file_reader->Start();
99 99
100 return true; 100 return true;
101 } 101 }
102 102
103 void ExecuteCodeInTabFunction::OnExecuteCodeFinished(bool success, 103 void ExecuteCodeInTabFunction::OnExecuteCodeFinished(const std::string& error,
104 int32 page_id, 104 int32 on_page_id,
105 const std::string& error, 105 const GURL& on_url,
106 const ListValue& result) { 106 const ListValue& result) {
107 if (!error.empty()) { 107 if (!error.empty())
108 CHECK(!success);
109 SetError(error); 108 SetError(error);
110 }
111 109
112 SendResponse(success); 110 SendResponse(error.empty());
113 } 111 }
114 112
115 void TabsExecuteScriptFunction::OnExecuteCodeFinished(bool success, 113 void TabsExecuteScriptFunction::OnExecuteCodeFinished(const std::string& error,
116 int32 page_id, 114 int32 on_page_id,
117 const std::string& error, 115 const GURL& on_url,
118 const ListValue& result) { 116 const ListValue& result) {
119 if (error.empty()) 117 if (error.empty())
120 SetResult(result.DeepCopy()); 118 SetResult(result.DeepCopy());
121 ExecuteCodeInTabFunction::OnExecuteCodeFinished(success, page_id, error, 119 ExecuteCodeInTabFunction::OnExecuteCodeFinished(error, on_page_id, on_url,
122 result); 120 result);
123 } 121 }
124 122
125 bool ExecuteCodeInTabFunction::Init() { 123 bool ExecuteCodeInTabFunction::Init() {
126 if (details_.get()) 124 if (details_.get())
127 return true; 125 return true;
128 126
129 // |tab_id| is optional so it's ok if it's not there. 127 // |tab_id| is optional so it's ok if it's not there.
130 int tab_id = -1; 128 int tab_id = -1;
131 args_->GetInteger(0, &tab_id); 129 args_->GetInteger(0, &tab_id);
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 contents->extension_tab_helper()->script_executor()->ExecuteScript( 264 contents->extension_tab_helper()->script_executor()->ExecuteScript(
267 extension->id(), 265 extension->id(),
268 script_type, 266 script_type,
269 code_string, 267 code_string,
270 frame_scope, 268 frame_scope,
271 run_at, 269 run_at,
272 ScriptExecutor::ISOLATED_WORLD, 270 ScriptExecutor::ISOLATED_WORLD,
273 base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this)); 271 base::Bind(&ExecuteCodeInTabFunction::OnExecuteCodeFinished, this));
274 return true; 272 return true;
275 } 273 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698