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

Side by Side Diff: chrome/browser/ui/views/location_bar/page_action_image_view.h

Issue 8333021: Fix a crash in PageActionImageView when extensions are reloaded due to incognito settings changing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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
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_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "chrome/browser/extensions/image_loading_tracker.h" 13 #include "chrome/browser/extensions/image_loading_tracker.h"
14 #include "chrome/browser/extensions/extension_context_menu_model.h" 14 #include "chrome/browser/extensions/extension_context_menu_model.h"
15 #include "chrome/browser/ui/views/extensions/extension_popup.h" 15 #include "chrome/browser/ui/views/extensions/extension_popup.h"
16 #include "views/controls/image_view.h" 16 #include "views/controls/image_view.h"
17 17
18 class LocationBarView; 18 class LocationBarView;
19 namespace views { 19 namespace views {
20 class MenuRunner; 20 class MenuRunner;
21 } 21 }
22 22
23 // PageActionImageView is used by the LocationBarView to display the icon for a 23 // PageActionImageView is used by the LocationBarView to display the icon for a
24 // given PageAction and notify the extension when the icon is clicked. 24 // given PageAction and notify the extension when the icon is clicked.
25 class PageActionImageView : public views::ImageView, 25 class PageActionImageView : public views::ImageView,
26 public ImageLoadingTracker::Observer, 26 public ImageLoadingTracker::Observer,
27 public ExtensionContextMenuModel::PopupDelegate, 27 public ExtensionContextMenuModel::PopupDelegate,
28 public ExtensionPopup::Observer { 28 public ExtensionPopup::Observer,
29 public content::NotificationObserver {
29 public: 30 public:
30 PageActionImageView(LocationBarView* owner, 31 PageActionImageView(LocationBarView* owner,
31 ExtensionAction* page_action); 32 ExtensionAction* page_action);
32 virtual ~PageActionImageView(); 33 virtual ~PageActionImageView();
33 34
34 ExtensionAction* page_action() { return page_action_; } 35 ExtensionAction* page_action() { return page_action_; }
35 36
36 int current_tab_id() { return current_tab_id_; } 37 int current_tab_id() { return current_tab_id_; }
37 38
38 void set_preview_enabled(bool preview_enabled) { 39 void set_preview_enabled(bool preview_enabled) {
(...skipping 12 matching lines...) Expand all
51 virtual void OnImageLoaded(SkBitmap* image, 52 virtual void OnImageLoaded(SkBitmap* image,
52 const ExtensionResource& resource, 53 const ExtensionResource& resource,
53 int index) OVERRIDE; 54 int index) OVERRIDE;
54 55
55 // Overridden from ExtensionContextMenuModelModel::Delegate 56 // Overridden from ExtensionContextMenuModelModel::Delegate
56 virtual void InspectPopup(ExtensionAction* action) OVERRIDE; 57 virtual void InspectPopup(ExtensionAction* action) OVERRIDE;
57 58
58 // Overridden from ExtensionPopup::Observer 59 // Overridden from ExtensionPopup::Observer
59 virtual void ExtensionPopupIsClosing(ExtensionPopup* popup) OVERRIDE; 60 virtual void ExtensionPopupIsClosing(ExtensionPopup* popup) OVERRIDE;
60 61
62 // content::NotificationObserver implementation.
63 virtual void Observe(int type,
64 const content::NotificationSource& source,
65 const content::NotificationDetails& details) OVERRIDE;
66
61 // Called to notify the PageAction that it should determine whether to be 67 // Called to notify the PageAction that it should determine whether to be
62 // visible or hidden. |contents| is the TabContents that is active, |url| is 68 // visible or hidden. |contents| is the TabContents that is active, |url| is
63 // the current page URL. 69 // the current page URL.
64 void UpdateVisibility(TabContents* contents, const GURL& url); 70 void UpdateVisibility(TabContents* contents, const GURL& url);
65 71
66 // Either notify listeners or show a popup depending on the page action. 72 // Either notify listeners or show a popup depending on the page action.
67 void ExecuteAction(int button, bool inspect_with_devtools); 73 void ExecuteAction(int button, bool inspect_with_devtools);
68 74
69 private: 75 private:
70 // Hides the active popup, if there is one. 76 // Hides the active popup, if there is one.
(...skipping 23 matching lines...) Expand all
94 // The string to show for a tooltip; 100 // The string to show for a tooltip;
95 std::string tooltip_; 101 std::string tooltip_;
96 102
97 // This is used for post-install visual feedback. The page_action icon is 103 // This is used for post-install visual feedback. The page_action icon is
98 // briefly shown even if it hasn't been enabled by its extension. 104 // briefly shown even if it hasn't been enabled by its extension.
99 bool preview_enabled_; 105 bool preview_enabled_;
100 106
101 // The current popup and the button it came from. NULL if no popup. 107 // The current popup and the button it came from. NULL if no popup.
102 ExtensionPopup* popup_; 108 ExtensionPopup* popup_;
103 109
110 content::NotificationRegistrar registrar_;
111
104 scoped_ptr<views::MenuRunner> menu_runner_; 112 scoped_ptr<views::MenuRunner> menu_runner_;
105 113
106 DISALLOW_IMPLICIT_CONSTRUCTORS(PageActionImageView); 114 DISALLOW_IMPLICIT_CONSTRUCTORS(PageActionImageView);
107 }; 115 };
108 116
109 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_ 117 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_PAGE_ACTION_IMAGE_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698