Chromium Code Reviews| 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 // IE toolband implementation. | 5 // IE toolband implementation. |
| 6 #ifndef CEEE_IE_PLUGIN_TOOLBAND_TOOL_BAND_H_ | 6 #ifndef CEEE_IE_PLUGIN_TOOLBAND_TOOL_BAND_H_ |
| 7 #define CEEE_IE_PLUGIN_TOOLBAND_TOOL_BAND_H_ | 7 #define CEEE_IE_PLUGIN_TOOLBAND_TOOL_BAND_H_ |
| 8 | 8 |
| 9 #include <atlbase.h> | 9 #include <atlbase.h> |
| 10 #include <atlapp.h> // Must be included AFTER base. | 10 #include <atlapp.h> // Must be included AFTER base. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 // and renders by hosting chrome frame as an ActiveX control. | 43 // and renders by hosting chrome frame as an ActiveX control. |
| 44 class ATL_NO_VTABLE ToolBand : public CComObjectRootEx<CComSingleThreadModel>, | 44 class ATL_NO_VTABLE ToolBand : public CComObjectRootEx<CComSingleThreadModel>, |
| 45 public CComCoClass<ToolBand, &CLSID_ToolBand>, | 45 public CComCoClass<ToolBand, &CLSID_ToolBand>, |
| 46 public IObjectWithSiteImpl<ToolBand>, | 46 public IObjectWithSiteImpl<ToolBand>, |
| 47 public IServiceProviderImpl<ToolBand>, | 47 public IServiceProviderImpl<ToolBand>, |
| 48 public IChromeFramePrivileged, | 48 public IChromeFramePrivileged, |
| 49 public IDeskBand, | 49 public IDeskBand, |
| 50 public IPersistStream, | 50 public IPersistStream, |
| 51 public ChromeFrameEvents, | 51 public ChromeFrameEvents, |
| 52 public HostingBrowserEvents, | 52 public HostingBrowserEvents, |
| 53 public CWindowImpl<ToolBand> { | 53 // WS_CHILD | WS_VISIBLE | TBSTYLE_TRANSPARENT | CCS_NODIVIDER are critical |
|
Sigurður Ásgeirsson
2011/01/14 14:00:43
one last nit: can I ask you to move this to a type
| |
| 54 // for painting toolband background while chrome frame is hidden. | |
| 55 // TBSTYLE_TRANSPARENT makes toolbar same color as rest of IE controls. | |
| 56 // CCS_NODIVIDER removes line above toolbar. | |
| 57 // Rest was copied from IE favorite bar. | |
| 58 public CWindowImpl<ToolBand, CWindow, CWinTraits< | |
| 59 WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | | |
| 60 TBSTYLE_TOOLTIPS | TBSTYLE_TRANSPARENT | TBSTYLE_LIST | TBSTYLE_FLAT | | |
| 61 CCS_NODIVIDER | CCS_NOPARENTALIGN | CCS_NORESIZE | CCS_TOP, 0>> { | |
| 54 public: | 62 public: |
| 55 ToolBand(); | 63 ToolBand(); |
| 56 ~ToolBand(); | 64 ~ToolBand(); |
| 57 | 65 |
| 66 // Subclass TOOLBARCLASSNAME to use TBSTYLE_TRANSPARENT. | |
| 67 DECLARE_WND_SUPERCLASS(NULL, TOOLBARCLASSNAME) | |
| 68 | |
| 58 DECLARE_REGISTRY_RESOURCEID_EX(IDR_TOOL_BAND) | 69 DECLARE_REGISTRY_RESOURCEID_EX(IDR_TOOL_BAND) |
| 59 BEGIN_REGISTRY_MAP(ToolBand) | 70 BEGIN_REGISTRY_MAP(ToolBand) |
| 60 REGMAP_UUID("CLSID", CLSID_ToolBand) | 71 REGMAP_UUID("CLSID", CLSID_ToolBand) |
| 61 REGMAP_RESOURCE("NAME", IDS_CEEE_NAME) | 72 REGMAP_RESOURCE("NAME", IDS_CEEE_NAME) |
| 62 END_REGISTRY_MAP() | 73 END_REGISTRY_MAP() |
| 63 | 74 |
| 64 BEGIN_COM_MAP(ToolBand) | 75 BEGIN_COM_MAP(ToolBand) |
| 65 COM_INTERFACE_ENTRY(IDeskBand) | 76 COM_INTERFACE_ENTRY(IDeskBand) |
| 66 COM_INTERFACE_ENTRY(IDockingWindow) | 77 COM_INTERFACE_ENTRY(IDockingWindow) |
| 67 COM_INTERFACE_ENTRY(IOleWindow) | 78 COM_INTERFACE_ENTRY(IOleWindow) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 virtual void OnFinalMessage(HWND window); | 183 virtual void OnFinalMessage(HWND window); |
| 173 LRESULT OnCreate(LPCREATESTRUCT lpCreateStruct); | 184 LRESULT OnCreate(LPCREATESTRUCT lpCreateStruct); |
| 174 | 185 |
| 175 // Loads the manifest from file and retrieves the URL to the extension. | 186 // Loads the manifest from file and retrieves the URL to the extension. |
| 176 // @returns true on success, false on failure to read the manifest or URL. | 187 // @returns true on success, false on failure to read the manifest or URL. |
| 177 bool LoadManifestFile(const std::wstring& base_dir, | 188 bool LoadManifestFile(const std::wstring& base_dir, |
| 178 std::string* toolband_url); | 189 std::string* toolband_url); |
| 179 | 190 |
| 180 // @name Message handlers. | 191 // @name Message handlers. |
| 181 // @{ | 192 // @{ |
| 182 void OnPaint(CDCHandle dc); | |
| 183 void OnSize(UINT type, CSize size); | 193 void OnSize(UINT type, CSize size); |
| 184 // @} | 194 // @} |
| 185 | 195 |
| 186 // Toolband requires a specific BHO to work. Normally, IE will create BHO | 196 // Toolband requires a specific BHO to work. Normally, IE will create BHO |
| 187 // about the same time as the toolband. However, in some scenarios | 197 // about the same time as the toolband. However, in some scenarios |
| 188 // (re-enabling the gadget) BHOs for the current pages won't be created, | 198 // (re-enabling the gadget) BHOs for the current pages won't be created, |
| 189 // even though the bar will. | 199 // even though the bar will. |
| 190 HRESULT EnsureBhoIsAvailable(); | 200 HRESULT EnsureBhoIsAvailable(); |
| 191 | 201 |
| 192 // Gets the session ID of the Chrome Frame instance associated with the tool | 202 // Gets the session ID of the Chrome Frame instance associated with the tool |
| 193 // band. | 203 // band. |
| 194 virtual HRESULT GetSessionId(int* session_id); | 204 virtual HRESULT GetSessionId(int* session_id); |
| 195 | 205 |
| 196 // Sends the tool band's Chrome Frame session ID to the BHO, given the BHO as | 206 // Sends the tool band's Chrome Frame session ID to the BHO, given the BHO as |
| 197 // an IUnknown. | 207 // an IUnknown. |
| 198 virtual HRESULT SendSessionIdToBho(IUnknown* bho); | 208 virtual HRESULT SendSessionIdToBho(IUnknown* bho); |
| 199 | 209 |
| 200 private: | 210 private: |
| 211 class EmptyWindow : | |
| 212 public CWindowImpl<EmptyWindow, CWindow, CWinTraits<WS_CHILD, 0>> { | |
| 213 public: | |
| 214 BEGIN_MSG_MAP(EmptyWindow) | |
| 215 END_MSG_MAP() | |
| 216 }; | |
| 217 | |
| 201 // Initializes the toolband to the given site. | 218 // Initializes the toolband to the given site. |
| 202 // Called from SetSite. | 219 // Called from SetSite. |
| 203 HRESULT Initialize(IUnknown *site); | 220 HRESULT Initialize(IUnknown *site); |
| 204 // Tears down an initialized toolband. | 221 // Tears down an initialized toolband. |
| 205 // Called from SetSite. | 222 // Called from SetSite. |
| 206 HRESULT Teardown(); | 223 HRESULT Teardown(); |
| 207 | 224 |
| 208 // Handles the dispatching of command received from the User/UI context. | 225 // Handles the dispatching of command received from the User/UI context. |
| 209 HRESULT DispatchUserCommand(const DictionaryValue& dict, | 226 HRESULT DispatchUserCommand(const DictionaryValue& dict, |
| 210 scoped_ptr<Value>* return_value); | 227 scoped_ptr<Value>* return_value); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 233 | 250 |
| 234 // The minimum size the toolband should take. | 251 // The minimum size the toolband should take. |
| 235 LONG current_width_; | 252 LONG current_width_; |
| 236 LONG current_height_; | 253 LONG current_height_; |
| 237 | 254 |
| 238 // The URL to our extension. | 255 // The URL to our extension. |
| 239 std::string extension_url_; | 256 std::string extension_url_; |
| 240 | 257 |
| 241 // Our Chrome frame instance and its window. | 258 // Our Chrome frame instance and its window. |
| 242 CComPtr<IChromeFrame> chrome_frame_; | 259 CComPtr<IChromeFrame> chrome_frame_; |
| 243 CWindow chrome_frame_window_; | 260 |
| 261 // Hides chrome frame during initialization. | |
| 262 EmptyWindow chrome_frame_container_window_; | |
| 244 | 263 |
| 245 // Indicates whether CloseDW() is being called on this tool band. | 264 // Indicates whether CloseDW() is being called on this tool band. |
| 246 bool is_quitting_; | 265 bool is_quitting_; |
| 247 | 266 |
| 248 // True if we noticed that no extensions are enabled and requested | 267 // True if we noticed that no extensions are enabled and requested |
| 249 // to install one. | 268 // to install one. |
| 250 bool already_tried_installing_; | 269 bool already_tried_installing_; |
| 251 | 270 |
| 252 // Flag purpose: see comments to ShouldForceOwnLine | 271 // Flag purpose: see comments to ShouldForceOwnLine |
| 253 // for efficiency we read only once (thus the second flag). | 272 // for efficiency we read only once (thus the second flag). |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 272 static _ATL_FUNC_INFO handler_type_long_; | 291 static _ATL_FUNC_INFO handler_type_long_; |
| 273 static _ATL_FUNC_INFO handler_type_idispatch_bstr_; | 292 static _ATL_FUNC_INFO handler_type_idispatch_bstr_; |
| 274 static _ATL_FUNC_INFO handler_type_bstr_i4_; | 293 static _ATL_FUNC_INFO handler_type_bstr_i4_; |
| 275 static _ATL_FUNC_INFO handler_type_bstrarray_; | 294 static _ATL_FUNC_INFO handler_type_bstrarray_; |
| 276 static _ATL_FUNC_INFO handler_type_idispatch_variantref_; | 295 static _ATL_FUNC_INFO handler_type_idispatch_variantref_; |
| 277 | 296 |
| 278 DISALLOW_COPY_AND_ASSIGN(ToolBand); | 297 DISALLOW_COPY_AND_ASSIGN(ToolBand); |
| 279 }; | 298 }; |
| 280 | 299 |
| 281 #endif // CEEE_IE_PLUGIN_TOOLBAND_TOOL_BAND_H_ | 300 #endif // CEEE_IE_PLUGIN_TOOLBAND_TOOL_BAND_H_ |
| OLD | NEW |