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

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

Issue 6693054: Get rid of extensions dependency from content\browser. (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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSOIN_TAB_HELPER_H_
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSOIN_TAB_HELPER_H_
7 #pragma once
8
9 #include "content/browser/tab_contents/tab_contents_observer.h"
10 #include "chrome/browser/extensions/image_loading_tracker.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12
13 class Extension;
14
15 // Per-tab extension helper.
16 class ExtensionTabHelper : public TabContentsObserver,
17 public ImageLoadingTracker::Observer {
18 public:
19 explicit ExtensionTabHelper(TabContents* tab_contents);
20 virtual ~ExtensionTabHelper();
21
22 // Call this after updating a page action to notify clients about the changes.
23 void PageActionStateChanged();
24
25 // App extensions ------------------------------------------------------------
26
27 // Sets the extension denoting this as an app. If |extension| is non-null this
28 // tab becomes an app-tab. TabContents does not listen for unload events for
29 // the extension. It's up to consumers of TabContents to do that.
30 //
31 // NOTE: this should only be manipulated before the tab is added to a browser.
32 // TODO(sky): resolve if this is the right way to identify an app tab. If it
33 // is, than this should be passed in the constructor.
34 void SetExtensionApp(const Extension* extension);
35
36 // Sets the extension app icon.
37 void SetExtensionAppIcon(const SkBitmap* extension_app_icon);
38
39 // 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
41 // specified id.
42 void SetExtensionAppById(const std::string& extension_app_id);
43
44 const Extension* extension_app() const { return extension_app_; }
45 const SkBitmap* extension_app_icon() { return &extension_app_icon_; }
46 bool is_app() const { return extension_app_ != NULL; }
47
48 // If an app extension has been explicitly set for this TabContents its icon
49 // is returned.
50 //
51 // NOTE: the returned icon is larger than 16x16 (its size is
52 // Extension::EXTENSION_ICON_SMALLISH).
53 SkBitmap* GetExtensionAppIcon();
54
55 TabContents* tab_contents() const {
56 return TabContentsObserver::tab_contents();
57 }
58
59 private:
60 // TabContentsObserver overrides.
61 virtual void DidNavigateMainFramePostCommit(
62 const NavigationController::LoadCommittedDetails& details,
63 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
64 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
65
66 // App extensions related methods:
67
68 // Resets app_icon_ and if |extension| is non-null creates a new
69 // ImageLoadingTracker to load the extension's image.
70 void UpdateExtensionAppIcon(const Extension* extension);
71
72 // ImageLoadingTracker::Observer.
73 virtual void OnImageLoaded(SkBitmap* image, const ExtensionResource& resource,
74 int index);
75
76 // Message handlers.
77 void OnPostMessage(int port_id, const std::string& message);
78
79 // Data for app extensions ---------------------------------------------------
80
81 // If non-null this tab is an app tab and this is the extension the tab was
82 // created for.
83 const Extension* extension_app_;
84
85 // Icon for extension_app_ (if non-null) or extension_for_current_page_.
86 SkBitmap extension_app_icon_;
87
88 // Used for loading extension_app_icon_.
89 scoped_ptr<ImageLoadingTracker> extension_app_image_loader_;
90
91 DISALLOW_COPY_AND_ASSIGN(ExtensionTabHelper);
92 };
93
94 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSOIN_TAB_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698