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

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

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 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h" 5 #include "chrome/browser/ui/views/location_bar/page_action_image_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/extensions/extension_browser_event_router.h" 8 #include "chrome/browser/extensions/extension_browser_event_router.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_tab_util.h" 10 #include "chrome/browser/extensions/extension_tab_util.h"
11 #include "chrome/browser/platform_util.h" 11 #include "chrome/browser/platform_util.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser_list.h" 13 #include "chrome/browser/ui/browser_list.h"
14 #include "chrome/browser/ui/views/frame/browser_view.h" 14 #include "chrome/browser/ui/views/frame/browser_view.h"
15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" 15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h"
16 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/extensions/extension.h"
16 #include "chrome/common/extensions/extension_action.h" 18 #include "chrome/common/extensions/extension_action.h"
17 #include "chrome/common/extensions/extension_resource.h" 19 #include "chrome/common/extensions/extension_resource.h"
20 #include "content/browser/notification_service_impl.h"
21 #include "content/public/browser/notification_details.h"
22 #include "content/public/browser/notification_source.h"
18 #include "ui/base/accessibility/accessible_view_state.h" 23 #include "ui/base/accessibility/accessible_view_state.h"
19 #include "views/controls/menu/menu_item_view.h" 24 #include "views/controls/menu/menu_item_view.h"
20 #include "views/controls/menu/menu_model_adapter.h" 25 #include "views/controls/menu/menu_model_adapter.h"
21 #include "views/controls/menu/menu_runner.h" 26 #include "views/controls/menu/menu_runner.h"
22 27
23 PageActionImageView::PageActionImageView(LocationBarView* owner, 28 PageActionImageView::PageActionImageView(LocationBarView* owner,
24 ExtensionAction* page_action) 29 ExtensionAction* page_action)
25 : owner_(owner), 30 : owner_(owner),
26 page_action_(page_action), 31 page_action_(page_action),
27 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)), 32 ALLOW_THIS_IN_INITIALIZER_LIST(tracker_(this)),
(...skipping 12 matching lines...) Expand all
40 icon_paths.push_back(page_action_->default_icon_path()); 45 icon_paths.push_back(page_action_->default_icon_path());
41 46
42 for (std::vector<std::string>::iterator iter = icon_paths.begin(); 47 for (std::vector<std::string>::iterator iter = icon_paths.begin();
43 iter != icon_paths.end(); ++iter) { 48 iter != icon_paths.end(); ++iter) {
44 tracker_.LoadImage(extension, extension->GetResource(*iter), 49 tracker_.LoadImage(extension, extension->GetResource(*iter),
45 gfx::Size(Extension::kPageActionIconMaxSize, 50 gfx::Size(Extension::kPageActionIconMaxSize,
46 Extension::kPageActionIconMaxSize), 51 Extension::kPageActionIconMaxSize),
47 ImageLoadingTracker::DONT_CACHE); 52 ImageLoadingTracker::DONT_CACHE);
48 } 53 }
49 54
55 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
56 content::Source<Profile>(
57 owner_->browser()->profile()->GetOriginalProfile()));
58
50 set_accessibility_focusable(true); 59 set_accessibility_focusable(true);
51 } 60 }
52 61
53 PageActionImageView::~PageActionImageView() { 62 PageActionImageView::~PageActionImageView() {
54 if (popup_) 63 if (popup_)
55 HidePopup(); 64 HidePopup();
56 } 65 }
57 66
58 void PageActionImageView::ExecuteAction(int button, 67 void PageActionImageView::ExecuteAction(int button,
59 bool inspect_with_devtools) { 68 bool inspect_with_devtools) {
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 icon = iter->second; 227 icon = iter->second;
219 } 228 }
220 } 229 }
221 if (!icon.isNull()) 230 if (!icon.isNull())
222 SetImage(&icon); 231 SetImage(&icon);
223 232
224 SetVisible(true); 233 SetVisible(true);
225 } 234 }
226 235
227 void PageActionImageView::InspectPopup(ExtensionAction* action) { 236 void PageActionImageView::InspectPopup(ExtensionAction* action) {
228 ExecuteAction(1, // left-click 237 ExecuteAction(1, // Left-click.
229 true); // inspect_with_devtools 238 true); // |inspect_with_devtools|.
230 } 239 }
231 240
232 void PageActionImageView::ExtensionPopupIsClosing(ExtensionPopup* popup) { 241 void PageActionImageView::ExtensionPopupIsClosing(ExtensionPopup* popup) {
233 DCHECK_EQ(popup_, popup); 242 DCHECK_EQ(popup_, popup);
234 // ExtensionPopup is ref-counted, so we don't need to delete it. 243 // ExtensionPopup is ref-counted, so we don't need to delete it.
235 popup_ = NULL; 244 popup_ = NULL;
236 } 245 }
237 246
247 void PageActionImageView::Observe(int type,
248 const content::NotificationSource& source,
249 const content::NotificationDetails& details) {
250 DCHECK_EQ(chrome::NOTIFICATION_EXTENSION_UNLOADED, type);
251 const Extension* unloaded_extension =
252 content::Details<UnloadedExtensionInfo>(details)->extension;
253 if (page_action_ == unloaded_extension ->page_action())
254 owner_->UpdatePageActions();
255 }
256
238 void PageActionImageView::HidePopup() { 257 void PageActionImageView::HidePopup() {
239 if (popup_) 258 if (popup_)
240 popup_->Close(); 259 popup_->Close();
241 } 260 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/location_bar/page_action_image_view.h ('k') | chrome/test/base/testing_profile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698