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