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

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: sync to r184453 Created 7 years, 10 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"
(...skipping 17 matching lines...) Expand all
28 #include "ui/base/keycodes/keyboard_codes.h" 28 #include "ui/base/keycodes/keyboard_codes.h"
29 #include "ui/views/focus/accelerator_handler.h" 29 #include "ui/views/focus/accelerator_handler.h"
30 #include "ui/views/widget/root_view.h" 30 #include "ui/views/widget/root_view.h"
31 31
32 using content::NavigationController; 32 using content::NavigationController;
33 using content::RenderViewHost; 33 using content::RenderViewHost;
34 using content::WebContents; 34 using content::WebContents;
35 35
36 void AutomationProvider::CreateExternalTab( 36 void AutomationProvider::CreateExternalTab(
37 const ExternalTabSettings& settings, 37 const ExternalTabSettings& settings,
38 gfx::NativeWindow* tab_container_window, gfx::NativeWindow* tab_window, 38 HWND* tab_container_window,
39 int* tab_handle, int* session_id) { 39 HWND* tab_window,
40 int* tab_handle,
41 int* session_id) {
40 TRACE_EVENT_BEGIN_ETW("AutomationProvider::CreateExternalTab", 0, ""); 42 TRACE_EVENT_BEGIN_ETW("AutomationProvider::CreateExternalTab", 0, "");
41 43
42 *tab_handle = 0; 44 *tab_handle = 0;
43 *tab_container_window = NULL; 45 *tab_container_window = NULL;
44 *tab_window = NULL; 46 *tab_window = NULL;
45 *session_id = -1; 47 *session_id = -1;
46 scoped_refptr<ExternalTabContainer> external_tab_container = 48 scoped_refptr<ExternalTabContainer> external_tab_container =
47 ExternalTabContainer::Create(this, automation_resource_message_filter_); 49 ExternalTabContainer::Create(this, automation_resource_message_filter_);
48 50
49 Profile* profile = settings.is_incognito ? 51 Profile* profile = settings.is_incognito ?
50 profile_->GetOffTheRecordProfile() : profile_; 52 profile_->GetOffTheRecordProfile() : profile_;
51 53
52 // 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
53 // which is released when the window is destroyed. 55 // which is released when the window is destroyed.
54 external_tab_container->Init(profile, settings.parent, settings.dimensions, 56 external_tab_container->Init(profile, settings.parent, settings.dimensions,
55 settings.style, settings.load_requests_via_automation, 57 settings.style, settings.load_requests_via_automation,
56 settings.handle_top_level_requests, NULL, settings.initial_url, 58 settings.handle_top_level_requests, NULL, settings.initial_url,
57 settings.referrer, settings.infobars_enabled, 59 settings.referrer, settings.infobars_enabled,
58 settings.route_all_top_level_navigations); 60 settings.route_all_top_level_navigations);
59 61
60 if (AddExternalTab(external_tab_container)) { 62 if (AddExternalTab(external_tab_container)) {
61 WebContents* web_contents = external_tab_container->GetWebContents(); 63 WebContents* web_contents = external_tab_container->GetWebContents();
62 SessionTabHelper* session_tab_helper = 64 SessionTabHelper* session_tab_helper =
63 SessionTabHelper::FromWebContents(web_contents); 65 SessionTabHelper::FromWebContents(web_contents);
64 *tab_handle = external_tab_container->GetTabHandle(); 66 *tab_handle = external_tab_container->GetTabHandle();
65 *tab_container_window = external_tab_container->GetExternalTabNativeView(); 67 *tab_container_window = external_tab_container->GetExternalTabHWND();
66 *tab_window = web_contents->GetNativeView(); 68 *tab_window = external_tab_container->GetContentHWND();
67 *session_id = session_tab_helper->session_id().id(); 69 *session_id = session_tab_helper->session_id().id();
68 } else { 70 } else {
69 external_tab_container->Uninitialize(); 71 external_tab_container->Uninitialize();
70 } 72 }
71 73
72 TRACE_EVENT_END_ETW("AutomationProvider::CreateExternalTab", 0, ""); 74 TRACE_EVENT_END_ETW("AutomationProvider::CreateExternalTab", 0, "");
73 } 75 }
74 76
75 bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) { 77 bool AutomationProvider::AddExternalTab(ExternalTabContainer* external_tab) {
76 DCHECK(external_tab != NULL); 78 DCHECK(external_tab != NULL);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 return; 112 return;
111 113
112 printing::PrintViewManager* print_view_manager = 114 printing::PrintViewManager* print_view_manager =
113 printing::PrintViewManager::FromWebContents(web_contents); 115 printing::PrintViewManager::FromWebContents(web_contents);
114 print_view_manager->PrintNow(); 116 print_view_manager->PrintNow();
115 } 117 }
116 118
117 ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { 119 ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) {
118 if (tab_tracker_->ContainsHandle(handle)) { 120 if (tab_tracker_->ContainsHandle(handle)) {
119 NavigationController* tab = tab_tracker_->GetResource(handle); 121 NavigationController* tab = tab_tracker_->GetResource(handle);
120 return ExternalTabContainer::GetContainerForTab( 122 return ExternalTabContainer::GetContainerForTab(tab->GetWebContents());
121 tab->GetWebContents()->GetNativeView());
122 } 123 }
123 124
124 return NULL; 125 return NULL;
125 } 126 }
126 127
127 void AutomationProvider::OnTabReposition( 128 void AutomationProvider::OnTabReposition(
128 int tab_handle, const Reposition_Params& params) { 129 int tab_handle,
130 const Reposition_Params& params) {
129 if (!tab_tracker_->ContainsHandle(tab_handle)) 131 if (!tab_tracker_->ContainsHandle(tab_handle))
130 return; 132 return;
131 133
132 if (!IsWindow(params.window)) 134 if (!IsWindow(params.window))
133 return; 135 return;
134 136
135 unsigned long process_id = 0; 137 unsigned long process_id = 0;
136 unsigned long thread_id = 0; 138 unsigned long thread_id = 0;
137 139
138 thread_id = GetWindowThreadProcessId(params.window, &process_id); 140 thread_id = GetWindowThreadProcessId(params.window, &process_id);
(...skipping 14 matching lines...) Expand all
153 } 155 }
154 } 156 }
155 157
156 void AutomationProvider::OnForwardContextMenuCommandToChrome(int tab_handle, 158 void AutomationProvider::OnForwardContextMenuCommandToChrome(int tab_handle,
157 int command) { 159 int command) {
158 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); 160 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle);
159 if (external_tab) 161 if (external_tab)
160 external_tab->ExecuteContextMenuCommand(command); 162 external_tab->ExecuteContextMenuCommand(command);
161 } 163 }
162 164
163 void AutomationProvider::ConnectExternalTab( 165 void AutomationProvider::ConnectExternalTab(uint64 cookie,
164 uint64 cookie, 166 bool allow,
165 bool allow, 167 HWND parent_window,
166 gfx::NativeWindow parent_window, 168 HWND* tab_container_window,
167 gfx::NativeWindow* tab_container_window, 169 HWND* tab_window,
168 gfx::NativeWindow* tab_window, 170 int* tab_handle,
169 int* tab_handle, 171 int* session_id) {
170 int* session_id) {
171 TRACE_EVENT_BEGIN_ETW("AutomationProvider::ConnectExternalTab", 0, ""); 172 TRACE_EVENT_BEGIN_ETW("AutomationProvider::ConnectExternalTab", 0, "");
172 173
173 *tab_handle = 0; 174 *tab_handle = 0;
174 *tab_container_window = NULL; 175 *tab_container_window = NULL;
175 *tab_window = NULL; 176 *tab_window = NULL;
176 *session_id = -1; 177 *session_id = -1;
177 178
178 scoped_refptr<ExternalTabContainer> external_tab_container = 179 scoped_refptr<ExternalTabContainer> external_tab_container =
179 ExternalTabContainer::RemovePendingTab(static_cast<uintptr_t>(cookie)); 180 ExternalTabContainer::RemovePendingTab(static_cast<uintptr_t>(cookie));
180 if (!external_tab_container.get()) { 181 if (!external_tab_container.get()) {
181 NOTREACHED(); 182 NOTREACHED();
182 return; 183 return;
183 } 184 }
184 185
185 if (allow && AddExternalTab(external_tab_container)) { 186 if (allow && AddExternalTab(external_tab_container)) {
186 external_tab_container->Reinitialize(this, 187 external_tab_container->Reinitialize(this,
187 automation_resource_message_filter_, 188 automation_resource_message_filter_,
188 parent_window); 189 parent_window);
189 WebContents* web_contents = external_tab_container->GetWebContents(); 190 WebContents* web_contents = external_tab_container->GetWebContents();
190 SessionTabHelper* session_tab_helper = 191 SessionTabHelper* session_tab_helper =
191 SessionTabHelper::FromWebContents(web_contents); 192 SessionTabHelper::FromWebContents(web_contents);
192 *tab_handle = external_tab_container->GetTabHandle(); 193 *tab_handle = external_tab_container->GetTabHandle();
193 *tab_container_window = external_tab_container->GetExternalTabNativeView(); 194 *tab_container_window = external_tab_container->GetExternalTabHWND();
194 *tab_window = web_contents->GetNativeView(); 195 *tab_window = external_tab_container->GetContentHWND();
195 *session_id = session_tab_helper->session_id().id(); 196 *session_id = session_tab_helper->session_id().id();
196 } else { 197 } else {
197 external_tab_container->Uninitialize(); 198 external_tab_container->Uninitialize();
198 } 199 }
199 200
200 TRACE_EVENT_END_ETW("AutomationProvider::ConnectExternalTab", 0, ""); 201 TRACE_EVENT_END_ETW("AutomationProvider::ConnectExternalTab", 0, "");
201 } 202 }
202 203
203 void AutomationProvider::OnBrowserMoved(int tab_handle) { 204 void AutomationProvider::OnBrowserMoved(int tab_handle) {
204 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle); 205 ExternalTabContainer* external_tab = GetExternalTabForHandle(tab_handle);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) { 259 void AutomationProvider::OnSetZoomLevel(int handle, int zoom_level) {
259 if (tab_tracker_->ContainsHandle(handle)) { 260 if (tab_tracker_->ContainsHandle(handle)) {
260 NavigationController* tab = tab_tracker_->GetResource(handle); 261 NavigationController* tab = tab_tracker_->GetResource(handle);
261 if (tab->GetWebContents() && tab->GetWebContents()->GetRenderViewHost()) { 262 if (tab->GetWebContents() && tab->GetWebContents()->GetRenderViewHost()) {
262 RenderViewHost* host = tab->GetWebContents()->GetRenderViewHost(); 263 RenderViewHost* host = tab->GetWebContents()->GetRenderViewHost();
263 content::PageZoom zoom = static_cast<content::PageZoom>(zoom_level); 264 content::PageZoom zoom = static_cast<content::PageZoom>(zoom_level);
264 host->Zoom(zoom); 265 host->Zoom(zoom);
265 } 266 }
266 } 267 }
267 } 268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698