| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/automation/automation_provider_observers.h" | 5 #include "chrome/browser/automation/automation_provider_observers.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 #include "content/public/browser/render_process_host.h" | 82 #include "content/public/browser/render_process_host.h" |
| 83 #include "content/public/common/process_type.h" | 83 #include "content/public/common/process_type.h" |
| 84 #include "googleurl/src/gurl.h" | 84 #include "googleurl/src/gurl.h" |
| 85 #include "third_party/skia/include/core/SkBitmap.h" | 85 #include "third_party/skia/include/core/SkBitmap.h" |
| 86 #include "ui/gfx/codec/png_codec.h" | 86 #include "ui/gfx/codec/png_codec.h" |
| 87 #include "ui/gfx/rect.h" | 87 #include "ui/gfx/rect.h" |
| 88 | 88 |
| 89 using content::BrowserThread; | 89 using content::BrowserThread; |
| 90 using content::DownloadItem; | 90 using content::DownloadItem; |
| 91 using content::DownloadManager; | 91 using content::DownloadManager; |
| 92 using content::NavigationController; |
| 92 using content::WebContents; | 93 using content::WebContents; |
| 93 | 94 |
| 94 // Holds onto start and stop timestamps for a particular tab | 95 // Holds onto start and stop timestamps for a particular tab |
| 95 class InitialLoadObserver::TabTime { | 96 class InitialLoadObserver::TabTime { |
| 96 public: | 97 public: |
| 97 explicit TabTime(base::TimeTicks started) | 98 explicit TabTime(base::TimeTicks started) |
| 98 : load_start_time_(started) { | 99 : load_start_time_(started) { |
| 99 } | 100 } |
| 100 void set_stop_time(base::TimeTicks stopped) { | 101 void set_stop_time(base::TimeTicks stopped) { |
| 101 load_stop_time_ = stopped; | 102 load_stop_time_ = stopped; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 automation_->Send( | 227 automation_->Send( |
| 227 new AutomationMsg_InitialNewTabUILoadComplete(*load_time.ptr())); | 228 new AutomationMsg_InitialNewTabUILoadComplete(*load_time.ptr())); |
| 228 } | 229 } |
| 229 } else { | 230 } else { |
| 230 NOTREACHED(); | 231 NOTREACHED(); |
| 231 } | 232 } |
| 232 } | 233 } |
| 233 | 234 |
| 234 NavigationControllerRestoredObserver::NavigationControllerRestoredObserver( | 235 NavigationControllerRestoredObserver::NavigationControllerRestoredObserver( |
| 235 AutomationProvider* automation, | 236 AutomationProvider* automation, |
| 236 content::NavigationController* controller, | 237 NavigationController* controller, |
| 237 IPC::Message* reply_message) | 238 IPC::Message* reply_message) |
| 238 : automation_(automation->AsWeakPtr()), | 239 : automation_(automation->AsWeakPtr()), |
| 239 controller_(controller), | 240 controller_(controller), |
| 240 reply_message_(reply_message) { | 241 reply_message_(reply_message) { |
| 241 if (FinishedRestoring()) { | 242 if (FinishedRestoring()) { |
| 242 SendDone(); | 243 SendDone(); |
| 243 } else { | 244 } else { |
| 244 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, | 245 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
| 245 content::NotificationService::AllSources()); | 246 content::NotificationService::AllSources()); |
| 246 } | 247 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 266 void NavigationControllerRestoredObserver::SendDone() { | 267 void NavigationControllerRestoredObserver::SendDone() { |
| 267 if (!automation_) | 268 if (!automation_) |
| 268 return; | 269 return; |
| 269 | 270 |
| 270 AutomationMsg_WaitForTabToBeRestored::WriteReplyParams(reply_message_.get(), | 271 AutomationMsg_WaitForTabToBeRestored::WriteReplyParams(reply_message_.get(), |
| 271 true); | 272 true); |
| 272 automation_->Send(reply_message_.release()); | 273 automation_->Send(reply_message_.release()); |
| 273 } | 274 } |
| 274 | 275 |
| 275 NavigationNotificationObserver::NavigationNotificationObserver( | 276 NavigationNotificationObserver::NavigationNotificationObserver( |
| 276 content::NavigationController* controller, | 277 NavigationController* controller, |
| 277 AutomationProvider* automation, | 278 AutomationProvider* automation, |
| 278 IPC::Message* reply_message, | 279 IPC::Message* reply_message, |
| 279 int number_of_navigations, | 280 int number_of_navigations, |
| 280 bool include_current_navigation, | 281 bool include_current_navigation, |
| 281 bool use_json_interface) | 282 bool use_json_interface) |
| 282 : automation_(automation->AsWeakPtr()), | 283 : automation_(automation->AsWeakPtr()), |
| 283 reply_message_(reply_message), | 284 reply_message_(reply_message), |
| 284 controller_(controller), | 285 controller_(controller), |
| 285 navigations_remaining_(number_of_navigations), | 286 navigations_remaining_(number_of_navigations), |
| 286 navigation_started_(false), | 287 navigation_started_(false), |
| 287 use_json_interface_(use_json_interface) { | 288 use_json_interface_(use_json_interface) { |
| 288 if (number_of_navigations == 0) { | 289 if (number_of_navigations == 0) { |
| 289 ConditionMet(AUTOMATION_MSG_NAVIGATION_SUCCESS); | 290 ConditionMet(AUTOMATION_MSG_NAVIGATION_SUCCESS); |
| 290 return; | 291 return; |
| 291 } | 292 } |
| 292 DCHECK_LT(0, navigations_remaining_); | 293 DCHECK_LT(0, navigations_remaining_); |
| 293 content::Source<content::NavigationController> source(controller_); | 294 content::Source<NavigationController> source(controller_); |
| 294 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); | 295 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, source); |
| 295 registrar_.Add(this, content::NOTIFICATION_LOAD_START, source); | 296 registrar_.Add(this, content::NOTIFICATION_LOAD_START, source); |
| 296 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, source); | 297 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, source); |
| 297 registrar_.Add(this, chrome::NOTIFICATION_AUTH_NEEDED, source); | 298 registrar_.Add(this, chrome::NOTIFICATION_AUTH_NEEDED, source); |
| 298 registrar_.Add(this, chrome::NOTIFICATION_AUTH_SUPPLIED, source); | 299 registrar_.Add(this, chrome::NOTIFICATION_AUTH_SUPPLIED, source); |
| 299 registrar_.Add(this, chrome::NOTIFICATION_AUTH_CANCELLED, source); | 300 registrar_.Add(this, chrome::NOTIFICATION_AUTH_CANCELLED, source); |
| 300 registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, | 301 registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, |
| 301 content::NotificationService::AllSources()); | 302 content::NotificationService::AllSources()); |
| 302 | 303 |
| 303 if (include_current_navigation && controller->GetWebContents()->IsLoading()) | 304 if (include_current_navigation && controller->GetWebContents()->IsLoading()) |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 389 |
| 389 void TabStripNotificationObserver::Observe( | 390 void TabStripNotificationObserver::Observe( |
| 390 int type, | 391 int type, |
| 391 const content::NotificationSource& source, | 392 const content::NotificationSource& source, |
| 392 const content::NotificationDetails& details) { | 393 const content::NotificationDetails& details) { |
| 393 if (type == notification_) { | 394 if (type == notification_) { |
| 394 if (type == content::NOTIFICATION_TAB_PARENTED) { | 395 if (type == content::NOTIFICATION_TAB_PARENTED) { |
| 395 ObserveTab(&(content::Source<TabContentsWrapper>(source).ptr()-> | 396 ObserveTab(&(content::Source<TabContentsWrapper>(source).ptr()-> |
| 396 tab_contents()->GetController())); | 397 tab_contents()->GetController())); |
| 397 } else { | 398 } else { |
| 398 ObserveTab(content::Source<content::NavigationController>(source).ptr()); | 399 ObserveTab(content::Source<NavigationController>(source).ptr()); |
| 399 } | 400 } |
| 400 delete this; | 401 delete this; |
| 401 } else { | 402 } else { |
| 402 NOTREACHED(); | 403 NOTREACHED(); |
| 403 } | 404 } |
| 404 } | 405 } |
| 405 | 406 |
| 406 TabAppendedNotificationObserver::TabAppendedNotificationObserver( | 407 TabAppendedNotificationObserver::TabAppendedNotificationObserver( |
| 407 Browser* parent, AutomationProvider* automation, | 408 Browser* parent, AutomationProvider* automation, |
| 408 IPC::Message* reply_message) | 409 IPC::Message* reply_message) |
| 409 : TabStripNotificationObserver(content::NOTIFICATION_TAB_PARENTED, | 410 : TabStripNotificationObserver(content::NOTIFICATION_TAB_PARENTED, |
| 410 automation), | 411 automation), |
| 411 parent_(parent), | 412 parent_(parent), |
| 412 reply_message_(reply_message) { | 413 reply_message_(reply_message) { |
| 413 } | 414 } |
| 414 | 415 |
| 415 TabAppendedNotificationObserver::~TabAppendedNotificationObserver() {} | 416 TabAppendedNotificationObserver::~TabAppendedNotificationObserver() {} |
| 416 | 417 |
| 417 void TabAppendedNotificationObserver::ObserveTab( | 418 void TabAppendedNotificationObserver::ObserveTab( |
| 418 content::NavigationController* controller) { | 419 NavigationController* controller) { |
| 419 if (!automation_) | 420 if (!automation_) |
| 420 return; | 421 return; |
| 421 | 422 |
| 422 if (automation_->GetIndexForNavigationController(controller, parent_) == | 423 if (automation_->GetIndexForNavigationController(controller, parent_) == |
| 423 TabStripModel::kNoTab) { | 424 TabStripModel::kNoTab) { |
| 424 // This tab notification doesn't belong to the parent_. | 425 // This tab notification doesn't belong to the parent_. |
| 425 return; | 426 return; |
| 426 } | 427 } |
| 427 | 428 |
| 428 new NavigationNotificationObserver(controller, automation_, | 429 new NavigationNotificationObserver(controller, automation_, |
| 429 reply_message_.release(), | 430 reply_message_.release(), |
| 430 1, false, false); | 431 1, false, false); |
| 431 } | 432 } |
| 432 | 433 |
| 433 TabClosedNotificationObserver::TabClosedNotificationObserver( | 434 TabClosedNotificationObserver::TabClosedNotificationObserver( |
| 434 AutomationProvider* automation, bool wait_until_closed, | 435 AutomationProvider* automation, bool wait_until_closed, |
| 435 IPC::Message* reply_message) | 436 IPC::Message* reply_message) |
| 436 : TabStripNotificationObserver(wait_until_closed ? | 437 : TabStripNotificationObserver(wait_until_closed ? |
| 437 content::NOTIFICATION_TAB_CLOSED : content::NOTIFICATION_TAB_CLOSING, | 438 content::NOTIFICATION_TAB_CLOSED : content::NOTIFICATION_TAB_CLOSING, |
| 438 automation), | 439 automation), |
| 439 reply_message_(reply_message), | 440 reply_message_(reply_message), |
| 440 for_browser_command_(false) { | 441 for_browser_command_(false) { |
| 441 } | 442 } |
| 442 | 443 |
| 443 TabClosedNotificationObserver::~TabClosedNotificationObserver() {} | 444 TabClosedNotificationObserver::~TabClosedNotificationObserver() {} |
| 444 | 445 |
| 445 void TabClosedNotificationObserver::ObserveTab( | 446 void TabClosedNotificationObserver::ObserveTab( |
| 446 content::NavigationController* controller) { | 447 NavigationController* controller) { |
| 447 if (!automation_) | 448 if (!automation_) |
| 448 return; | 449 return; |
| 449 | 450 |
| 450 if (for_browser_command_) { | 451 if (for_browser_command_) { |
| 451 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), | 452 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), |
| 452 true); | 453 true); |
| 453 } else { | 454 } else { |
| 454 AutomationMsg_CloseTab::WriteReplyParams(reply_message_.get(), true); | 455 AutomationMsg_CloseTab::WriteReplyParams(reply_message_.get(), true); |
| 455 } | 456 } |
| 456 automation_->Send(reply_message_.release()); | 457 automation_->Send(reply_message_.release()); |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 878 return; | 879 return; |
| 879 } | 880 } |
| 880 | 881 |
| 881 if (type == chrome::NOTIFICATION_BROWSER_OPENED) { | 882 if (type == chrome::NOTIFICATION_BROWSER_OPENED) { |
| 882 // Store the new browser ID and continue waiting for a new tab within it | 883 // Store the new browser ID and continue waiting for a new tab within it |
| 883 // to stop loading. | 884 // to stop loading. |
| 884 new_window_id_ = ExtensionTabUtil::GetWindowId( | 885 new_window_id_ = ExtensionTabUtil::GetWindowId( |
| 885 content::Source<Browser>(source).ptr()); | 886 content::Source<Browser>(source).ptr()); |
| 886 } else if (type == content::NOTIFICATION_LOAD_STOP) { | 887 } else if (type == content::NOTIFICATION_LOAD_STOP) { |
| 887 // Only send the result if the loaded tab is in the new window. | 888 // Only send the result if the loaded tab is in the new window. |
| 888 content::NavigationController* controller = | 889 NavigationController* controller = |
| 889 content::Source<content::NavigationController>(source).ptr(); | 890 content::Source<NavigationController>(source).ptr(); |
| 890 TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( | 891 TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( |
| 891 controller->GetWebContents()); | 892 controller->GetWebContents()); |
| 892 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; | 893 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; |
| 893 if (window_id == new_window_id_) { | 894 if (window_id == new_window_id_) { |
| 894 if (for_browser_command_) { | 895 if (for_browser_command_) { |
| 895 AutomationMsg_WindowExecuteCommand::WriteReplyParams( | 896 AutomationMsg_WindowExecuteCommand::WriteReplyParams( |
| 896 reply_message_.get(), true); | 897 reply_message_.get(), true); |
| 897 } | 898 } |
| 898 automation_->Send(reply_message_.release()); | 899 automation_->Send(reply_message_.release()); |
| 899 delete this; | 900 delete this; |
| (...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1893 AutomationProviderBrowsingDataObserver:: | 1894 AutomationProviderBrowsingDataObserver:: |
| 1894 ~AutomationProviderBrowsingDataObserver() {} | 1895 ~AutomationProviderBrowsingDataObserver() {} |
| 1895 | 1896 |
| 1896 void AutomationProviderBrowsingDataObserver::OnBrowsingDataRemoverDone() { | 1897 void AutomationProviderBrowsingDataObserver::OnBrowsingDataRemoverDone() { |
| 1897 if (provider_) | 1898 if (provider_) |
| 1898 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess(NULL); | 1899 AutomationJSONReply(provider_, reply_message_.release()).SendSuccess(NULL); |
| 1899 delete this; | 1900 delete this; |
| 1900 } | 1901 } |
| 1901 | 1902 |
| 1902 OmniboxAcceptNotificationObserver::OmniboxAcceptNotificationObserver( | 1903 OmniboxAcceptNotificationObserver::OmniboxAcceptNotificationObserver( |
| 1903 content::NavigationController* controller, | 1904 NavigationController* controller, |
| 1904 AutomationProvider* automation, | 1905 AutomationProvider* automation, |
| 1905 IPC::Message* reply_message) | 1906 IPC::Message* reply_message) |
| 1906 : automation_(automation->AsWeakPtr()), | 1907 : automation_(automation->AsWeakPtr()), |
| 1907 reply_message_(reply_message), | 1908 reply_message_(reply_message), |
| 1908 controller_(controller) { | 1909 controller_(controller) { |
| 1909 content::Source<content::NavigationController> source(controller_); | 1910 content::Source<NavigationController> source(controller_); |
| 1910 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, source); | 1911 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, source); |
| 1911 // Pages requiring auth don't send LOAD_STOP. | 1912 // Pages requiring auth don't send LOAD_STOP. |
| 1912 registrar_.Add(this, chrome::NOTIFICATION_AUTH_NEEDED, source); | 1913 registrar_.Add(this, chrome::NOTIFICATION_AUTH_NEEDED, source); |
| 1913 } | 1914 } |
| 1914 | 1915 |
| 1915 OmniboxAcceptNotificationObserver::~OmniboxAcceptNotificationObserver() { | 1916 OmniboxAcceptNotificationObserver::~OmniboxAcceptNotificationObserver() { |
| 1916 } | 1917 } |
| 1917 | 1918 |
| 1918 void OmniboxAcceptNotificationObserver::Observe( | 1919 void OmniboxAcceptNotificationObserver::Observe( |
| 1919 int type, | 1920 int type, |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2191 dict->SetBoolean("is_pinned", top_sites_->IsURLPinned(visited.url)); | 2192 dict->SetBoolean("is_pinned", top_sites_->IsURLPinned(visited.url)); |
| 2192 list_value->Append(dict); | 2193 list_value->Append(dict); |
| 2193 } | 2194 } |
| 2194 ntp_info_->Set("most_visited", list_value); | 2195 ntp_info_->Set("most_visited", list_value); |
| 2195 AutomationJSONReply(automation_, | 2196 AutomationJSONReply(automation_, |
| 2196 reply_message_.release()).SendSuccess(ntp_info_.get()); | 2197 reply_message_.release()).SendSuccess(ntp_info_.get()); |
| 2197 delete this; | 2198 delete this; |
| 2198 } | 2199 } |
| 2199 | 2200 |
| 2200 AppLaunchObserver::AppLaunchObserver( | 2201 AppLaunchObserver::AppLaunchObserver( |
| 2201 content::NavigationController* controller, | 2202 NavigationController* controller, |
| 2202 AutomationProvider* automation, | 2203 AutomationProvider* automation, |
| 2203 IPC::Message* reply_message, | 2204 IPC::Message* reply_message, |
| 2204 extension_misc::LaunchContainer launch_container) | 2205 extension_misc::LaunchContainer launch_container) |
| 2205 : controller_(controller), | 2206 : controller_(controller), |
| 2206 automation_(automation->AsWeakPtr()), | 2207 automation_(automation->AsWeakPtr()), |
| 2207 reply_message_(reply_message), | 2208 reply_message_(reply_message), |
| 2208 launch_container_(launch_container), | 2209 launch_container_(launch_container), |
| 2209 new_window_id_(extension_misc::kUnknownWindowId) { | 2210 new_window_id_(extension_misc::kUnknownWindowId) { |
| 2210 if (launch_container_ == extension_misc::LAUNCH_TAB) { | 2211 if (launch_container_ == extension_misc::LAUNCH_TAB) { |
| 2211 // Need to wait for the currently-active tab to reload. | 2212 // Need to wait for the currently-active tab to reload. |
| 2212 content::Source<content::NavigationController> source(controller_); | 2213 content::Source<NavigationController> source(controller_); |
| 2213 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, source); | 2214 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, source); |
| 2214 } else { | 2215 } else { |
| 2215 // Need to wait for a new tab in a new window to load. | 2216 // Need to wait for a new tab in a new window to load. |
| 2216 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, | 2217 registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
| 2217 content::NotificationService::AllSources()); | 2218 content::NotificationService::AllSources()); |
| 2218 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 2219 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
| 2219 content::NotificationService::AllSources()); | 2220 content::NotificationService::AllSources()); |
| 2220 } | 2221 } |
| 2221 } | 2222 } |
| 2222 | 2223 |
| 2223 AppLaunchObserver::~AppLaunchObserver() {} | 2224 AppLaunchObserver::~AppLaunchObserver() {} |
| 2224 | 2225 |
| 2225 void AppLaunchObserver::Observe(int type, | 2226 void AppLaunchObserver::Observe(int type, |
| 2226 const content::NotificationSource& source, | 2227 const content::NotificationSource& source, |
| 2227 const content::NotificationDetails& details) { | 2228 const content::NotificationDetails& details) { |
| 2228 if (type == content::NOTIFICATION_LOAD_STOP) { | 2229 if (type == content::NOTIFICATION_LOAD_STOP) { |
| 2229 if (launch_container_ == extension_misc::LAUNCH_TAB) { | 2230 if (launch_container_ == extension_misc::LAUNCH_TAB) { |
| 2230 // The app has been launched in the new tab. | 2231 // The app has been launched in the new tab. |
| 2231 if (automation_) { | 2232 if (automation_) { |
| 2232 AutomationJSONReply(automation_, | 2233 AutomationJSONReply(automation_, |
| 2233 reply_message_.release()).SendSuccess(NULL); | 2234 reply_message_.release()).SendSuccess(NULL); |
| 2234 } | 2235 } |
| 2235 delete this; | 2236 delete this; |
| 2236 return; | 2237 return; |
| 2237 } else { | 2238 } else { |
| 2238 // The app has launched only if the loaded tab is in the new window. | 2239 // The app has launched only if the loaded tab is in the new window. |
| 2239 content::NavigationController* controller = | 2240 NavigationController* controller = |
| 2240 content::Source<content::NavigationController>(source).ptr(); | 2241 content::Source<NavigationController>(source).ptr(); |
| 2241 TabContentsWrapper* tab = | 2242 TabContentsWrapper* tab = |
| 2242 TabContentsWrapper::GetCurrentWrapperForContents( | 2243 TabContentsWrapper::GetCurrentWrapperForContents( |
| 2243 controller->GetWebContents()); | 2244 controller->GetWebContents()); |
| 2244 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; | 2245 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; |
| 2245 if (window_id == new_window_id_) { | 2246 if (window_id == new_window_id_) { |
| 2246 if (automation_) { | 2247 if (automation_) { |
| 2247 AutomationJSONReply(automation_, | 2248 AutomationJSONReply(automation_, |
| 2248 reply_message_.release()).SendSuccess(NULL); | 2249 reply_message_.release()).SendSuccess(NULL); |
| 2249 } | 2250 } |
| 2250 delete this; | 2251 delete this; |
| (...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2743 // Use TAB_PARENTED to detect the new tab. | 2744 // Use TAB_PARENTED to detect the new tab. |
| 2744 registrar_.Add(this, | 2745 registrar_.Add(this, |
| 2745 content::NOTIFICATION_TAB_PARENTED, | 2746 content::NOTIFICATION_TAB_PARENTED, |
| 2746 content::NotificationService::AllSources()); | 2747 content::NotificationService::AllSources()); |
| 2747 } | 2748 } |
| 2748 | 2749 |
| 2749 void NewTabObserver::Observe(int type, | 2750 void NewTabObserver::Observe(int type, |
| 2750 const content::NotificationSource& source, | 2751 const content::NotificationSource& source, |
| 2751 const content::NotificationDetails& details) { | 2752 const content::NotificationDetails& details) { |
| 2752 DCHECK_EQ(content::NOTIFICATION_TAB_PARENTED, type); | 2753 DCHECK_EQ(content::NOTIFICATION_TAB_PARENTED, type); |
| 2753 content::NavigationController* controller = | 2754 NavigationController* controller = |
| 2754 &(content::Source<TabContentsWrapper>(source).ptr()-> | 2755 &(content::Source<TabContentsWrapper>(source).ptr()-> |
| 2755 tab_contents()->GetController()); | 2756 tab_contents()->GetController()); |
| 2756 if (automation_) { | 2757 if (automation_) { |
| 2757 // TODO(phajdan.jr): Clean up this hack. We write the correct return type | 2758 // TODO(phajdan.jr): Clean up this hack. We write the correct return type |
| 2758 // here, but don't send the message. NavigationNotificationObserver | 2759 // here, but don't send the message. NavigationNotificationObserver |
| 2759 // will wait properly for the load to finish, and send the message, | 2760 // will wait properly for the load to finish, and send the message, |
| 2760 // but it will also append its own return value at the end of the reply. | 2761 // but it will also append its own return value at the end of the reply. |
| 2761 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), | 2762 AutomationMsg_WindowExecuteCommand::WriteReplyParams(reply_message_.get(), |
| 2762 true); | 2763 true); |
| 2763 new NavigationNotificationObserver(controller, automation_, | 2764 new NavigationNotificationObserver(controller, automation_, |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2964 reply_message_.release()).SendError("Profile could not be created."); | 2965 reply_message_.release()).SendError("Profile could not be created."); |
| 2965 return; | 2966 return; |
| 2966 } | 2967 } |
| 2967 } else if (type == chrome::NOTIFICATION_BROWSER_OPENED) { | 2968 } else if (type == chrome::NOTIFICATION_BROWSER_OPENED) { |
| 2968 // Store the new browser ID and continue waiting for a new tab within it | 2969 // Store the new browser ID and continue waiting for a new tab within it |
| 2969 // to stop loading. | 2970 // to stop loading. |
| 2970 new_window_id_ = ExtensionTabUtil::GetWindowId( | 2971 new_window_id_ = ExtensionTabUtil::GetWindowId( |
| 2971 content::Source<Browser>(source).ptr()); | 2972 content::Source<Browser>(source).ptr()); |
| 2972 } else if (type == content::NOTIFICATION_LOAD_STOP) { | 2973 } else if (type == content::NOTIFICATION_LOAD_STOP) { |
| 2973 // Only send the result if the loaded tab is in the new window. | 2974 // Only send the result if the loaded tab is in the new window. |
| 2974 content::NavigationController* controller = | 2975 NavigationController* controller = |
| 2975 content::Source<content::NavigationController>(source).ptr(); | 2976 content::Source<NavigationController>(source).ptr(); |
| 2976 TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( | 2977 TabContentsWrapper* tab = TabContentsWrapper::GetCurrentWrapperForContents( |
| 2977 controller->GetWebContents()); | 2978 controller->GetWebContents()); |
| 2978 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; | 2979 int window_id = tab ? tab->restore_tab_helper()->window_id().id() : -1; |
| 2979 if (window_id == new_window_id_) { | 2980 if (window_id == new_window_id_) { |
| 2980 if (automation_) { | 2981 if (automation_) { |
| 2981 AutomationJSONReply(automation_, reply_message_.release()) | 2982 AutomationJSONReply(automation_, reply_message_.release()) |
| 2982 .SendSuccess(NULL); | 2983 .SendSuccess(NULL); |
| 2983 } | 2984 } |
| 2984 delete this; | 2985 delete this; |
| 2985 } | 2986 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3098 } | 3099 } |
| 3099 | 3100 |
| 3100 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); | 3101 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); |
| 3101 if (host->extension_id() == extension_id_ && | 3102 if (host->extension_id() == extension_id_ && |
| 3102 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { | 3103 host->extension_host_type() == chrome::VIEW_TYPE_EXTENSION_POPUP) { |
| 3103 AutomationJSONReply(automation_, reply_message_.release()) | 3104 AutomationJSONReply(automation_, reply_message_.release()) |
| 3104 .SendSuccess(NULL); | 3105 .SendSuccess(NULL); |
| 3105 delete this; | 3106 delete this; |
| 3106 } | 3107 } |
| 3107 } | 3108 } |
| OLD | NEW |