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