Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: chrome/browser/automation/automation_provider_win.cc

Issue 12220101: Minimal Chrome Frame with Aura. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: revert install_worker.cc to un-break win64 build Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.h" 5 #include "chrome/browser/automation/automation_provider.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/automation/automation_browser_tracker.h" 13 #include "chrome/browser/automation/automation_browser_tracker.h"
14 #include "chrome/browser/automation/automation_tab_tracker.h" 14 #include "chrome/browser/automation/automation_tab_tracker.h"
15 #include "chrome/browser/automation/automation_window_tracker.h" 15 #include "chrome/browser/automation/automation_window_tracker.h"
16 #include "chrome/browser/external_tab/external_tab_container.h" 16 #include "chrome/browser/external_tab/external_tab_container.h"
17 #include "chrome/browser/printing/print_view_manager.h" 17 #include "chrome/browser/printing/print_view_manager.h"
18 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
19 #include "chrome/browser/sessions/session_tab_helper.h" 19 #include "chrome/browser/sessions/session_tab_helper.h"
20 #include "chrome/browser/ui/browser.h" 20 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/browser_window.h" 21 #include "chrome/browser/ui/browser_window.h"
22 #include "chrome/common/automation_messages.h" 22 #include "chrome/common/automation_messages.h"
23 #include "chrome/common/render_messages.h" 23 #include "chrome/common/render_messages.h"
24 #include "content/public/browser/navigation_controller.h" 24 #include "content/public/browser/navigation_controller.h"
25 #include "content/public/browser/render_view_host.h" 25 #include "content/public/browser/render_view_host.h"
26 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
27 #include "content/public/browser/web_contents_view.h"
28 #include "content/public/common/page_zoom.h" 27 #include "content/public/common/page_zoom.h"
29 #include "ui/base/keycodes/keyboard_codes.h" 28 #include "ui/base/keycodes/keyboard_codes.h"
30 #include "ui/views/focus/accelerator_handler.h" 29 #include "ui/views/focus/accelerator_handler.h"
31 #include "ui/views/widget/root_view.h" 30 #include "ui/views/widget/root_view.h"
32 31
33 using content::NavigationController; 32 using content::NavigationController;
34 using content::RenderViewHost; 33 using content::RenderViewHost;
35 using content::WebContents; 34 using content::WebContents;
36 35
37 void AutomationProvider::CreateExternalTab( 36 void AutomationProvider::CreateExternalTab(
38 const ExternalTabSettings& settings, 37 const ExternalTabSettings& settings,
39 gfx::NativeWindow* tab_container_window, gfx::NativeWindow* tab_window, 38 HWND* tab_container_window,
40 int* tab_handle, int* session_id) { 39 HWND* tab_window,
40 int* tab_handle,
41 int* session_id) {
41 TRACE_EVENT_BEGIN_ETW("AutomationProvider::CreateExternalTab", 0, ""); 42 TRACE_EVENT_BEGIN_ETW("AutomationProvider::CreateExternalTab", 0, "");
42 43
43 *tab_handle = 0; 44 *tab_handle = 0;
44 *tab_container_window = NULL; 45 *tab_container_window = NULL;
45 *tab_window = NULL; 46 *tab_window = NULL;
46 *session_id = -1; 47 *session_id = -1;
47 scoped_refptr<ExternalTabContainer> external_tab_container = 48 scoped_refptr<ExternalTabContainer> external_tab_container =
48 ExternalTabContainer::Create(this, automation_resource_message_filter_); 49 ExternalTabContainer::Create(this, automation_resource_message_filter_);
49 50
50 Profile* profile = settings.is_incognito ? 51 Profile* profile = settings.is_incognito ?
51 profile_->GetOffTheRecordProfile() : profile_; 52 profile_->GetOffTheRecordProfile() : profile_;
52 53
53 // When the ExternalTabContainer window is created we grab a reference on it 54 // When the ExternalTabContainer window is created we grab a reference on it
54 // which is released when the window is destroyed. 55 // which is released when the window is destroyed.
55 external_tab_container->Init(profile, settings.parent, settings.dimensions, 56 external_tab_container->Init(profile, settings.parent, settings.dimensions,
56 settings.style, settings.load_requests_via_automation, 57 settings.style, settings.load_requests_via_automation,
57 settings.handle_top_level_requests, NULL, settings.initial_url, 58 settings.handle_top_level_requests, NULL, settings.initial_url,
58 settings.referrer, settings.infobars_enabled, 59 settings.referrer, settings.infobars_enabled,
59 settings.route_all_top_level_navigations); 60 settings.route_all_top_level_navigations);
60 61
61 if (AddExternalTab(external_tab_container)) { 62 if (AddExternalTab(external_tab_container)) {
62 WebContents* web_contents = external_tab_container->GetWebContents(); 63 WebContents* web_contents = external_tab_container->GetWebContents();
63 SessionTabHelper* session_tab_helper = 64 SessionTabHelper* session_tab_helper =
64 SessionTabHelper::FromWebContents(web_contents); 65 SessionTabHelper::FromWebContents(web_contents);
65 *tab_handle = external_tab_container->GetTabHandle(); 66 *tab_handle = external_tab_container->GetTabHandle();
66 *tab_container_window = external_tab_container->GetExternalTabNativeView(); 67 *tab_container_window = external_tab_container->GetExternalTabHWND();
67 *tab_window = web_contents->GetView()->GetNativeView(); 68 *tab_window = external_tab_container->GetContentHWND();
68 *session_id = session_tab_helper->session_id().id(); 69 *session_id = session_tab_helper->session_id().id();
69 } else { 70 } else {
70 external_tab_container->Uninitialize(); 71 external_tab_container->Uninitialize();
71 } 72 }
72 73
73 TRACE_EVENT_END_ETW("AutomationProvider::CreateExternalTab", 0, ""); 74 TRACE_EVENT_END_ETW("AutomationProvider::CreateExternalTab", 0, "");
74 } 75 }
75 76
76 bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) { 77 bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) {
77 DCHECK(external_tab != NULL); 78 DCHECK(external_tab != NULL);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 return; 112 return;
112 113
113 printing::PrintViewManager* print_view_manager = 114 printing::PrintViewManager* print_view_manager =
114 printing::PrintViewManager::FromWebContents(web_contents); 115 printing::PrintViewManager::FromWebContents(web_contents);
115 print_view_manager->PrintNow(); 116 print_view_manager->PrintNow();
116 } 117 }
117 118
118 ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { 119 ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) {
119 if (tab_tracker_->ContainsHandle(handle)) { 120 if (tab_tracker_->ContainsHandle(handle)) {
120 NavigationController* tab = tab_tracker_->GetResource(handle); 121 NavigationController* tab = tab_tracker_->GetResource(handle);
121 return ExternalTabContainer::GetContainerForTab( 122 return ExternalTabContainer::GetContainerForTab(tab->GetWebContents());
122 tab->GetWebContents()->GetView()->GetNativeView());
123 } 123 }
124 124
125 return NULL; 125 return NULL;
126 } 126 }
127 127
128 void AutomationProvider::OnTabReposition( 128 void AutomationProvider::OnTabReposition(int tab_handle,
129 int tab_handle, const Reposition_Params& params) { 129 const Reposition_Params& params) {
130 if (!tab_tracker_->ContainsHandle(tab_handle)) 130 if (!tab_tracker_->ContainsHandle(tab_handle))
131 return; 131 return;
132 132
133 if (!IsWindow(params.window)) 133 if (!IsWindow(params.window))
134 return; 134 return;
135 135
136 unsigned long process_id = 0; 136 unsigned long process_id = 0;
137 unsigned long thread_id = 0; 137 unsigned long thread_id = 0;
138 138
139 thread_id = GetWindowThreadProcessId(params.window, &process_id); 139 thread_id = GetWindowThreadProcessId(params.window, &process_id);
(...skipping 14 matching lines...) Expand all
154 } 154 }
155 } 155 }
156 156
157 void AutomationProvider::OnForwardContextMenuCommandToChrome(int tab_handle, 157 void AutomationProvider::OnForwardContextMenuCommandToChrome(int tab_handle,
158 int command) { 158 int command) {
159 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); 159 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle);
160 if (external_tab) 160 if (external_tab)
161 external_tab->ExecuteContextMenuCommand(command); 161 external_tab->ExecuteContextMenuCommand(command);
162 } 162 }
163 163
164 void AutomationProvider::ConnectExternalTab( 164 void AutomationProvider::ConnectExternalTab(uint64 cookie,
165 uint64 cookie, 165 bool allow,
166 bool allow, 166 HWND parent_window,
167 gfx::NativeWindow parent_window, 167 HWND* tab_container_window,
168 gfx::NativeWindow* tab_container_window, 168 HWND* tab_window,
169 gfx::NativeWindow* tab_window, 169 int* tab_handle,
170 int* tab_handle, 170 int* session_id) {
171 int* session_id) {
172 TRACE_EVENT_BEGIN_ETW("AutomationProvider::ConnectExternalTab", 0, ""); 171 TRACE_EVENT_BEGIN_ETW("AutomationProvider::ConnectExternalTab", 0, "");
173 172
174 *tab_handle = 0; 173 *tab_handle = 0;
175 *tab_container_window = NULL; 174 *tab_container_window = NULL;
176 *tab_window = NULL; 175 *tab_window = NULL;
177 *session_id = -1; 176 *session_id = -1;
178 177
179 scoped_refptr<ExternalTabContainer> external_tab_container = 178 scoped_refptr<ExternalTabContainer> external_tab_container =
180 ExternalTabContainer::RemovePendingTab(static_cast<uintptr_t>(cookie)); 179 ExternalTabContainer::RemovePendingTab(static_cast<uintptr_t>(cookie));
181 if (!external_tab_container.get()) { 180 if (!external_tab_container.get()) {
182 NOTREACHED(); 181 NOTREACHED();
183 return; 182 return;
184 } 183 }
185 184
186 if (allow && AddExternalTab(external_tab_container)) { 185 if (allow && AddExternalTab(external_tab_container)) {
187 external_tab_container->Reinitialize(this, 186 external_tab_container->Reinitialize(this,
188 automation_resource_message_filter_, 187 automation_resource_message_filter_,
189 parent_window); 188 parent_window);
190 WebContents* web_contents = external_tab_container->GetWebContents(); 189 WebContents* web_contents = external_tab_container->GetWebContents();
191 SessionTabHelper* session_tab_helper = 190 SessionTabHelper* session_tab_helper =
192 SessionTabHelper::FromWebContents(web_contents); 191 SessionTabHelper::FromWebContents(web_contents);
193 *tab_handle = external_tab_container->GetTabHandle(); 192 *tab_handle = external_tab_container->GetTabHandle();
194 *tab_container_window = external_tab_container->GetExternalTabNativeView(); 193 *tab_container_window = external_tab_container->GetExternalTabHWND();
195 *tab_window = web_contents->GetView()->GetNativeView(); 194 *tab_window = external_tab_container->GetContentHWND();
196 *session_id = session_tab_helper->session_id().id(); 195 *session_id = session_tab_helper->session_id().id();
197 } else { 196 } else {
198 external_tab_container->Uninitialize(); 197 external_tab_container->Uninitialize();
199 } 198 }
200 199
201 TRACE_EVENT_END_ETW("AutomationProvider::ConnectExternalTab", 0, ""); 200 TRACE_EVENT_END_ETW("AutomationProvider::ConnectExternalTab", 0, "");
202 } 201 }
203 202
204 void AutomationProvider::OnBrowserMoved(int tab_handle) { 203 void AutomationProvider::OnBrowserMoved(int tab_handle) {
205 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); 204 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { 258 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) {
260 if (tab_tracker_->ContainsHandle(handle)) { 259 if (tab_tracker_->ContainsHandle(handle)) {
261 NavigationController* tab = tab_tracker_->GetResource(handle); 260 NavigationController* tab = tab_tracker_->GetResource(handle);
262 if (tab->GetWebContents() && tab->GetWebContents()->GetRenderViewHost()) { 261 if (tab->GetWebContents() && tab->GetWebContents()->GetRenderViewHost()) {
263 RenderViewHost* host = tab->GetWebContents()->GetRenderViewHost(); 262 RenderViewHost* host = tab->GetWebContents()->GetRenderViewHost();
264 content::PageZoom zoom = static_cast<content::PageZoom>(zoom_level); 263 content::PageZoom zoom = static_cast<content::PageZoom>(zoom_level);
265 host->Zoom(zoom); 264 host->Zoom(zoom);
266 } 265 }
267 } 266 }
268 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698