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

Unified Diff: chrome/browser/automation/automation_provider_observers.cc

Issue 10890023: Miscellaneous cleanups from several months ago I never got around to landing. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/alternate_nav_url_fetcher.cc ('k') | chrome/browser/download/download_request_limiter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/automation/automation_provider_observers.cc
===================================================================
--- chrome/browser/automation/automation_provider_observers.cc (revision 153800)
+++ chrome/browser/automation/automation_provider_observers.cc (working copy)
@@ -386,20 +386,16 @@
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- if (type == notification_) {
- if (type == chrome::NOTIFICATION_TAB_PARENTED) {
- ObserveTab(&(content::Source<TabContents>(source).ptr()->
- web_contents()->GetController()));
- } else if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
- ObserveTab(&(content::Source<content::WebContents>(source).ptr()->
- GetController()));
- } else {
- ObserveTab(content::Source<NavigationController>(source).ptr());
- }
- delete this;
+ DCHECK_EQ(notification_, type);
+ if (type == chrome::NOTIFICATION_TAB_PARENTED) {
+ ObserveTab(&content::Source<TabContents>(source)->web_contents()->
+ GetController());
+ } else if (type == content::NOTIFICATION_WEB_CONTENTS_DESTROYED) {
+ ObserveTab(&content::Source<content::WebContents>(source)->GetController());
} else {
- NOTREACHED();
+ ObserveTab(content::Source<NavigationController>(source).ptr());
}
+ delete this;
}
TabAppendedNotificationObserver::TabAppendedNotificationObserver(
@@ -441,11 +437,9 @@
bool wait_until_closed,
IPC::Message* reply_message,
bool use_json_interface)
- : TabStripNotificationObserver(
- wait_until_closed
- ? static_cast<int>(content::NOTIFICATION_WEB_CONTENTS_DESTROYED)
- : static_cast<int>(chrome::NOTIFICATION_TAB_CLOSING),
- automation),
+ : TabStripNotificationObserver((wait_until_closed ?
+ static_cast<int>(content::NOTIFICATION_WEB_CONTENTS_DESTROYED) :
+ static_cast<int>(chrome::NOTIFICATION_TAB_CLOSING)), automation),
reply_message_(reply_message),
use_json_interface_(use_json_interface),
for_browser_command_(false) {
@@ -810,7 +804,8 @@
}
void BrowserOpenedNotificationObserver::Observe(
- int type, const content::NotificationSource& source,
+ int type,
+ const content::NotificationSource& source,
const content::NotificationDetails& details) {
if (!automation_) {
delete this;
@@ -822,7 +817,8 @@
// to stop loading.
new_window_id_ = ExtensionTabUtil::GetWindowId(
content::Source<Browser>(source).ptr());
- } else if (type == content::NOTIFICATION_LOAD_STOP) {
+ } else {
+ DCHECK_EQ(content::NOTIFICATION_LOAD_STOP, type);
// Only send the result if the loaded tab is in the new window.
NavigationController* controller =
content::Source<NavigationController>(source).ptr();
@@ -843,8 +839,6 @@
delete this;
return;
}
- } else {
- NOTREACHED();
}
}
@@ -871,7 +865,7 @@
void BrowserClosedNotificationObserver::Observe(
int type, const content::NotificationSource& source,
const content::NotificationDetails& details) {
- DCHECK(type == chrome::NOTIFICATION_BROWSER_CLOSED);
+ DCHECK_EQ(chrome::NOTIFICATION_BROWSER_CLOSED, type);
if (!automation_) {
delete this;
@@ -1174,16 +1168,15 @@
OnDomOperationCompleted(dom_op_details->json);
} else if (type == chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN) {
OnModalDialogShown();
- } else if (type == chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED) {
+ } else {
+ DCHECK_EQ(chrome::NOTIFICATION_WEB_CONTENT_SETTINGS_CHANGED, type);
WebContents* web_contents = content::Source<WebContents>(source).ptr();
if (web_contents) {
TabContents* tab_contents = TabContents::FromWebContents(web_contents);
- if (tab_contents &&
- tab_contents->content_settings() &&
+ if (tab_contents && tab_contents->content_settings() &&
tab_contents->content_settings()->IsContentBlocked(
- CONTENT_SETTINGS_TYPE_JAVASCRIPT)) {
+ CONTENT_SETTINGS_TYPE_JAVASCRIPT))
OnJavascriptBlocked();
- }
}
}
}
@@ -2193,36 +2186,23 @@
void AppLaunchObserver::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- if (type == content::NOTIFICATION_LOAD_STOP) {
- if (launch_container_ == extension_misc::LAUNCH_TAB) {
- // The app has been launched in the new tab.
- if (automation_) {
- AutomationJSONReply(automation_,
- reply_message_.release()).SendSuccess(NULL);
- }
- delete this;
- return;
- } else {
- // The app has launched only if the loaded tab is in the new window.
- NavigationController* controller =
- content::Source<NavigationController>(source).ptr();
- TabContents* tab =
- TabContents::FromWebContents(controller->GetWebContents());
- int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1;
- if (window_id == new_window_id_) {
- if (automation_) {
- AutomationJSONReply(automation_,
- reply_message_.release()).SendSuccess(NULL);
- }
- delete this;
- return;
- }
+ if (type == chrome::NOTIFICATION_BROWSER_WINDOW_READY) {
+ new_window_id_ =
+ ExtensionTabUtil::GetWindowId(content::Source<Browser>(source).ptr());
+ return;
+ }
+
+ DCHECK_EQ(content::NOTIFICATION_LOAD_STOP, type);
+ TabContents* tab = TabContents::FromWebContents(
+ content::Source<NavigationController>(source)->GetWebContents());
+ if ((launch_container_ == extension_misc::LAUNCH_TAB) ||
+ (tab &&
+ (tab->restore_tab_helper()->window_id().id() == new_window_id_))) {
Peter Kasting 2012/08/29 01:21:38 Note: There is a slight behavior change here in th
+ if (automation_) {
+ AutomationJSONReply(automation_,
+ reply_message_.release()).SendSuccess(NULL);
}
- } else if (type == chrome::NOTIFICATION_BROWSER_WINDOW_READY) {
- new_window_id_ = ExtensionTabUtil::GetWindowId(
- content::Source<Browser>(source).ptr());
- } else {
- NOTREACHED();
+ delete this;
}
}
@@ -2858,7 +2838,8 @@
// to stop loading.
new_window_id_ = ExtensionTabUtil::GetWindowId(
content::Source<Browser>(source).ptr());
- } else if (type == content::NOTIFICATION_LOAD_STOP) {
+ } else {
+ DCHECK_EQ(content::NOTIFICATION_LOAD_STOP, type);
// Only send the result if the loaded tab is in the new window.
NavigationController* controller =
content::Source<NavigationController>(source).ptr();
@@ -2872,8 +2853,6 @@
}
delete this;
}
- } else {
- NOTREACHED();
}
}
« no previous file with comments | « chrome/browser/alternate_nav_url_fetcher.cc ('k') | chrome/browser/download/download_request_limiter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698