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 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ | 5 #ifndef CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ |
6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ | 6 #define CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <deque> | 9 #include <deque> |
10 #include <map> | 10 #include <map> |
(...skipping 1325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 const content::NotificationDetails& details); | 1336 const content::NotificationDetails& details); |
1337 | 1337 |
1338 private: | 1338 private: |
1339 content::NotificationRegistrar registrar_; | 1339 content::NotificationRegistrar registrar_; |
1340 base::WeakPtr<AutomationProvider> automation_; | 1340 base::WeakPtr<AutomationProvider> automation_; |
1341 scoped_ptr<IPC::Message> reply_message_; | 1341 scoped_ptr<IPC::Message> reply_message_; |
1342 | 1342 |
1343 DISALLOW_COPY_AND_ASSIGN(SavePackageNotificationObserver); | 1343 DISALLOW_COPY_AND_ASSIGN(SavePackageNotificationObserver); |
1344 }; | 1344 }; |
1345 | 1345 |
1346 // This class manages taking a snapshot of a page. | 1346 // This class manages taking a snapshot of a page. This requires waiting on |
1347 class PageSnapshotTaker : public TabEventObserver, | 1347 // asynchronous callbacks and notifications. |
1348 public content::NotificationObserver { | 1348 class PageSnapshotTaker : public DomOperationObserver { |
1349 public: | 1349 public: |
1350 PageSnapshotTaker(AutomationProvider* automation, | 1350 PageSnapshotTaker(AutomationProvider* automation, |
1351 IPC::Message* reply_message, | 1351 IPC::Message* reply_message, |
1352 TabContentsWrapper* tab_contents, | 1352 RenderViewHost* render_view, |
1353 const FilePath& path); | 1353 const FilePath& path); |
1354 virtual ~PageSnapshotTaker(); | 1354 virtual ~PageSnapshotTaker(); |
1355 | 1355 |
1356 // Start the process of taking a snapshot of the entire page. | 1356 // Start the process of taking a snapshot of the entire page. |
1357 void Start(); | 1357 void Start(); |
1358 | 1358 |
1359 private: | 1359 private: |
1360 // TabEventObserver overrides. | 1360 // Overriden from DomOperationObserver. |
1361 virtual void OnSnapshotEntirePageACK( | 1361 virtual void OnDomOperationCompleted(const std::string& json) OVERRIDE; |
1362 bool success, | 1362 virtual void OnModalDialogShown() OVERRIDE; |
1363 const std::vector<unsigned char>& png_data, | 1363 |
1364 const std::string& error_msg) OVERRIDE; | 1364 // Called by the ThumbnailGenerator when the requested snapshot has been |
1365 // NotificationObserver overrides. | 1365 // generated. |
1366 virtual void Observe(int type, | 1366 void OnSnapshotTaken(const SkBitmap& bitmap); |
1367 const content::NotificationSource& source, | 1367 |
1368 const content::NotificationDetails& details); | 1368 // Helper method to send arbitrary javascript to the renderer for evaluation. |
| 1369 void ExecuteScript(const std::wstring& javascript); |
1369 | 1370 |
1370 // Helper method to send a response back to the client. Deletes this. | 1371 // Helper method to send a response back to the client. Deletes this. |
1371 void SendMessage(bool success, const std::string& error_msg); | 1372 void SendMessage(bool success, const std::string& error_msg); |
1372 | 1373 |
1373 base::WeakPtr<AutomationProvider> automation_; | 1374 base::WeakPtr<AutomationProvider> automation_; |
1374 scoped_ptr<IPC::Message> reply_message_; | 1375 scoped_ptr<IPC::Message> reply_message_; |
1375 TabContentsWrapper* tab_contents_; | 1376 RenderViewHost* render_view_; |
1376 FilePath image_path_; | 1377 FilePath image_path_; |
1377 content::NotificationRegistrar registrar_; | 1378 bool received_width_; |
| 1379 gfx::Size entire_page_size_; |
1378 | 1380 |
1379 DISALLOW_COPY_AND_ASSIGN(PageSnapshotTaker); | 1381 DISALLOW_COPY_AND_ASSIGN(PageSnapshotTaker); |
1380 }; | 1382 }; |
1381 | 1383 |
1382 class NTPInfoObserver : public content::NotificationObserver { | 1384 class NTPInfoObserver : public content::NotificationObserver { |
1383 public: | 1385 public: |
1384 NTPInfoObserver(AutomationProvider* automation, | 1386 NTPInfoObserver(AutomationProvider* automation, |
1385 IPC::Message* reply_message, | 1387 IPC::Message* reply_message, |
1386 CancelableRequestConsumer* consumer); | 1388 CancelableRequestConsumer* consumer); |
1387 virtual ~NTPInfoObserver(); | 1389 virtual ~NTPInfoObserver(); |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1802 private: | 1804 private: |
1803 content::NotificationRegistrar registrar_; | 1805 content::NotificationRegistrar registrar_; |
1804 base::WeakPtr<AutomationProvider> automation_; | 1806 base::WeakPtr<AutomationProvider> automation_; |
1805 scoped_ptr<IPC::Message> reply_message_; | 1807 scoped_ptr<IPC::Message> reply_message_; |
1806 int new_window_id_; | 1808 int new_window_id_; |
1807 | 1809 |
1808 DISALLOW_COPY_AND_ASSIGN(BrowserOpenedWithNewProfileNotificationObserver); | 1810 DISALLOW_COPY_AND_ASSIGN(BrowserOpenedWithNewProfileNotificationObserver); |
1809 }; | 1811 }; |
1810 | 1812 |
1811 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ | 1813 #endif // CHROME_BROWSER_AUTOMATION_AUTOMATION_PROVIDER_OBSERVERS_H_ |
OLD | NEW |