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

Side by Side Diff: chrome/browser/extensions/extension_tab_helper.h

Issue 6794035: Move dispatching and sending of the last extension specific messages out of TabContents and Rende... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 months 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_BROWSER_EXTENSIONS_EXTENSOIN_TAB_HELPER_H_ 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSOIN_TAB_HELPER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "content/browser/tab_contents/tab_contents_observer.h" 9 #include "content/browser/tab_contents/tab_contents_observer.h"
10 #include "chrome/browser/extensions/image_loading_tracker.h" 10 #include "chrome/browser/extensions/image_loading_tracker.h"
11 #include "chrome/common/web_apps.h"
11 #include "third_party/skia/include/core/SkBitmap.h" 12 #include "third_party/skia/include/core/SkBitmap.h"
12 13
13 class Extension; 14 class Extension;
15 class TabContentsWrapper;
16 struct WebApplicationInfo;
14 17
15 // Per-tab extension helper. 18 // Per-tab extension helper.
16 class ExtensionTabHelper : public TabContentsObserver, 19 class ExtensionTabHelper : public TabContentsObserver,
17 public ImageLoadingTracker::Observer { 20 public ImageLoadingTracker::Observer {
18 public: 21 public:
19 explicit ExtensionTabHelper(TabContents* tab_contents); 22 explicit ExtensionTabHelper(TabContentsWrapper* wrapper);
20 virtual ~ExtensionTabHelper(); 23 virtual ~ExtensionTabHelper();
21 24
22 // Copies the internal state from another ExtensionTabHelper. 25 // Copies the internal state from another ExtensionTabHelper.
23 void CopyStateFrom(const ExtensionTabHelper& source); 26 void CopyStateFrom(const ExtensionTabHelper& source);
24 27
25 // Call this after updating a page action to notify clients about the changes. 28 // Call this after updating a page action to notify clients about the changes.
26 void PageActionStateChanged(); 29 void PageActionStateChanged();
27 30
31 // Requests application info for the specified page. This is an asynchronous
32 // request. The delegate is notified by way of OnDidGetApplicationInfo when
33 // the data is available.
34 void GetApplicationInfo(int32 page_id);
35
28 // App extensions ------------------------------------------------------------ 36 // App extensions ------------------------------------------------------------
29 37
30 // Sets the extension denoting this as an app. If |extension| is non-null this 38 // Sets the extension denoting this as an app. If |extension| is non-null this
31 // tab becomes an app-tab. TabContents does not listen for unload events for 39 // tab becomes an app-tab. TabContents does not listen for unload events for
32 // the extension. It's up to consumers of TabContents to do that. 40 // the extension. It's up to consumers of TabContents to do that.
33 // 41 //
34 // NOTE: this should only be manipulated before the tab is added to a browser. 42 // NOTE: this should only be manipulated before the tab is added to a browser.
35 // TODO(sky): resolve if this is the right way to identify an app tab. If it 43 // TODO(sky): resolve if this is the right way to identify an app tab. If it
36 // is, than this should be passed in the constructor. 44 // is, than this should be passed in the constructor.
37 void SetExtensionApp(const Extension* extension); 45 void SetExtensionApp(const Extension* extension);
38 46
39 // Convenience for setting the app extension by id. This does nothing if 47 // Convenience for setting the app extension by id. This does nothing if
40 // |extension_app_id| is empty, or an extension can't be found given the 48 // |extension_app_id| is empty, or an extension can't be found given the
41 // specified id. 49 // specified id.
42 void SetExtensionAppById(const std::string& extension_app_id); 50 void SetExtensionAppById(const std::string& extension_app_id);
43 51
44 const Extension* extension_app() const { return extension_app_; } 52 const Extension* extension_app() const { return extension_app_; }
45 bool is_app() const { return extension_app_ != NULL; } 53 bool is_app() const { return extension_app_ != NULL; }
54 const WebApplicationInfo& web_app_info() const {
55 return web_app_info_;
56 }
46 57
47 // If an app extension has been explicitly set for this TabContents its icon 58 // If an app extension has been explicitly set for this TabContents its icon
48 // is returned. 59 // is returned.
49 // 60 //
50 // NOTE: the returned icon is larger than 16x16 (its size is 61 // NOTE: the returned icon is larger than 16x16 (its size is
51 // Extension::EXTENSION_ICON_SMALLISH). 62 // Extension::EXTENSION_ICON_SMALLISH).
52 SkBitmap* GetExtensionAppIcon(); 63 SkBitmap* GetExtensionAppIcon();
53 64
54 TabContents* tab_contents() const { 65 TabContents* tab_contents() const {
55 return TabContentsObserver::tab_contents(); 66 return TabContentsObserver::tab_contents();
56 } 67 }
57 68
58 private: 69 private:
59 // TabContentsObserver overrides. 70 // TabContentsObserver overrides.
60 virtual void DidNavigateMainFramePostCommit( 71 virtual void DidNavigateMainFramePostCommit(
61 const NavigationController::LoadCommittedDetails& details, 72 const NavigationController::LoadCommittedDetails& details,
62 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; 73 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
63 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 74 virtual bool OnMessageReceived(const IPC::Message& message);
75
76 // Message handlers.
77 void OnDidGetApplicationInfo(int32 page_id, const WebApplicationInfo& info);
78 void OnInstallApplication(const WebApplicationInfo& info);
64 79
65 // App extensions related methods: 80 // App extensions related methods:
66 81
67 // Resets app_icon_ and if |extension| is non-null creates a new 82 // Resets app_icon_ and if |extension| is non-null creates a new
68 // ImageLoadingTracker to load the extension's image. 83 // ImageLoadingTracker to load the extension's image.
69 void UpdateExtensionAppIcon(const Extension* extension); 84 void UpdateExtensionAppIcon(const Extension* extension);
70 85
71 // ImageLoadingTracker::Observer. 86 // ImageLoadingTracker::Observer.
72 virtual void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource, 87 virtual void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource,
73 int index); 88 int index);
74 89
75 // Message handlers.
76 void OnPostMessage(int port_id, const std::string& message);
77
78 // Data for app extensions --------------------------------------------------- 90 // Data for app extensions ---------------------------------------------------
79 91
80 // If non-null this tab is an app tab and this is the extension the tab was 92 // If non-null this tab is an app tab and this is the extension the tab was
81 // created for. 93 // created for.
82 const Extension* extension_app_; 94 const Extension* extension_app_;
83 95
84 // Icon for extension_app_ (if non-null) or extension_for_current_page_. 96 // Icon for extension_app_ (if non-null) or extension_for_current_page_.
85 SkBitmap extension_app_icon_; 97 SkBitmap extension_app_icon_;
86 98
87 // Used for loading extension_app_icon_. 99 // Used for loading extension_app_icon_.
88 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_; 100 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_;
89 101
102 // Cached web app info data.
103 WebApplicationInfo web_app_info_;
104
105 TabContentsWrapper* wrapper_;
106
90 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper); 107 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper);
91 }; 108 };
92 109
93 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSOIN_TAB_HELPER_H_ 110 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698