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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #include "chrome/browser/search_engines/template_url_service_factory.h" | 52 #include "chrome/browser/search_engines/template_url_service_factory.h" |
53 #include "chrome/browser/sessions/session_tab_helper.h" | 53 #include "chrome/browser/sessions/session_tab_helper.h" |
54 #include "chrome/browser/sessions/tab_restore_service.h" | 54 #include "chrome/browser/sessions/tab_restore_service.h" |
55 #include "chrome/browser/sessions/tab_restore_service_factory.h" | 55 #include "chrome/browser/sessions/tab_restore_service_factory.h" |
56 #include "chrome/browser/ui/browser.h" | 56 #include "chrome/browser/ui/browser.h" |
57 #include "chrome/browser/ui/browser_list.h" | 57 #include "chrome/browser/ui/browser_list.h" |
58 #include "chrome/browser/ui/browser_tabstrip.h" | 58 #include "chrome/browser/ui/browser_tabstrip.h" |
59 #include "chrome/browser/ui/browser_window.h" | 59 #include "chrome/browser/ui/browser_window.h" |
60 #include "chrome/browser/ui/find_bar/find_notification_details.h" | 60 #include "chrome/browser/ui/find_bar/find_notification_details.h" |
61 #include "chrome/browser/ui/login/login_prompt.h" | 61 #include "chrome/browser/ui/login/login_prompt.h" |
62 #include "chrome/browser/ui/tab_contents/tab_contents.h" | |
63 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" | 62 #include "chrome/browser/ui/webui/ntp/app_launcher_handler.h" |
64 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" | 63 #include "chrome/browser/ui/webui/ntp/most_visited_handler.h" |
65 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 64 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
66 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" | 65 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" |
67 #include "chrome/common/automation_constants.h" | 66 #include "chrome/common/automation_constants.h" |
68 #include "chrome/common/automation_messages.h" | 67 #include "chrome/common/automation_messages.h" |
69 #include "chrome/common/chrome_notification_types.h" | 68 #include "chrome/common/chrome_notification_types.h" |
70 #include "chrome/common/content_settings_types.h" | 69 #include "chrome/common/content_settings_types.h" |
71 #include "chrome/common/extensions/extension.h" | 70 #include "chrome/common/extensions/extension.h" |
72 #include "chrome/common/view_type.h" | 71 #include "chrome/common/view_type.h" |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1196 return; | 1195 return; |
1197 } | 1196 } |
1198 MetricEventDurationDetails* metric_event_duration = | 1197 MetricEventDurationDetails* metric_event_duration = |
1199 content::Details<MetricEventDurationDetails>(details).ptr(); | 1198 content::Details<MetricEventDurationDetails>(details).ptr(); |
1200 durations_[metric_event_duration->event_name] = | 1199 durations_[metric_event_duration->event_name] = |
1201 metric_event_duration->duration_ms; | 1200 metric_event_duration->duration_ms; |
1202 } | 1201 } |
1203 | 1202 |
1204 InfoBarCountObserver::InfoBarCountObserver(AutomationProvider* automation, | 1203 InfoBarCountObserver::InfoBarCountObserver(AutomationProvider* automation, |
1205 IPC::Message* reply_message, | 1204 IPC::Message* reply_message, |
1206 TabContents* tab_contents, | 1205 WebContents* web_contents, |
1207 size_t target_count) | 1206 size_t target_count) |
1208 : automation_(automation->AsWeakPtr()), | 1207 : automation_(automation->AsWeakPtr()), |
1209 reply_message_(reply_message), | 1208 reply_message_(reply_message), |
1210 tab_contents_(tab_contents), | 1209 web_contents_(web_contents), |
1211 target_count_(target_count) { | 1210 target_count_(target_count) { |
1212 content::Source<InfoBarTabHelper> source( | 1211 content::Source<InfoBarTabHelper> source( |
1213 InfoBarTabHelper::FromWebContents(tab_contents->web_contents())); | 1212 InfoBarTabHelper::FromWebContents(web_contents)); |
1214 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, | 1213 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED, |
1215 source); | 1214 source); |
1216 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, | 1215 registrar_.Add(this, chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
1217 source); | 1216 source); |
1218 CheckCount(); | 1217 CheckCount(); |
1219 } | 1218 } |
1220 | 1219 |
1221 InfoBarCountObserver::~InfoBarCountObserver() {} | 1220 InfoBarCountObserver::~InfoBarCountObserver() {} |
1222 | 1221 |
1223 void InfoBarCountObserver::Observe( | 1222 void InfoBarCountObserver::Observe( |
1224 int type, | 1223 int type, |
1225 const content::NotificationSource& source, | 1224 const content::NotificationSource& source, |
1226 const content::NotificationDetails& details) { | 1225 const content::NotificationDetails& details) { |
1227 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED || | 1226 DCHECK(type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED || |
1228 type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED); | 1227 type == chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED); |
1229 CheckCount(); | 1228 CheckCount(); |
1230 } | 1229 } |
1231 | 1230 |
1232 void InfoBarCountObserver::CheckCount() { | 1231 void InfoBarCountObserver::CheckCount() { |
1233 InfoBarTabHelper* infobar_tab_helper = | 1232 InfoBarTabHelper* infobar_tab_helper = |
1234 InfoBarTabHelper::FromWebContents(tab_contents_->web_contents()); | 1233 InfoBarTabHelper::FromWebContents(web_contents_); |
1235 if (infobar_tab_helper->GetInfoBarCount() != target_count_) | 1234 if (infobar_tab_helper->GetInfoBarCount() != target_count_) |
1236 return; | 1235 return; |
1237 | 1236 |
1238 if (automation_) { | 1237 if (automation_) { |
1239 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_.get(), | 1238 AutomationMsg_WaitForInfoBarCount::WriteReplyParams(reply_message_.get(), |
1240 true); | 1239 true); |
1241 automation_->Send(reply_message_.release()); | 1240 automation_->Send(reply_message_.release()); |
1242 } | 1241 } |
1243 delete this; | 1242 delete this; |
1244 } | 1243 } |
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1723 reply_message_.release()).SendSuccess(NULL); | 1722 reply_message_.release()).SendSuccess(NULL); |
1724 } | 1723 } |
1725 delete this; | 1724 delete this; |
1726 } else { | 1725 } else { |
1727 NOTREACHED(); | 1726 NOTREACHED(); |
1728 } | 1727 } |
1729 } | 1728 } |
1730 | 1729 |
1731 PageSnapshotTaker::PageSnapshotTaker(AutomationProvider* automation, | 1730 PageSnapshotTaker::PageSnapshotTaker(AutomationProvider* automation, |
1732 IPC::Message* reply_message, | 1731 IPC::Message* reply_message, |
1733 TabContents* tab_contents, | 1732 WebContents* web_contents, |
1734 const FilePath& path) | 1733 const FilePath& path) |
1735 : automation_(automation->AsWeakPtr()), | 1734 : automation_(automation->AsWeakPtr()), |
1736 reply_message_(reply_message), | 1735 reply_message_(reply_message), |
1737 tab_contents_(tab_contents), | 1736 web_contents_(web_contents), |
1738 image_path_(path) { | 1737 image_path_(path) { |
1739 registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, | 1738 registrar_.Add(this, chrome::NOTIFICATION_APP_MODAL_DIALOG_SHOWN, |
1740 content::NotificationService::AllSources()); | 1739 content::NotificationService::AllSources()); |
1741 } | 1740 } |
1742 | 1741 |
1743 PageSnapshotTaker::~PageSnapshotTaker() {} | 1742 PageSnapshotTaker::~PageSnapshotTaker() {} |
1744 | 1743 |
1745 void PageSnapshotTaker::Start() { | 1744 void PageSnapshotTaker::Start() { |
1746 AutomationTabHelper* automation_tab_helper = | 1745 AutomationTabHelper* automation_tab_helper = |
1747 AutomationTabHelper::FromWebContents(tab_contents_->web_contents()); | 1746 AutomationTabHelper::FromWebContents(web_contents_); |
1748 StartObserving(automation_tab_helper); | 1747 StartObserving(automation_tab_helper); |
1749 automation_tab_helper->SnapshotEntirePage(); | 1748 automation_tab_helper->SnapshotEntirePage(); |
1750 } | 1749 } |
1751 | 1750 |
1752 void PageSnapshotTaker::OnSnapshotEntirePageACK( | 1751 void PageSnapshotTaker::OnSnapshotEntirePageACK( |
1753 bool success, | 1752 bool success, |
1754 const std::vector<unsigned char>& png_data, | 1753 const std::vector<unsigned char>& png_data, |
1755 const std::string& error_msg) { | 1754 const std::string& error_msg) { |
1756 bool overall_success = success; | 1755 bool overall_success = success; |
1757 std::string overall_error_msg = error_msg; | 1756 std::string overall_error_msg = error_msg; |
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2833 if (automation_) { | 2832 if (automation_) { |
2834 AutomationJSONReply(automation_, reply_message_.release()) | 2833 AutomationJSONReply(automation_, reply_message_.release()) |
2835 .SendSuccess(NULL); | 2834 .SendSuccess(NULL); |
2836 } | 2835 } |
2837 delete this; | 2836 delete this; |
2838 } | 2837 } |
2839 } else { | 2838 } else { |
2840 NOTREACHED(); | 2839 NOTREACHED(); |
2841 } | 2840 } |
2842 } | 2841 } |
OLD | NEW |