| 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" |
| 11 #include "chrome/common/chrome_paths.h" |
| 12 #include "chrome/common/chrome_paths_internal.h" |
| 11 #include "chrome_frame/simple_resource_loader.h" | 13 #include "chrome_frame/simple_resource_loader.h" |
| 12 #include "chrome_frame/utils.h" | 14 #include "chrome_frame/utils.h" |
| 13 | 15 |
| 14 #include "grit/chromium_strings.h" | 16 #include "grit/chromium_strings.h" |
| 15 | 17 |
| 16 #define IDC_ABOUT_CHROME_FRAME 40018 | 18 #define IDC_ABOUT_CHROME_FRAME 40018 |
| 17 | 19 |
| 18 // A class to implement common functionality for all types of | 20 // A class to implement common functionality for all types of |
| 19 // plugins: NPAPI. ActiveX and ActiveDoc | 21 // plugins: NPAPI. ActiveX and ActiveDoc |
| 20 template <typename T> | 22 template <typename T> |
| 21 class ChromeFramePlugin : public ChromeFrameDelegateImpl { | 23 class ChromeFramePlugin : public ChromeFrameDelegateImpl { |
| 22 public: | 24 public: |
| 23 ChromeFramePlugin() | 25 ChromeFramePlugin() |
| 24 : ignore_setfocus_(false), | 26 : ignore_setfocus_(false), |
| 25 is_privileged_(false) { | 27 is_privileged_(false) { |
| 26 } | 28 } |
| 27 ~ChromeFramePlugin() { | 29 ~ChromeFramePlugin() { |
| 28 Uninitialize(); | 30 Uninitialize(); |
| 29 } | 31 } |
| 30 | 32 |
| 31 BEGIN_MSG_MAP(T) | 33 BEGIN_MSG_MAP(T) |
| 32 MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) | 34 MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) |
| 33 MESSAGE_HANDLER(WM_SIZE, OnSize) | 35 MESSAGE_HANDLER(WM_SIZE, OnSize) |
| 34 MESSAGE_HANDLER(WM_PARENTNOTIFY, OnParentNotify) | 36 MESSAGE_HANDLER(WM_PARENTNOTIFY, OnParentNotify) |
| 35 END_MSG_MAP() | 37 END_MSG_MAP() |
| 36 | 38 |
| 37 bool Initialize() { | 39 bool Initialize() { |
| 40 DLOG(INFO) << __FUNCTION__; |
| 38 DCHECK(!automation_client_.get()); | 41 DCHECK(!automation_client_.get()); |
| 39 automation_client_ = CreateAutomationClient(); | 42 automation_client_ = CreateAutomationClient(); |
| 40 if (!automation_client_.get()) { | 43 if (!automation_client_.get()) { |
| 41 NOTREACHED() << "new ChromeFrameAutomationClient"; | 44 NOTREACHED() << "new ChromeFrameAutomationClient"; |
| 42 return false; | 45 return false; |
| 43 } | 46 } |
| 44 | 47 |
| 45 return true; | 48 return true; |
| 46 } | 49 } |
| 47 | 50 |
| 48 void Uninitialize() { | 51 void Uninitialize() { |
| 52 DLOG(INFO) << __FUNCTION__; |
| 49 if (IsValid()) { | 53 if (IsValid()) { |
| 50 automation_client_->Uninitialize(); | 54 automation_client_->Uninitialize(); |
| 51 automation_client_ = NULL; | 55 automation_client_ = NULL; |
| 52 } | 56 } |
| 53 } | 57 } |
| 54 | 58 |
| 55 bool InitializeAutomation(const std::wstring& profile_name, | 59 bool InitializeAutomation(const std::wstring& profile_name, |
| 56 const std::wstring& extra_chrome_arguments, | 60 const std::wstring& extra_chrome_arguments, |
| 57 bool incognito) { | 61 bool incognito) { |
| 58 DCHECK(IsValid()); | 62 DCHECK(IsValid()); |
| 59 // We don't want to do incognito when privileged, since we're | 63 // We don't want to do incognito when privileged, since we're |
| 60 // running in browser chrome or some other privileged context. | 64 // running in browser chrome or some other privileged context. |
| 61 bool incognito_mode = !is_privileged_ && incognito; | 65 bool incognito_mode = !is_privileged_ && incognito; |
| 66 FilePath profile_path; |
| 67 GetProfilePath(profile_name, &profile_path); |
| 62 return automation_client_->Initialize(this, kCommandExecutionTimeout, true, | 68 return automation_client_->Initialize(this, kCommandExecutionTimeout, true, |
| 63 profile_name, extra_chrome_arguments, | 69 profile_path, extra_chrome_arguments, |
| 64 incognito_mode); | 70 incognito_mode); |
| 65 } | 71 } |
| 66 | 72 |
| 67 // ChromeFrameDelegate implementation | 73 // ChromeFrameDelegate implementation |
| 68 virtual WindowType GetWindow() const { | 74 virtual WindowType GetWindow() const { |
| 69 return (static_cast<const T*>(this))->m_hWnd; | 75 return (static_cast<const T*>(this))->m_hWnd; |
| 70 } | 76 } |
| 71 | 77 |
| 72 virtual void GetBounds(RECT* bounds) { | 78 virtual void GetBounds(RECT* bounds) { |
| 73 if (bounds) { | 79 if (bounds) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 204 if (IsValid()) { | 210 if (IsValid()) { |
| 205 TabProxy* tab = automation_client_->tab(); | 211 TabProxy* tab = automation_client_->tab(); |
| 206 HWND chrome_window = automation_client_->tab_window(); | 212 HWND chrome_window = automation_client_->tab_window(); |
| 207 if (tab && ::IsWindow(chrome_window)) { | 213 if (tab && ::IsWindow(chrome_window)) { |
| 208 DLOG(INFO) << "Setting initial focus"; | 214 DLOG(INFO) << "Setting initial focus"; |
| 209 tab->SetInitialFocus(win_util::IsShiftPressed()); | 215 tab->SetInitialFocus(win_util::IsShiftPressed()); |
| 210 } | 216 } |
| 211 } | 217 } |
| 212 } | 218 } |
| 213 | 219 |
| 220 virtual void GetProfilePath(const std::wstring& profile_name, |
| 221 FilePath* profile_path) { |
| 222 chrome::GetChromeFrameUserDataDirectory(profile_path); |
| 223 *profile_path = profile_path->Append(profile_name); |
| 224 DLOG(INFO) << __FUNCTION__ << ": " << profile_path->value(); |
| 225 } |
| 226 |
| 214 protected: | 227 protected: |
| 215 // Our gateway to chrome land | 228 // Our gateway to chrome land |
| 216 scoped_refptr<ChromeFrameAutomationClient> automation_client_; | 229 scoped_refptr<ChromeFrameAutomationClient> automation_client_; |
| 217 | 230 |
| 218 // Url of the containing document. | 231 // Url of the containing document. |
| 219 std::string document_url_; | 232 std::string document_url_; |
| 220 | 233 |
| 221 // We set this flag when we're taking the focus ourselves | 234 // We set this flag when we're taking the focus ourselves |
| 222 // and notifying the host browser that we're doing so. | 235 // and notifying the host browser that we're doing so. |
| 223 // When the flag is not set, we transfer the focus to chrome. | 236 // When the flag is not set, we transfer the focus to chrome. |
| 224 bool ignore_setfocus_; | 237 bool ignore_setfocus_; |
| 225 | 238 |
| 226 // The plugin is privileged if it is: | 239 // The plugin is privileged if it is: |
| 227 // * Invoked by a window running under the system principal in FireFox. | 240 // * Invoked by a window running under the system principal in FireFox. |
| 228 // * Being hosted by a custom host exposing the SID_ChromeFramePrivileged | 241 // * Being hosted by a custom host exposing the SID_ChromeFramePrivileged |
| 229 // service. | 242 // service. |
| 230 // | 243 // |
| 231 // When privileged, additional interfaces are made available to the user. | 244 // When privileged, additional interfaces are made available to the user. |
| 232 bool is_privileged_; | 245 bool is_privileged_; |
| 233 | 246 |
| 234 // List of functions to enable for automation, or a single entry "*" to | 247 // List of functions to enable for automation, or a single entry "*" to |
| 235 // enable all functions for automation. Ignored unless is_privileged_ is | 248 // enable all functions for automation. Ignored unless is_privileged_ is |
| 236 // true. Defaults to the empty list, meaning automation will not be | 249 // true. Defaults to the empty list, meaning automation will not be |
| 237 // turned on. | 250 // turned on. |
| 238 std::vector<std::string> functions_enabled_; | 251 std::vector<std::string> functions_enabled_; |
| 239 }; | 252 }; |
| 240 | 253 |
| 241 #endif // CHROME_FRAME_CHROME_FRAME_PLUGIN_H_ | 254 #endif // CHROME_FRAME_CHROME_FRAME_PLUGIN_H_ |
| 242 | 255 |
| OLD | NEW |