| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROME_FRAME_CHROME_FRAME_PLUGIN_H_ | 5 #ifndef CHROME_FRAME_CHROME_FRAME_PLUGIN_H_ |
| 6 #define CHROME_FRAME_CHROME_FRAME_PLUGIN_H_ | 6 #define CHROME_FRAME_CHROME_FRAME_PLUGIN_H_ |
| 7 | 7 |
| 8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
| 9 #include "base/win_util.h" | 9 #include "base/win_util.h" |
| 10 #include "chrome_frame/chrome_frame_automation.h" | 10 #include "chrome_frame/chrome_frame_automation.h" |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 automation_client_->SendContextMenuCommandToChromeFrame(selected); | 115 automation_client_->SendContextMenuCommandToChromeFrame(selected); |
| 116 } | 116 } |
| 117 } | 117 } |
| 118 | 118 |
| 119 DestroyMenu(copy); | 119 DestroyMenu(copy); |
| 120 } | 120 } |
| 121 | 121 |
| 122 LRESULT OnSetFocus(UINT message, WPARAM wparam, LPARAM lparam, | 122 LRESULT OnSetFocus(UINT message, WPARAM wparam, LPARAM lparam, |
| 123 BOOL& handled) { // NO_LINT | 123 BOOL& handled) { // NO_LINT |
| 124 if (!ignore_setfocus_ && automation_client_ != NULL) { | 124 if (!ignore_setfocus_ && automation_client_ != NULL) { |
| 125 TabProxy* tab = automation_client_->tab(); | 125 GiveFocusToChrome(); |
| 126 HWND chrome_window = automation_client_->tab_window(); | |
| 127 if (tab && ::IsWindow(chrome_window)) { | |
| 128 DLOG(INFO) << "Setting initial focus"; | |
| 129 tab->SetInitialFocus(win_util::IsShiftPressed()); | |
| 130 } | |
| 131 } | 126 } |
| 132 | |
| 133 return 0; | 127 return 0; |
| 134 } | 128 } |
| 135 | 129 |
| 136 LRESULT OnSize(UINT message, WPARAM wparam, LPARAM lparam, | 130 LRESULT OnSize(UINT message, WPARAM wparam, LPARAM lparam, |
| 137 BOOL& handled) { // NO_LINT | 131 BOOL& handled) { // NO_LINT |
| 138 handled = FALSE; | 132 handled = FALSE; |
| 139 // When we get resized, we need to resize the external tab window too. | 133 // When we get resized, we need to resize the external tab window too. |
| 140 if (automation_client_.get()) | 134 if (automation_client_.get()) |
| 141 automation_client_->Resize(LOWORD(lparam), HIWORD(lparam), | 135 automation_client_->Resize(LOWORD(lparam), HIWORD(lparam), |
| 142 SWP_NOACTIVATE | SWP_NOZORDER); | 136 SWP_NOACTIVATE | SWP_NOZORDER); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // passed to Chrome for execution. Override in most-derived class if needed. | 177 // passed to Chrome for execution. Override in most-derived class if needed. |
| 184 bool HandleContextMenuCommand(UINT cmd) { | 178 bool HandleContextMenuCommand(UINT cmd) { |
| 185 return false; | 179 return false; |
| 186 } | 180 } |
| 187 | 181 |
| 188 // Allow overriding the type of automation client used, for unit tests. | 182 // Allow overriding the type of automation client used, for unit tests. |
| 189 virtual ChromeFrameAutomationClient* CreateAutomationClient() { | 183 virtual ChromeFrameAutomationClient* CreateAutomationClient() { |
| 190 return new ChromeFrameAutomationClient; | 184 return new ChromeFrameAutomationClient; |
| 191 } | 185 } |
| 192 | 186 |
| 187 void GiveFocusToChrome() { |
| 188 TabProxy* tab = automation_client_->tab(); |
| 189 HWND chrome_window = automation_client_->tab_window(); |
| 190 if (tab && ::IsWindow(chrome_window)) { |
| 191 DLOG(INFO) << "Setting initial focus"; |
| 192 tab->SetInitialFocus(win_util::IsShiftPressed()); |
| 193 } |
| 194 } |
| 195 |
| 193 protected: | 196 protected: |
| 194 // Our gateway to chrome land | 197 // Our gateway to chrome land |
| 195 scoped_refptr<ChromeFrameAutomationClient> automation_client_; | 198 scoped_refptr<ChromeFrameAutomationClient> automation_client_; |
| 196 | 199 |
| 197 // Url of the containing document. | 200 // Url of the containing document. |
| 198 std::string document_url_; | 201 std::string document_url_; |
| 199 | 202 |
| 200 // We set this flag when we're taking the focus ourselves | 203 // We set this flag when we're taking the focus ourselves |
| 201 // and notifying the host browser that we're doing so. | 204 // and notifying the host browser that we're doing so. |
| 202 // When the flag is not set, we transfer the focus to chrome. | 205 // When the flag is not set, we transfer the focus to chrome. |
| 203 bool ignore_setfocus_; | 206 bool ignore_setfocus_; |
| 204 | 207 |
| 205 // The plugin is privileged if it is: | 208 // The plugin is privileged if it is: |
| 206 // * Invoked by a window running under the system principal in FireFox. | 209 // * Invoked by a window running under the system principal in FireFox. |
| 207 // * Being hosted by a custom host exposing the SID_ChromeFramePrivileged | 210 // * Being hosted by a custom host exposing the SID_ChromeFramePrivileged |
| 208 // service. | 211 // service. |
| 209 // | 212 // |
| 210 // When privileged, additional interfaces are made available to the user. | 213 // When privileged, additional interfaces are made available to the user. |
| 211 bool is_privileged_; | 214 bool is_privileged_; |
| 212 | 215 |
| 213 // List of functions to enable for automation, or a single entry "*" to | 216 // List of functions to enable for automation, or a single entry "*" to |
| 214 // enable all functions for automation. Ignored unless is_privileged_ is | 217 // enable all functions for automation. Ignored unless is_privileged_ is |
| 215 // true. Defaults to the empty list, meaning automation will not be | 218 // true. Defaults to the empty list, meaning automation will not be |
| 216 // turned on. | 219 // turned on. |
| 217 std::vector<std::string> functions_enabled_; | 220 std::vector<std::string> functions_enabled_; |
| 218 }; | 221 }; |
| 219 | 222 |
| 220 #endif // CHROME_FRAME_CHROME_FRAME_PLUGIN_H_ | 223 #endif // CHROME_FRAME_CHROME_FRAME_PLUGIN_H_ |
| 221 | 224 |
| OLD | NEW |