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

Side by Side Diff: chrome/browser/views/location_bar_view.cc

Issue 425018: Merge 32277 - Fix a crash when activating a select element inside a page... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/249/src/
Patch Set: Created 11 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
« no previous file with comments | « chrome/browser/views/location_bar_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/views/location_bar_view.h" 5 #include "chrome/browser/views/location_bar_view.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 LocationBarView::PageActionImageView::PageActionImageView( 1287 LocationBarView::PageActionImageView::PageActionImageView(
1288 LocationBarView* owner, 1288 LocationBarView* owner,
1289 Profile* profile, 1289 Profile* profile,
1290 ExtensionAction* page_action, 1290 ExtensionAction* page_action,
1291 const BubblePositioner* bubble_positioner) 1291 const BubblePositioner* bubble_positioner)
1292 : LocationBarImageView(bubble_positioner), 1292 : LocationBarImageView(bubble_positioner),
1293 owner_(owner), 1293 owner_(owner),
1294 profile_(profile), 1294 profile_(profile),
1295 page_action_(page_action), 1295 page_action_(page_action),
1296 current_tab_id_(-1), 1296 current_tab_id_(-1),
1297 preview_enabled_(false) { 1297 preview_enabled_(false),
1298 popup_(NULL),
1299 ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)) {
1298 Extension* extension = profile->GetExtensionsService()->GetExtensionById( 1300 Extension* extension = profile->GetExtensionsService()->GetExtensionById(
1299 page_action->extension_id(), false); 1301 page_action->extension_id(), false);
1300 DCHECK(extension); 1302 DCHECK(extension);
1301 1303
1302 // Load all the icons declared in the manifest. This is the contents of the 1304 // Load all the icons declared in the manifest. This is the contents of the
1303 // icons array, plus the default_icon property, if any. 1305 // icons array, plus the default_icon property, if any.
1304 std::vector<std::string> icon_paths(*page_action->icon_paths()); 1306 std::vector<std::string> icon_paths(*page_action->icon_paths());
1305 if (!page_action_->default_icon_path().empty()) 1307 if (!page_action_->default_icon_path().empty())
1306 icon_paths.push_back(page_action_->default_icon_path()); 1308 icon_paths.push_back(page_action_->default_icon_path());
1307 1309
1308 tracker_ = new ImageLoadingTracker(this, icon_paths.size()); 1310 tracker_ = new ImageLoadingTracker(this, icon_paths.size());
1309 for (std::vector<std::string>::iterator iter = icon_paths.begin(); 1311 for (std::vector<std::string>::iterator iter = icon_paths.begin();
1310 iter != icon_paths.end(); ++iter) { 1312 iter != icon_paths.end(); ++iter) {
1311 tracker_->PostLoadImageTask( 1313 tracker_->PostLoadImageTask(
1312 extension->GetResource(*iter), 1314 extension->GetResource(*iter),
1313 gfx::Size(Extension::kPageActionIconMaxSize, 1315 gfx::Size(Extension::kPageActionIconMaxSize,
1314 Extension::kPageActionIconMaxSize)); 1316 Extension::kPageActionIconMaxSize));
1315 } 1317 }
1316 } 1318 }
1317 1319
1318 LocationBarView::PageActionImageView::~PageActionImageView() { 1320 LocationBarView::PageActionImageView::~PageActionImageView() {
1319 if (tracker_) 1321 if (tracker_)
1320 tracker_->StopTrackingImageLoad(); 1322 tracker_->StopTrackingImageLoad();
1323
1324 if (popup_)
1325 HidePopup();
1321 } 1326 }
1322 1327
1323 void LocationBarView::PageActionImageView::ExecuteAction(int button) { 1328 void LocationBarView::PageActionImageView::ExecuteAction(int button) {
1324 if (page_action_->has_popup()) { 1329 if (page_action_->has_popup()) {
1325 gfx::Point origin;
1326 View::ConvertPointToScreen(this, &origin);
1327 gfx::Rect rect = bounds();
1328 rect.set_x(origin.x());
1329 rect.set_y(origin.y());
1330
1331 // In tests, GetLastActive could return NULL, so we need to have 1330 // In tests, GetLastActive could return NULL, so we need to have
1332 // a fallback. 1331 // a fallback.
1333 // TODO(erikkay): Find a better way to get the Browser that this 1332 // TODO(erikkay): Find a better way to get the Browser that this
1334 // button is in. 1333 // button is in.
1335 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); 1334 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_);
1336 if (!browser) 1335 if (!browser)
1337 browser = BrowserList::FindBrowserWithProfile(profile_); 1336 browser = BrowserList::FindBrowserWithProfile(profile_);
1338 ExtensionPopup::Show(page_action_->popup_url(), browser, rect, 1337
1339 BubbleBorder::TOP_RIGHT); 1338 // Always hide the current popup. Only one popup at a time.
1339 HidePopup();
1340
1341 gfx::Point origin;
1342 View::ConvertPointToScreen(this, &origin);
1343 gfx::Rect rect = bounds();
1344 rect.set_x(origin.x());
1345 rect.set_y(origin.y());
1346 popup_ = ExtensionPopup::Show(page_action_->popup_url(), browser, rect,
1347 BubbleBorder::TOP_RIGHT);
1348 popup_->set_delegate(this);
1340 } else { 1349 } else {
1341 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted( 1350 ExtensionBrowserEventRouter::GetInstance()->PageActionExecuted(
1342 profile_, page_action_->extension_id(), page_action_->id(), 1351 profile_, page_action_->extension_id(), page_action_->id(),
1343 current_tab_id_, current_url_.spec(), button); 1352 current_tab_id_, current_url_.spec(), button);
1344 } 1353 }
1345 } 1354 }
1346 1355
1347 void LocationBarView::PageActionImageView::OnMouseMoved( 1356 void LocationBarView::PageActionImageView::OnMouseMoved(
1348 const views::MouseEvent& event) { 1357 const views::MouseEvent& event) {
1349 // PageActionImageView uses normal tooltips rather than the info bubble, 1358 // PageActionImageView uses normal tooltips rather than the info bubble,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 icon = iter->second; 1442 icon = iter->second;
1434 } 1443 }
1435 } 1444 }
1436 1445
1437 if (!icon.isNull()) 1446 if (!icon.isNull())
1438 ImageView::SetImage(&icon); 1447 ImageView::SetImage(&icon);
1439 } 1448 }
1440 SetVisible(visible); 1449 SetVisible(visible);
1441 } 1450 }
1442 1451
1452 void LocationBarView::PageActionImageView::BubbleBrowserWindowClosing(
1453 BrowserBubble* bubble) {
1454 HidePopup();
1455 }
1456
1457 void LocationBarView::PageActionImageView::BubbleLostFocus(
1458 BrowserBubble* bubble) {
1459 if (!popup_)
1460 return;
1461
1462 MessageLoop::current()->PostTask(FROM_HERE,
1463 method_factory_.NewRunnableMethod(
1464 &LocationBarView::PageActionImageView::HidePopup));
1465 }
1466
1467 void LocationBarView::PageActionImageView::HidePopup() {
1468 if (!popup_)
1469 return;
1470
1471 // This sometimes gets called via a timer (See BubbleLostFocus), so clear
1472 // the method factory. in case one is pending.
1473 method_factory_.RevokeAll();
1474
1475 // Save the popup in a local since destroying it calls BubbleLostFocus,
1476 // which will try to call HidePopup() again.
1477 ExtensionPopup* closing_popup = popup_;
1478 popup_ = NULL;
1479
1480 closing_popup->DetachFromBrowser();
1481 delete closing_popup;
1482 }
1483
1443 //////////////////////////////////////////////////////////////////////////////// 1484 ////////////////////////////////////////////////////////////////////////////////
1444 // LocationBarView, LocationBar implementation: 1485 // LocationBarView, LocationBar implementation:
1445 1486
1446 void LocationBarView::ShowFirstRunBubble(bool use_OEM_bubble) { 1487 void LocationBarView::ShowFirstRunBubble(bool use_OEM_bubble) {
1447 // We wait 30 milliseconds to open. It allows less flicker. 1488 // We wait 30 milliseconds to open. It allows less flicker.
1448 Task* task = first_run_bubble_.NewRunnableMethod( 1489 Task* task = first_run_bubble_.NewRunnableMethod(
1449 &LocationBarView::ShowFirstRunBubbleInternal, use_OEM_bubble); 1490 &LocationBarView::ShowFirstRunBubbleInternal, use_OEM_bubble);
1450 MessageLoop::current()->PostDelayedTask(FROM_HERE, task, 30); 1491 MessageLoop::current()->PostDelayedTask(FROM_HERE, task, 30);
1451 } 1492 }
1452 1493
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 const int button = 1; // Left mouse button. 1572 const int button = 1; // Left mouse button.
1532 page_action_views_[i]->image_view()->ExecuteAction(button); 1573 page_action_views_[i]->image_view()->ExecuteAction(button);
1533 return; 1574 return;
1534 } 1575 }
1535 ++current; 1576 ++current;
1536 } 1577 }
1537 } 1578 }
1538 } 1579 }
1539 NOTREACHED(); 1580 NOTREACHED();
1540 } 1581 }
OLDNEW
« no previous file with comments | « chrome/browser/views/location_bar_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698