| OLD | NEW |
| 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_SIDEBAR_SIDEBAR_CONTAINER_H_ | 5 #ifndef CHROME_BROWSER_SIDEBAR_SIDEBAR_CONTAINER_H_ |
| 6 #define CHROME_BROWSER_SIDEBAR_SIDEBAR_CONTAINER_H_ | 6 #define CHROME_BROWSER_SIDEBAR_SIDEBAR_CONTAINER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" |
| 11 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/string16.h" | 13 #include "base/string16.h" |
| 13 #include "chrome/browser/extensions/image_loading_tracker.h" | 14 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 14 #include "content/browser/tab_contents/tab_contents_delegate.h" | 15 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 15 | 16 |
| 16 class BrowserWindow; | 17 class BrowserWindow; |
| 17 class Profile; | 18 class Profile; |
| 18 class RenderViewHost; | 19 class RenderViewHost; |
| 19 class SkBitmap; | 20 class SkBitmap; |
| 20 class TabContents; | 21 class TabContents; |
| 21 | 22 |
| 22 /////////////////////////////////////////////////////////////////////////////// | 23 /////////////////////////////////////////////////////////////////////////////// |
| 23 // SidebarContainer | 24 // SidebarContainer |
| 24 // | 25 // |
| 25 // Stores one particular sidebar state: sidebar's content, its content id, | 26 // Stores one particular sidebar state: sidebar's content, its content id, |
| 26 // tab it is linked to, mini tab icon, title etc. | 27 // tab it is linked to, mini tab icon, title etc. |
| 27 // | 28 // |
| 28 class SidebarContainer | 29 class SidebarContainer : public TabContentsDelegate, |
| 29 : public TabContentsDelegate, | 30 private ImageLoadingTracker::Observer { |
| 30 private ImageLoadingTracker::Observer { | |
| 31 public: | 31 public: |
| 32 // Interface to implement to listen for sidebar update notification. | 32 // Interface to implement to listen for sidebar update notification. |
| 33 class Delegate { | 33 class Delegate { |
| 34 public: | 34 public: |
| 35 Delegate() {} | 35 Delegate() {} |
| 36 virtual ~Delegate() {} | 36 virtual ~Delegate() {} |
| 37 virtual void UpdateSidebar(SidebarContainer* host) = 0; | 37 virtual void UpdateSidebar(SidebarContainer* host) = 0; |
| 38 private: | 38 private: |
| 39 DISALLOW_COPY_AND_ASSIGN(Delegate); | 39 DISALLOW_COPY_AND_ASSIGN(Delegate); |
| 40 }; | 40 }; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // Changes sidebar's badge text. | 86 // Changes sidebar's badge text. |
| 87 void SetBadgeText(const string16& badge_text); | 87 void SetBadgeText(const string16& badge_text); |
| 88 | 88 |
| 89 // Changes sidebar's icon. | 89 // Changes sidebar's icon. |
| 90 void SetIcon(const SkBitmap& bitmap); | 90 void SetIcon(const SkBitmap& bitmap); |
| 91 | 91 |
| 92 // Changes sidebar's title. | 92 // Changes sidebar's title. |
| 93 void SetTitle(const string16& title); | 93 void SetTitle(const string16& title); |
| 94 | 94 |
| 95 private: | 95 private: |
| 96 // Overridden from TabContentsDelegate. | 96 // Overridden from TabContentsDelegate: |
| 97 virtual bool IsPopup(const TabContents* source) const; | |
| 98 virtual content::JavaScriptDialogCreator* | 97 virtual content::JavaScriptDialogCreator* |
| 99 GetJavaScriptDialogCreator() OVERRIDE; | 98 GetJavaScriptDialogCreator() OVERRIDE; |
| 100 | 99 |
| 101 // Overridden from ImageLoadingTracker::Observer. | 100 // Overridden from ImageLoadingTracker::Observer: |
| 102 virtual void OnImageLoaded(SkBitmap* image, | 101 virtual void OnImageLoaded(SkBitmap* image, |
| 103 const ExtensionResource& resource, | 102 const ExtensionResource& resource, |
| 104 int index); | 103 int index) OVERRIDE; |
| 105 | 104 |
| 106 // Returns an extension this sidebar belongs to. | 105 // Returns an extension this sidebar belongs to. |
| 107 const Extension* GetExtension() const; | 106 const Extension* GetExtension() const; |
| 108 | 107 |
| 109 // Contents of the tab this sidebar is linked to. | 108 // Contents of the tab this sidebar is linked to. |
| 110 TabContents* tab_; | 109 TabContents* tab_; |
| 111 | 110 |
| 112 // Sidebar's content id. There might be more than one sidebar liked to each | 111 // Sidebar's content id. There might be more than one sidebar liked to each |
| 113 // particular tab and they are identified by their unique content id. | 112 // particular tab and they are identified by their unique content id. |
| 114 const std::string content_id_; | 113 const std::string content_id_; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 139 // icon should be used or discarded. | 138 // icon should be used or discarded. |
| 140 bool use_default_icon_; | 139 bool use_default_icon_; |
| 141 | 140 |
| 142 // Helper to load icons from extension asynchronously. | 141 // Helper to load icons from extension asynchronously. |
| 143 scoped_ptr<ImageLoadingTracker> image_loading_tracker_; | 142 scoped_ptr<ImageLoadingTracker> image_loading_tracker_; |
| 144 | 143 |
| 145 DISALLOW_COPY_AND_ASSIGN(SidebarContainer); | 144 DISALLOW_COPY_AND_ASSIGN(SidebarContainer); |
| 146 }; | 145 }; |
| 147 | 146 |
| 148 #endif // CHROME_BROWSER_SIDEBAR_SIDEBAR_CONTAINER_H_ | 147 #endif // CHROME_BROWSER_SIDEBAR_SIDEBAR_CONTAINER_H_ |
| OLD | NEW |