| 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 #include "chrome/browser/automation/automation_provider.h" | 5 #include "chrome/browser/automation/automation_provider.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 using base::Time; | 105 using base::Time; |
| 106 | 106 |
| 107 AutomationProvider::AutomationProvider(Profile* profile) | 107 AutomationProvider::AutomationProvider(Profile* profile) |
| 108 : profile_(profile), | 108 : profile_(profile), |
| 109 reply_message_(NULL), | 109 reply_message_(NULL), |
| 110 reinitialize_on_channel_error_(false), | 110 reinitialize_on_channel_error_(false), |
| 111 is_connected_(false), | 111 is_connected_(false), |
| 112 initial_tab_loads_complete_(false), | 112 initial_tab_loads_complete_(false), |
| 113 network_library_initialized_(true) { | 113 network_library_initialized_(true) { |
| 114 TRACE_EVENT_BEGIN("AutomationProvider::AutomationProvider", 0, ""); | 114 TRACE_EVENT_BEGIN_ETW("AutomationProvider::AutomationProvider", 0, ""); |
| 115 | 115 |
| 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 116 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 117 | 117 |
| 118 browser_tracker_.reset(new AutomationBrowserTracker(this)); | 118 browser_tracker_.reset(new AutomationBrowserTracker(this)); |
| 119 extension_tracker_.reset(new AutomationExtensionTracker(this)); | 119 extension_tracker_.reset(new AutomationExtensionTracker(this)); |
| 120 tab_tracker_.reset(new AutomationTabTracker(this)); | 120 tab_tracker_.reset(new AutomationTabTracker(this)); |
| 121 window_tracker_.reset(new AutomationWindowTracker(this)); | 121 window_tracker_.reset(new AutomationWindowTracker(this)); |
| 122 automation_omnibox_tracker_.reset(new AutomationOmniboxTracker(this)); | 122 automation_omnibox_tracker_.reset(new AutomationOmniboxTracker(this)); |
| 123 new_tab_ui_load_observer_.reset(new NewTabUILoadObserver(this)); | 123 new_tab_ui_load_observer_.reset(new NewTabUILoadObserver(this)); |
| 124 metric_event_duration_observer_.reset(new MetricEventDurationObserver()); | 124 metric_event_duration_observer_.reset(new MetricEventDurationObserver()); |
| 125 extension_test_result_observer_.reset( | 125 extension_test_result_observer_.reset( |
| 126 new ExtensionTestResultNotificationObserver(this)); | 126 new ExtensionTestResultNotificationObserver(this)); |
| 127 g_browser_process->AddRefModule(); | 127 g_browser_process->AddRefModule(); |
| 128 | 128 |
| 129 TRACE_EVENT_END("AutomationProvider::AutomationProvider", 0, ""); | 129 TRACE_EVENT_END_ETW("AutomationProvider::AutomationProvider", 0, ""); |
| 130 } | 130 } |
| 131 | 131 |
| 132 AutomationProvider::~AutomationProvider() { | 132 AutomationProvider::~AutomationProvider() { |
| 133 if (channel_.get()) | 133 if (channel_.get()) |
| 134 channel_->Close(); | 134 channel_->Close(); |
| 135 | 135 |
| 136 g_browser_process->ReleaseModule(); | 136 g_browser_process->ReleaseModule(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 bool AutomationProvider::InitializeChannel(const std::string& channel_id) { | 139 bool AutomationProvider::InitializeChannel(const std::string& channel_id) { |
| 140 TRACE_EVENT_BEGIN("AutomationProvider::InitializeChannel", 0, ""); | 140 TRACE_EVENT_BEGIN_ETW("AutomationProvider::InitializeChannel", 0, ""); |
| 141 | 141 |
| 142 channel_id_ = channel_id; | 142 channel_id_ = channel_id; |
| 143 std::string effective_channel_id = channel_id; | 143 std::string effective_channel_id = channel_id; |
| 144 | 144 |
| 145 // If the channel_id starts with kNamedInterfacePrefix, create a named IPC | 145 // If the channel_id starts with kNamedInterfacePrefix, create a named IPC |
| 146 // server and listen on it, else connect as client to an existing IPC server | 146 // server and listen on it, else connect as client to an existing IPC server |
| 147 bool use_named_interface = | 147 bool use_named_interface = |
| 148 channel_id.find(automation::kNamedInterfacePrefix) == 0; | 148 channel_id.find(automation::kNamedInterfacePrefix) == 0; |
| 149 if (use_named_interface) { | 149 if (use_named_interface) { |
| 150 effective_channel_id = channel_id.substr( | 150 effective_channel_id = channel_id.substr( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 169 | 169 |
| 170 #if defined(OS_CHROMEOS) | 170 #if defined(OS_CHROMEOS) |
| 171 // Wait for the network manager to initialize. | 171 // Wait for the network manager to initialize. |
| 172 // The observer will delete itself when done. | 172 // The observer will delete itself when done. |
| 173 network_library_initialized_ = false; | 173 network_library_initialized_ = false; |
| 174 NetworkManagerInitObserver* observer = new NetworkManagerInitObserver(this); | 174 NetworkManagerInitObserver* observer = new NetworkManagerInitObserver(this); |
| 175 if (!observer->Init()) | 175 if (!observer->Init()) |
| 176 delete observer; | 176 delete observer; |
| 177 #endif | 177 #endif |
| 178 | 178 |
| 179 TRACE_EVENT_END("AutomationProvider::InitializeChannel", 0, ""); | 179 TRACE_EVENT_END_ETW("AutomationProvider::InitializeChannel", 0, ""); |
| 180 | 180 |
| 181 return true; | 181 return true; |
| 182 } | 182 } |
| 183 | 183 |
| 184 IPC::Channel::Mode AutomationProvider::GetChannelMode( | 184 IPC::Channel::Mode AutomationProvider::GetChannelMode( |
| 185 bool use_named_interface) { | 185 bool use_named_interface) { |
| 186 if (use_named_interface) | 186 if (use_named_interface) |
| 187 return IPC::Channel::MODE_NAMED_SERVER; | 187 return IPC::Channel::MODE_NAMED_SERVER; |
| 188 else | 188 else |
| 189 return IPC::Channel::MODE_CLIENT; | 189 return IPC::Channel::MODE_CLIENT; |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 | 969 |
| 970 void AutomationProvider::SaveAsAsync(int tab_handle) { | 970 void AutomationProvider::SaveAsAsync(int tab_handle) { |
| 971 NavigationController* tab = NULL; | 971 NavigationController* tab = NULL; |
| 972 TabContents* tab_contents = GetTabContentsForHandle(tab_handle, &tab); | 972 TabContents* tab_contents = GetTabContentsForHandle(tab_handle, &tab); |
| 973 if (tab_contents) { | 973 if (tab_contents) { |
| 974 TabContentsWrapper* wrapper = | 974 TabContentsWrapper* wrapper = |
| 975 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); | 975 TabContentsWrapper::GetCurrentWrapperForContents(tab_contents); |
| 976 wrapper->download_tab_helper()->OnSavePage(); | 976 wrapper->download_tab_helper()->OnSavePage(); |
| 977 } | 977 } |
| 978 } | 978 } |
| OLD | NEW |