| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/ref_counted.h" | 11 #include "base/ref_counted.h" |
| 12 #include "base/win_util.h" | 12 #include "base/win_util.h" |
| 13 #include "chrome_frame/chrome_frame_automation.h" | 13 #include "chrome_frame/chrome_frame_automation.h" |
| 14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/common/chrome_paths_internal.h" | 15 #include "chrome/common/chrome_paths_internal.h" |
| 16 #include "chrome_frame/simple_resource_loader.h" | 16 #include "chrome_frame/simple_resource_loader.h" |
| 17 #include "chrome_frame/navigation_constraints.h" |
| 17 #include "chrome_frame/utils.h" | 18 #include "chrome_frame/utils.h" |
| 18 #include "grit/chromium_strings.h" | 19 #include "grit/chromium_strings.h" |
| 19 | 20 |
| 20 #define IDC_ABOUT_CHROME_FRAME 40018 | 21 #define IDC_ABOUT_CHROME_FRAME 40018 |
| 21 | 22 |
| 22 // A class to implement common functionality for all types of | 23 // A class to implement common functionality for all types of |
| 23 // plugins: NPAPI. ActiveX and ActiveDoc | 24 // plugins: NPAPI. ActiveX and ActiveDoc |
| 24 template <typename T> | 25 template <typename T> |
| 25 class ChromeFramePlugin : public ChromeFrameDelegateImpl { | 26 class ChromeFramePlugin |
| 27 : public ChromeFrameDelegateImpl, |
| 28 public NavigationConstraintsImpl { |
| 26 public: | 29 public: |
| 27 ChromeFramePlugin() | 30 ChromeFramePlugin() : ignore_setfocus_(false){ |
| 28 : ignore_setfocus_(false), | |
| 29 is_privileged_(false) { | |
| 30 } | 31 } |
| 31 ~ChromeFramePlugin() { | 32 ~ChromeFramePlugin() { |
| 32 Uninitialize(); | 33 Uninitialize(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 BEGIN_MSG_MAP(T) | 36 BEGIN_MSG_MAP(T) |
| 36 MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) | 37 MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) |
| 37 MESSAGE_HANDLER(WM_SIZE, OnSize) | 38 MESSAGE_HANDLER(WM_SIZE, OnSize) |
| 38 MESSAGE_HANDLER(WM_PARENTNOTIFY, OnParentNotify) | 39 MESSAGE_HANDLER(WM_PARENTNOTIFY, OnParentNotify) |
| 39 END_MSG_MAP() | 40 END_MSG_MAP() |
| (...skipping 20 matching lines...) Expand all Loading... |
| 60 | 61 |
| 61 bool InitializeAutomation(const std::wstring& profile_name, | 62 bool InitializeAutomation(const std::wstring& profile_name, |
| 62 const std::wstring& extra_chrome_arguments, | 63 const std::wstring& extra_chrome_arguments, |
| 63 bool incognito, bool is_widget_mode, | 64 bool incognito, bool is_widget_mode, |
| 64 const GURL& url, const GURL& referrer, | 65 const GURL& url, const GURL& referrer, |
| 65 bool route_all_top_level_navigations) { | 66 bool route_all_top_level_navigations) { |
| 66 DCHECK(IsValid()); | 67 DCHECK(IsValid()); |
| 67 DCHECK(launch_params_ == NULL); | 68 DCHECK(launch_params_ == NULL); |
| 68 // We don't want to do incognito when privileged, since we're | 69 // We don't want to do incognito when privileged, since we're |
| 69 // running in browser chrome or some other privileged context. | 70 // running in browser chrome or some other privileged context. |
| 70 bool incognito_mode = !is_privileged_ && incognito; | 71 bool incognito_mode = !is_privileged() && incognito; |
| 71 FilePath profile_path; | 72 FilePath profile_path; |
| 72 GetProfilePath(profile_name, &profile_path); | 73 GetProfilePath(profile_name, &profile_path); |
| 73 // The profile name could change based on the browser version. For e.g. for | 74 // The profile name could change based on the browser version. For e.g. for |
| 74 // IE6/7 the profile is created in a different folder whose last component | 75 // IE6/7 the profile is created in a different folder whose last component |
| 75 // is Google Chrome Frame. | 76 // is Google Chrome Frame. |
| 76 FilePath actual_profile_name = profile_path.BaseName(); | 77 FilePath actual_profile_name = profile_path.BaseName(); |
| 77 launch_params_ = new ChromeFrameLaunchParams(url, referrer, profile_path, | 78 launch_params_ = new ChromeFrameLaunchParams(url, referrer, profile_path, |
| 78 actual_profile_name.value(), SimpleResourceLoader::GetLanguage(), | 79 actual_profile_name.value(), SimpleResourceLoader::GetLanguage(), |
| 79 extra_chrome_arguments, incognito_mode, is_widget_mode, | 80 extra_chrome_arguments, incognito_mode, is_widget_mode, |
| 80 route_all_top_level_navigations); | 81 route_all_top_level_navigations); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 92 (static_cast<T*>(this))->GetClientRect(bounds); | 93 (static_cast<T*>(this))->GetClientRect(bounds); |
| 93 } | 94 } |
| 94 } | 95 } |
| 95 } | 96 } |
| 96 virtual std::string GetDocumentUrl() { | 97 virtual std::string GetDocumentUrl() { |
| 97 return document_url_; | 98 return document_url_; |
| 98 } | 99 } |
| 99 virtual void OnAutomationServerReady() { | 100 virtual void OnAutomationServerReady() { |
| 100 // Issue the extension automation request if we're privileged to | 101 // Issue the extension automation request if we're privileged to |
| 101 // allow this control to handle extension requests from Chrome. | 102 // allow this control to handle extension requests from Chrome. |
| 102 if (is_privileged_ && IsValid()) | 103 if (is_privileged() && IsValid()) |
| 103 automation_client_->SetEnableExtensionAutomation(functions_enabled_); | 104 automation_client_->SetEnableExtensionAutomation(functions_enabled_); |
| 104 } | 105 } |
| 105 | 106 |
| 106 virtual bool IsValid() const { | 107 virtual bool IsValid() const { |
| 107 return automation_client_.get() != NULL; | 108 return automation_client_.get() != NULL; |
| 108 } | 109 } |
| 109 | 110 |
| 110 virtual void OnHostMoved() { | 111 virtual void OnHostMoved() { |
| 111 if (IsValid()) | 112 if (IsValid()) |
| 112 automation_client_->OnChromeFrameHostMoved(); | 113 automation_client_->OnChromeFrameHostMoved(); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 scoped_refptr<ChromeFrameLaunchParams> launch_params_; | 255 scoped_refptr<ChromeFrameLaunchParams> launch_params_; |
| 255 | 256 |
| 256 // Url of the containing document. | 257 // Url of the containing document. |
| 257 std::string document_url_; | 258 std::string document_url_; |
| 258 | 259 |
| 259 // We set this flag when we're taking the focus ourselves | 260 // We set this flag when we're taking the focus ourselves |
| 260 // and notifying the host browser that we're doing so. | 261 // and notifying the host browser that we're doing so. |
| 261 // When the flag is not set, we transfer the focus to chrome. | 262 // When the flag is not set, we transfer the focus to chrome. |
| 262 bool ignore_setfocus_; | 263 bool ignore_setfocus_; |
| 263 | 264 |
| 264 // The plugin is privileged if it is: | |
| 265 // * Invoked by a window running under the system principal in FireFox. | |
| 266 // * Being hosted by a custom host exposing the SID_ChromeFramePrivileged | |
| 267 // service. | |
| 268 // | |
| 269 // When privileged, additional interfaces are made available to the user. | |
| 270 bool is_privileged_; | |
| 271 | |
| 272 // List of functions to enable for automation, or a single entry "*" to | 265 // List of functions to enable for automation, or a single entry "*" to |
| 273 // enable all functions for automation. Ignored unless is_privileged_ is | 266 // enable all functions for automation. Ignored unless is_privileged_ is |
| 274 // true. Defaults to the empty list, meaning automation will not be | 267 // true. Defaults to the empty list, meaning automation will not be |
| 275 // turned on. | 268 // turned on. |
| 276 std::vector<std::string> functions_enabled_; | 269 std::vector<std::string> functions_enabled_; |
| 277 }; | 270 }; |
| 278 | 271 |
| 279 #endif // CHROME_FRAME_CHROME_FRAME_PLUGIN_H_ | 272 #endif // CHROME_FRAME_CHROME_FRAME_PLUGIN_H_ |
| 280 | |
| OLD | NEW |