Index: chrome/browser/extensions/script_badge_controller.cc |
diff --git a/chrome/browser/extensions/script_badge_controller.cc b/chrome/browser/extensions/script_badge_controller.cc |
index 533ac25e37a6ab78e8778284429101010c761dbb..485c7d55fcb656d00c3da208fb6a98ec6f8cc1dd 100644 |
--- a/chrome/browser/extensions/script_badge_controller.cc |
+++ b/chrome/browser/extensions/script_badge_controller.cc |
@@ -4,6 +4,8 @@ |
#include "chrome/browser/extensions/script_badge_controller.h" |
+#include "base/logging.h" |
+#include "base/string_util.h" |
#include "chrome/browser/extensions/browser_event_router.h" |
#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/browser/extensions/extension_system.h" |
@@ -20,6 +22,7 @@ |
#include "content/public/browser/navigation_entry.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/web_contents.h" |
+#include "googleurl/src/gurl.h" |
#include "ipc/ipc_message.h" |
#include "ipc/ipc_message_macros.h" |
@@ -103,11 +106,20 @@ LocationBarController::Action ScriptBadgeController::OnClicked( |
void ScriptBadgeController::OnExecuteScriptFinished( |
const std::string& extension_id, |
- bool success, |
- int32 page_id, |
const std::string& error, |
+ int32 on_page_id, |
+ const GURL& on_url, |
const base::ListValue& script_results) { |
- if (success && page_id == GetPageID()) { |
+ int32 current_page_id = GetPageID(); |
+ |
+ // Tracking down http://crbug.com/138323. |
+ CHECK_GE(current_page_id, 0) << |
+ "Expect a page ID of " << on_page_id << ", on URL \"" << on_url << |
Jeffrey Yasskin
2012/08/06 11:39:02
Re "buffer on the stack", I assume you'll copy on_
|
+ "\", but there was no navigation entry. Current URL=\"" << |
+ tab_contents_->web_contents()->GetURL() << "\", " << |
+ "extension_id=" << extension_id; |
+ |
+ if (error.empty() && on_page_id == current_page_id) { |
if (MarkExtensionExecuting(extension_id)) |
NotifyChange(); |
} |
@@ -119,8 +131,9 @@ ExtensionService* ScriptBadgeController::GetExtensionService() { |
} |
int32 ScriptBadgeController::GetPageID() { |
- return tab_contents_->web_contents()->GetController().GetActiveEntry()-> |
- GetPageID(); |
+ content::NavigationEntry* nav_entry = |
+ tab_contents_->web_contents()->GetController().GetActiveEntry(); |
+ return nav_entry ? nav_entry->GetPageID() : -1; |
} |
void ScriptBadgeController::NotifyChange() { |
@@ -160,9 +173,27 @@ bool ScriptBadgeController::OnMessageReceived(const IPC::Message& message) { |
return handled; |
} |
+namespace { |
+std::string JoinExtensionIDs(const std::set<std::string>& ids) { |
+ std::vector<std::string> as_vector(ids.begin(), ids.end()); |
+ return "[" + JoinString(as_vector, ',') + "]"; |
+} |
+} // namespace |
+ |
void ScriptBadgeController::OnContentScriptsExecuting( |
- const std::set<std::string>& extension_ids, int32 page_id) { |
- if (page_id != GetPageID()) |
+ const std::set<std::string>& extension_ids, |
+ int32 on_page_id, |
+ const GURL& on_url) { |
+ int32 current_page_id = GetPageID(); |
+ |
+ // Tracking down http://crbug.com/138323. |
+ CHECK_GE(current_page_id, 0) << |
+ "Expect a page ID of " << on_page_id << ", on URL \"" << on_url << |
+ "\", but there was no navigation entry. Current URL=\"" << |
+ tab_contents_->web_contents()->GetURL() << "\", " << |
+ "extension_ids=" << JoinExtensionIDs(extension_ids); |
+ |
+ if (on_page_id != current_page_id) |
return; |
bool changed = false; |