| OLD | NEW |
| 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/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 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1778 reply_message_(reply_message), | 1778 reply_message_(reply_message), |
| 1779 tab_contents_(tab_contents), | 1779 tab_contents_(tab_contents), |
| 1780 image_path_(path) { | 1780 image_path_(path) { |
| 1781 registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, | 1781 registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, |
| 1782 content::NotificationService::AllSources()); | 1782 content::NotificationService::AllSources()); |
| 1783 } | 1783 } |
| 1784 | 1784 |
| 1785 PageSnapshotTaker::~PageSnapshotTaker() {} | 1785 PageSnapshotTaker::~PageSnapshotTaker() {} |
| 1786 | 1786 |
| 1787 void PageSnapshotTaker::Start() { | 1787 void PageSnapshotTaker::Start() { |
| 1788 StartObserving(tab_contents_->automation_tab_helper()); | 1788 AutomationTabHelper* automation_tab_helper = |
| 1789 tab_contents_->automation_tab_helper()->SnapshotEntirePage(); | 1789 AutomationTabHelper::FromWebContents(tab_contents_->web_contents()); |
| 1790 StartObserving(automation_tab_helper); |
| 1791 automation_tab_helper->SnapshotEntirePage(); |
| 1790 } | 1792 } |
| 1791 | 1793 |
| 1792 void PageSnapshotTaker::OnSnapshotEntirePageACK( | 1794 void PageSnapshotTaker::OnSnapshotEntirePageACK( |
| 1793 bool success, | 1795 bool success, |
| 1794 const std::vector<unsigned char>& png_data, | 1796 const std::vector<unsigned char>& png_data, |
| 1795 const std::string& error_msg) { | 1797 const std::string& error_msg) { |
| 1796 bool overall_success = success; | 1798 bool overall_success = success; |
| 1797 std::string overall_error_msg = error_msg; | 1799 std::string overall_error_msg = error_msg; |
| 1798 if (success) { | 1800 if (success) { |
| 1799 base::ThreadRestrictions::ScopedAllowIO allow_io; | 1801 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2354 chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, | 2356 chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, |
| 2355 content::NotificationService::AllSources()); | 2357 content::NotificationService::AllSources()); |
| 2356 registrar_.Add(this, | 2358 registrar_.Add(this, |
| 2357 content::NOTIFICATION_LOAD_STOP, | 2359 content::NOTIFICATION_LOAD_STOP, |
| 2358 content::NotificationService::AllSources()); | 2360 content::NotificationService::AllSources()); |
| 2359 for (BrowserList::const_iterator iter = BrowserList::begin(); | 2361 for (BrowserList::const_iterator iter = BrowserList::begin(); |
| 2360 iter != BrowserList::end(); | 2362 iter != BrowserList::end(); |
| 2361 ++iter) { | 2363 ++iter) { |
| 2362 Browser* browser = *iter; | 2364 Browser* browser = *iter; |
| 2363 for (int i = 0; i < browser->tab_count(); ++i) { | 2365 for (int i = 0; i < browser->tab_count(); ++i) { |
| 2364 TabContents* tab_contents = chrome::GetTabContentsAt(browser, i); | 2366 WebContents* web_contents = chrome::GetWebContentsAt(browser, i); |
| 2365 StartObserving(tab_contents->automation_tab_helper()); | 2367 AutomationTabHelper* automation_tab_helper = |
| 2366 if (tab_contents->automation_tab_helper()->has_pending_loads()) | 2368 AutomationTabHelper::FromWebContents(web_contents); |
| 2367 pending_tabs_.insert(tab_contents->web_contents()); | 2369 StartObserving(automation_tab_helper); |
| 2370 if (automation_tab_helper->has_pending_loads()) |
| 2371 pending_tabs_.insert(web_contents); |
| 2368 } | 2372 } |
| 2369 } | 2373 } |
| 2370 CheckIfNoMorePendingLoads(); | 2374 CheckIfNoMorePendingLoads(); |
| 2371 } | 2375 } |
| 2372 | 2376 |
| 2373 AllViewsStoppedLoadingObserver::~AllViewsStoppedLoadingObserver() { | 2377 AllViewsStoppedLoadingObserver::~AllViewsStoppedLoadingObserver() { |
| 2374 } | 2378 } |
| 2375 | 2379 |
| 2376 void AllViewsStoppedLoadingObserver::OnFirstPendingLoad( | 2380 void AllViewsStoppedLoadingObserver::OnFirstPendingLoad( |
| 2377 content::WebContents* web_contents) { | 2381 content::WebContents* web_contents) { |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2874 if (automation_) { | 2878 if (automation_) { |
| 2875 AutomationJSONReply(automation_, reply_message_.release()) | 2879 AutomationJSONReply(automation_, reply_message_.release()) |
| 2876 .SendSuccess(NULL); | 2880 .SendSuccess(NULL); |
| 2877 } | 2881 } |
| 2878 delete this; | 2882 delete this; |
| 2879 } | 2883 } |
| 2880 } else { | 2884 } else { |
| 2881 NOTREACHED(); | 2885 NOTREACHED(); |
| 2882 } | 2886 } |
| 2883 } | 2887 } |
| OLD | NEW |