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

Side by Side Diff: chrome_frame/chrome_frame_plugin.h

Issue 385111: Merge 31792 - The ChromeFrameAutomationClient class needs to be refcounted as... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/245/src/
Patch Set: Created 11 years, 1 month 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
« no previous file with comments | « chrome_frame/chrome_frame_automation.cc ('k') | chrome_frame/find_dialog.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/win_util.h" 9 #include "base/win_util.h"
9 #include "chrome_frame/chrome_frame_automation.h" 10 #include "chrome_frame/chrome_frame_automation.h"
10 #include "chrome_frame/utils.h" 11 #include "chrome_frame/utils.h"
11 12
12 #define IDC_ABOUT_CHROME_FRAME 40018 13 #define IDC_ABOUT_CHROME_FRAME 40018
13 14
14 // A class to implement common functionality for all types of 15 // A class to implement common functionality for all types of
15 // plugins: NPAPI. ActiveX and ActiveDoc 16 // plugins: NPAPI. ActiveX and ActiveDoc
16 template <typename T> 17 template <typename T>
17 class ChromeFramePlugin : public ChromeFrameDelegateImpl { 18 class ChromeFramePlugin : public ChromeFrameDelegateImpl {
18 public: 19 public:
19 ChromeFramePlugin() 20 ChromeFramePlugin()
20 : ignore_setfocus_(false), 21 : ignore_setfocus_(false),
21 is_privileged_(false) { 22 is_privileged_(false) {
22 } 23 }
23 ~ChromeFramePlugin() { 24 ~ChromeFramePlugin() {
24 Uninitialize(); 25 Uninitialize();
25 } 26 }
26 27
27 BEGIN_MSG_MAP(ChromeFrameActivex) 28 BEGIN_MSG_MAP(ChromeFrameActivex)
28 MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus) 29 MESSAGE_HANDLER(WM_SETFOCUS, OnSetFocus)
29 MESSAGE_HANDLER(WM_SIZE, OnSize) 30 MESSAGE_HANDLER(WM_SIZE, OnSize)
30 MESSAGE_HANDLER(WM_PARENTNOTIFY, OnParentNotify) 31 MESSAGE_HANDLER(WM_PARENTNOTIFY, OnParentNotify)
31 END_MSG_MAP() 32 END_MSG_MAP()
32 33
33 bool Initialize() { 34 bool Initialize() {
34 DCHECK(!automation_client_.get()); 35 DCHECK(!automation_client_.get());
35 automation_client_.reset(CreateAutomationClient()); 36 automation_client_ = CreateAutomationClient();
36 if (!automation_client_.get()) { 37 if (!automation_client_.get()) {
37 NOTREACHED() << "new ChromeFrameAutomationClient"; 38 NOTREACHED() << "new ChromeFrameAutomationClient";
38 return false; 39 return false;
39 } 40 }
40 41
41 return true; 42 return true;
42 } 43 }
43 44
44 void Uninitialize() { 45 void Uninitialize() {
45 if (automation_client_.get()) { 46 if (automation_client_.get()) {
46 automation_client_->Uninitialize(); 47 automation_client_->Uninitialize();
47 automation_client_.reset(); 48 automation_client_ = NULL;
48 } 49 }
49 } 50 }
50 51
51 bool InitializeAutomation(const std::wstring& profile_name, 52 bool InitializeAutomation(const std::wstring& profile_name,
52 const std::wstring& extra_chrome_arguments, 53 const std::wstring& extra_chrome_arguments,
53 bool incognito) { 54 bool incognito) {
54 // We don't want to do incognito when privileged, since we're 55 // We don't want to do incognito when privileged, since we're
55 // running in browser chrome or some other privileged context. 56 // running in browser chrome or some other privileged context.
56 bool incognito_mode = !is_privileged_ && incognito; 57 bool incognito_mode = !is_privileged_ && incognito;
57 return automation_client_->Initialize(this, kCommandExecutionTimeout, true, 58 return automation_client_->Initialize(this, kCommandExecutionTimeout, true,
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 return false; 185 return false;
185 } 186 }
186 187
187 // Allow overriding the type of automation client used, for unit tests. 188 // Allow overriding the type of automation client used, for unit tests.
188 virtual ChromeFrameAutomationClient* CreateAutomationClient() { 189 virtual ChromeFrameAutomationClient* CreateAutomationClient() {
189 return new ChromeFrameAutomationClient; 190 return new ChromeFrameAutomationClient;
190 } 191 }
191 192
192 protected: 193 protected:
193 // Our gateway to chrome land 194 // Our gateway to chrome land
194 scoped_ptr<ChromeFrameAutomationClient> automation_client_; 195 scoped_refptr<ChromeFrameAutomationClient> automation_client_;
195 196
196 // Url of the containing document. 197 // Url of the containing document.
197 std::string document_url_; 198 std::string document_url_;
198 199
199 // We set this flag when we're taking the focus ourselves 200 // We set this flag when we're taking the focus ourselves
200 // and notifying the host browser that we're doing so. 201 // and notifying the host browser that we're doing so.
201 // When the flag is not set, we transfer the focus to chrome. 202 // When the flag is not set, we transfer the focus to chrome.
202 bool ignore_setfocus_; 203 bool ignore_setfocus_;
203 204
204 // The plugin is privileged if it is: 205 // The plugin is privileged if it is:
205 // * Invoked by a window running under the system principal in FireFox. 206 // * Invoked by a window running under the system principal in FireFox.
206 // * Being hosted by a custom host exposing the SID_ChromeFramePrivileged 207 // * Being hosted by a custom host exposing the SID_ChromeFramePrivileged
207 // service. 208 // service.
208 // 209 //
209 // When privileged, additional interfaces are made available to the user. 210 // When privileged, additional interfaces are made available to the user.
210 bool is_privileged_; 211 bool is_privileged_;
211 212
212 // List of functions to enable for automation, or a single entry "*" to 213 // List of functions to enable for automation, or a single entry "*" to
213 // enable all functions for automation. Ignored unless is_privileged_ is 214 // enable all functions for automation. Ignored unless is_privileged_ is
214 // true. Defaults to the empty list, meaning automation will not be 215 // true. Defaults to the empty list, meaning automation will not be
215 // turned on. 216 // turned on.
216 std::vector<std::string> functions_enabled_; 217 std::vector<std::string> functions_enabled_;
217 }; 218 };
218 219
219 #endif // CHROME_FRAME_CHROME_FRAME_PLUGIN_H_ 220 #endif // CHROME_FRAME_CHROME_FRAME_PLUGIN_H_
220 221
OLDNEW
« no previous file with comments | « chrome_frame/chrome_frame_automation.cc ('k') | chrome_frame/find_dialog.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698