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

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

Issue 376014: Reland Extension Installed InfoBubble (Closed)
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
« no previous file with comments | « chrome/browser/views/location_bar_view.h ('k') | chrome/chrome.gyp » ('j') | 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 DCHECK(profile); 331 DCHECK(profile);
332 if (profile_ != profile) { 332 if (profile_ != profile) {
333 profile_ = profile; 333 profile_ = profile;
334 location_entry_->model()->SetProfile(profile); 334 location_entry_->model()->SetProfile(profile);
335 selected_keyword_view_.set_profile(profile); 335 selected_keyword_view_.set_profile(profile);
336 keyword_hint_view_.set_profile(profile); 336 keyword_hint_view_.set_profile(profile);
337 security_image_view_.set_profile(profile); 337 security_image_view_.set_profile(profile);
338 } 338 }
339 } 339 }
340 340
341 void LocationBarView::SetPreviewEnabledPageAction(ExtensionAction *page_action,
342 bool preview_enabled) {
343 DCHECK(page_action);
344 TabContents* contents = delegate_->GetTabContents();
345
346 RefreshPageActionViews();
347 PageActionWithBadgeView* page_action_view =
348 static_cast<PageActionWithBadgeView*>(GetPageActionView(page_action));
349 DCHECK(page_action_view);
350 if (!page_action_view)
351 return;
352
353 page_action_view->image_view()->set_preview_enabled(preview_enabled);
354 page_action_view->UpdateVisibility(contents,
355 GURL(WideToUTF8(model_->GetText())));
356 Layout();
357 SchedulePaint();
358 }
359
360 views::View* LocationBarView::GetPageActionView(
361 ExtensionAction *page_action) {
362 DCHECK(page_action);
363 for (std::vector<PageActionWithBadgeView*>::iterator iter =
364 page_action_views_.begin(); iter != page_action_views_.end();
365 ++iter) {
366 if ((*iter)->image_view()->page_action() == page_action)
367 return *iter;
368 }
369 return NULL;
370 }
341 gfx::Size LocationBarView::GetPreferredSize() { 371 gfx::Size LocationBarView::GetPreferredSize() {
342 return gfx::Size(0, 372 return gfx::Size(0,
343 (popup_window_mode_ ? kPopupBackground : kBackground)->height()); 373 (popup_window_mode_ ? kPopupBackground : kBackground)->height());
344 } 374 }
345 375
346 void LocationBarView::Layout() { 376 void LocationBarView::Layout() {
347 DoLayout(true); 377 DoLayout(true);
348 } 378 }
349 379
350 void LocationBarView::Paint(gfx::Canvas* canvas) { 380 void LocationBarView::Paint(gfx::Canvas* canvas) {
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 1286
1257 LocationBarView::PageActionImageView::PageActionImageView( 1287 LocationBarView::PageActionImageView::PageActionImageView(
1258 LocationBarView* owner, 1288 LocationBarView* owner,
1259 Profile* profile, 1289 Profile* profile,
1260 ExtensionAction* page_action, 1290 ExtensionAction* page_action,
1261 const BubblePositioner* bubble_positioner) 1291 const BubblePositioner* bubble_positioner)
1262 : LocationBarImageView(bubble_positioner), 1292 : LocationBarImageView(bubble_positioner),
1263 owner_(owner), 1293 owner_(owner),
1264 profile_(profile), 1294 profile_(profile),
1265 page_action_(page_action), 1295 page_action_(page_action),
1266 current_tab_id_(-1) { 1296 current_tab_id_(-1),
1297 preview_enabled_(false) {
1267 Extension* extension = profile->GetExtensionsService()->GetExtensionById( 1298 Extension* extension = profile->GetExtensionsService()->GetExtensionById(
1268 page_action->extension_id()); 1299 page_action->extension_id());
1269 DCHECK(extension); 1300 DCHECK(extension);
1270 1301
1271 // Load all the icons declared in the manifest. This is the contents of the 1302 // Load all the icons declared in the manifest. This is the contents of the
1272 // icons array, plus the default_icon property, if any. 1303 // icons array, plus the default_icon property, if any.
1273 std::vector<std::string> icon_paths(*page_action->icon_paths()); 1304 std::vector<std::string> icon_paths(*page_action->icon_paths());
1274 if (!page_action_->default_icon_path().empty()) 1305 if (!page_action_->default_icon_path().empty())
1275 icon_paths.push_back(page_action_->default_icon_path()); 1306 icon_paths.push_back(page_action_->default_icon_path());
1276 1307
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
1363 owner_->UpdatePageActions(); 1394 owner_->UpdatePageActions();
1364 } 1395 }
1365 1396
1366 void LocationBarView::PageActionImageView::UpdateVisibility( 1397 void LocationBarView::PageActionImageView::UpdateVisibility(
1367 TabContents* contents, const GURL& url) { 1398 TabContents* contents, const GURL& url) {
1368 // Save this off so we can pass it back to the extension when the action gets 1399 // Save this off so we can pass it back to the extension when the action gets
1369 // executed. See PageActionImageView::OnMousePressed. 1400 // executed. See PageActionImageView::OnMousePressed.
1370 current_tab_id_ = ExtensionTabUtil::GetTabId(contents); 1401 current_tab_id_ = ExtensionTabUtil::GetTabId(contents);
1371 current_url_ = url; 1402 current_url_ = url;
1372 1403
1373 bool visible = page_action_->GetIsVisible(current_tab_id_); 1404 bool visible = preview_enabled_ ||
1405 page_action_->GetIsVisible(current_tab_id_);
1374 if (visible) { 1406 if (visible) {
1375 // Set the tooltip. 1407 // Set the tooltip.
1376 tooltip_ = page_action_->GetTitle(current_tab_id_); 1408 tooltip_ = page_action_->GetTitle(current_tab_id_);
1377 SetTooltipText(ASCIIToWide(tooltip_)); 1409 SetTooltipText(ASCIIToWide(tooltip_));
1378 1410
1379 // Set the image. 1411 // Set the image.
1380 // It can come from three places. In descending order of priority: 1412 // It can come from three places. In descending order of priority:
1381 // - The developer can set it dynamically by path or bitmap. It will be in 1413 // - The developer can set it dynamically by path or bitmap. It will be in
1382 // page_action_->GetIcon(). 1414 // page_action_->GetIcon().
1383 // - The developer can set it dynamically by index. It will be in 1415 // - The developer can set it dynamically by index. It will be in
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1499 const int button = 1; // Left mouse button. 1531 const int button = 1; // Left mouse button.
1500 page_action_views_[i]->image_view()->ExecuteAction(button); 1532 page_action_views_[i]->image_view()->ExecuteAction(button);
1501 return; 1533 return;
1502 } 1534 }
1503 ++current; 1535 ++current;
1504 } 1536 }
1505 } 1537 }
1506 } 1538 }
1507 NOTREACHED(); 1539 NOTREACHED();
1508 } 1540 }
OLDNEW
« no previous file with comments | « chrome/browser/views/location_bar_view.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698