summaryrefslogtreecommitdiffstats
path: root/chrome/browser/automation/automation_provider_observers.h
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-11-25 19:40:10 +0000
committerBen Murdoch <benm@google.com>2010-12-03 13:52:53 +0000
commit4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7 (patch)
tree938665d93a11fe7a6d0124e3c1e020d1f9d3f947 /chrome/browser/automation/automation_provider_observers.h
parent7c627d87728a355737862918d144f98f69406954 (diff)
downloadexternal_chromium-4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7.zip
external_chromium-4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7.tar.gz
external_chromium-4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7.tar.bz2
Merge Chromium at r66597: Initial merge by git.
Change-Id: I9639f8a997f90ec219573aa22a49f5dbde78cc7b
Diffstat (limited to 'chrome/browser/automation/automation_provider_observers.h')
-rw-r--r--chrome/browser/automation/automation_provider_observers.h61
1 files changed, 56 insertions, 5 deletions
diff --git a/chrome/browser/automation/automation_provider_observers.h b/chrome/browser/automation/automation_provider_observers.h
index 7b76638..cfa6e14 100644
--- a/chrome/browser/automation/automation_provider_observers.h
+++ b/chrome/browser/automation/automation_provider_observers.h
@@ -21,10 +21,10 @@
#include "chrome/browser/password_manager/password_store.h"
#include "chrome/browser/search_engines/template_url_model_observer.h"
#include "chrome/browser/tabs/tab_strip_model.h"
+#include "chrome/common/automation_messages.h"
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/notification_type.h"
-#include "chrome/test/automation/automation_messages.h"
class AutocompleteEditModel;
class AutomationProvider;
@@ -33,6 +33,7 @@ class Browser;
class Extension;
class ExtensionProcessManager;
class NavigationController;
+class RenderViewHost;
class SavePackage;
class TabContents;
class TranslateInfoBarDelegate;
@@ -472,20 +473,34 @@ class FindInPageNotificationObserver : public NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(FindInPageNotificationObserver);
};
-class DomOperationNotificationObserver : public NotificationObserver {
+class DomOperationObserver : public NotificationObserver {
public:
- explicit DomOperationNotificationObserver(AutomationProvider* automation);
- ~DomOperationNotificationObserver();
+ DomOperationObserver();
+ virtual ~DomOperationObserver() {}
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details);
+ virtual void OnDomOperationCompleted(const std::string& json) = 0;
+
private:
NotificationRegistrar registrar_;
+
+ DISALLOW_COPY_AND_ASSIGN(DomOperationObserver);
+};
+
+class DomOperationMessageSender : public DomOperationObserver {
+ public:
+ explicit DomOperationMessageSender(AutomationProvider* automation)
+ : automation_(automation) {}
+
+ virtual void OnDomOperationCompleted(const std::string& json);
+
+ private:
AutomationProvider* automation_;
- DISALLOW_COPY_AND_ASSIGN(DomOperationNotificationObserver);
+ DISALLOW_COPY_AND_ASSIGN(DomOperationMessageSender);
};
class DocumentPrintedNotificationObserver : public NotificationObserver {
@@ -869,6 +884,42 @@ class SavePackageNotificationObserver : public NotificationObserver {
DISALLOW_COPY_AND_ASSIGN(SavePackageNotificationObserver);
};
+// This class manages taking a snapshot of a page. This requires waiting on
+// asynchronous callbacks and notifications.
+class PageSnapshotTaker : public DomOperationObserver {
+ public:
+ PageSnapshotTaker(AutomationProvider* automation,
+ IPC::Message* reply_message,
+ RenderViewHost* render_view,
+ const FilePath& path);
+
+ // Start the process of taking a snapshot of the entire page.
+ void Start();
+
+ private:
+ // Overriden from DomOperationObserver.
+ virtual void OnDomOperationCompleted(const std::string& json);
+
+ // Called by the ThumbnailGenerator when the requested snapshot has been
+ // generated.
+ void OnSnapshotTaken(const SkBitmap& bitmap);
+
+ // Helper method to send arbitrary javascript to the renderer for evaluation.
+ void ExecuteScript(const std::wstring& javascript);
+
+ // Helper method to send a response back to the client. Deletes this.
+ void SendMessage(bool success);
+
+ AutomationProvider* automation_;
+ IPC::Message* reply_message_;
+ RenderViewHost* render_view_;
+ FilePath image_path_;
+ bool received_width_;
+ gfx::Size entire_page_size_;
+
+ DISALLOW_COPY_AND_ASSIGN(PageSnapshotTaker);
+};
+
// Allows automation provider to wait until the autocomplete edit
// has received focus
class AutocompleteEditFocusedObserver : public NotificationObserver {