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

Side by Side Diff: chrome/browser/ui/views/browser_actions_container.cc

Issue 6452011: Rework tree APIs to reflect Google style and more const-correctness.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months 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/browser_actions_container.h" 5 #include "chrome/browser/ui/views/browser_actions_container.h"
6 6
7 #include "base/stl_util-inl.h" 7 #include "base/stl_util-inl.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_window.h" 10 #include "chrome/browser/browser_window.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 SkIntToScalar((bg_p.height() - icon.height()) / 2), &paint); 163 SkIntToScalar((bg_p.height() - icon.height()) / 2), &paint);
164 SetPushedIcon(bg_p); 164 SetPushedIcon(bg_p);
165 } 165 }
166 166
167 // If the browser action name is empty, show the extension name instead. 167 // If the browser action name is empty, show the extension name instead.
168 string16 name = UTF8ToUTF16(browser_action()->GetTitle(tab_id)); 168 string16 name = UTF8ToUTF16(browser_action()->GetTitle(tab_id));
169 if (name.empty()) 169 if (name.empty())
170 name = UTF8ToUTF16(extension()->name()); 170 name = UTF8ToUTF16(extension()->name());
171 SetTooltipText(UTF16ToWideHack(name)); 171 SetTooltipText(UTF16ToWideHack(name));
172 SetAccessibleName(name); 172 SetAccessibleName(name);
173 GetParent()->SchedulePaint(); 173 parent()->SchedulePaint();
174 } 174 }
175 175
176 void BrowserActionButton::Observe(NotificationType type, 176 void BrowserActionButton::Observe(NotificationType type,
177 const NotificationSource& source, 177 const NotificationSource& source,
178 const NotificationDetails& details) { 178 const NotificationDetails& details) {
179 DCHECK(type == NotificationType::EXTENSION_BROWSER_ACTION_UPDATED); 179 DCHECK(type == NotificationType::EXTENSION_BROWSER_ACTION_UPDATED);
180 UpdateState(); 180 UpdateState();
181 // The browser action may have become visible/hidden so we need to make 181 // The browser action may have become visible/hidden so we need to make
182 // sure the state gets updated. 182 // sure the state gets updated.
183 panel_->OnBrowserActionVisibilityChanged(); 183 panel_->OnBrowserActionVisibilityChanged();
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 // Always hide the current popup, even if it's not the same. 498 // Always hide the current popup, even if it's not the same.
499 // Only one popup should be visible at a time. 499 // Only one popup should be visible at a time.
500 HidePopup(); 500 HidePopup();
501 501
502 if (same_showing) 502 if (same_showing)
503 return; 503 return;
504 504
505 // We can get the execute event for browser actions that are not visible, 505 // We can get the execute event for browser actions that are not visible,
506 // since buttons can be activated from the overflow menu (chevron). In that 506 // since buttons can be activated from the overflow menu (chevron). In that
507 // case we show the popup as originating from the chevron. 507 // case we show the popup as originating from the chevron.
508 View* reference_view = button->GetParent()->IsVisible() ? button : chevron_; 508 View* reference_view = button->parent()->IsVisible() ? button : chevron_;
509 gfx::Point origin; 509 gfx::Point origin;
510 View::ConvertPointToScreen(reference_view, &origin); 510 View::ConvertPointToScreen(reference_view, &origin);
511 gfx::Rect rect = reference_view->bounds(); 511 gfx::Rect rect = reference_view->bounds();
512 rect.set_origin(origin); 512 rect.set_origin(origin);
513 513
514 gfx::NativeWindow frame_window = browser_->window()->GetNativeHandle(); 514 gfx::NativeWindow frame_window = browser_->window()->GetNativeHandle();
515 BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ? 515 BubbleBorder::ArrowLocation arrow_location = base::i18n::IsRTL() ?
516 BubbleBorder::TOP_LEFT : BubbleBorder::TOP_RIGHT; 516 BubbleBorder::TOP_LEFT : BubbleBorder::TOP_RIGHT;
517 517
518 popup_ = ExtensionPopup::Show(button->GetPopupUrl(), browser_, 518 popup_ = ExtensionPopup::Show(button->GetPopupUrl(), browser_,
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 if (!ShouldDisplayBrowserAction(extension)) 905 if (!ShouldDisplayBrowserAction(extension))
906 return; 906 return;
907 907
908 size_t visible_actions = VisibleBrowserActions(); 908 size_t visible_actions = VisibleBrowserActions();
909 909
910 // Add the new browser action to the vector and the view hierarchy. 910 // Add the new browser action to the vector and the view hierarchy.
911 if (profile_->IsOffTheRecord()) 911 if (profile_->IsOffTheRecord())
912 index = model_->OriginalIndexToIncognito(index); 912 index = model_->OriginalIndexToIncognito(index);
913 BrowserActionView* view = new BrowserActionView(extension, this); 913 BrowserActionView* view = new BrowserActionView(extension, this);
914 browser_action_views_.insert(browser_action_views_.begin() + index, view); 914 browser_action_views_.insert(browser_action_views_.begin() + index, view);
915 AddChildView(index, view); 915 AddChildViewAt(view, index);
916 916
917 // If we are still initializing the container, don't bother animating. 917 // If we are still initializing the container, don't bother animating.
918 if (!model_->extensions_initialized()) 918 if (!model_->extensions_initialized())
919 return; 919 return;
920 920
921 // Enlarge the container if it was already at maximum size and we're not in 921 // Enlarge the container if it was already at maximum size and we're not in
922 // the middle of upgrading. 922 // the middle of upgrading.
923 if ((model_->GetVisibleIconCount() < 0) && 923 if ((model_->GetVisibleIconCount() < 0) &&
924 !profile_->GetExtensionService()->IsBeingUpgraded(extension)) { 924 !profile_->GetExtensionService()->IsBeingUpgraded(extension)) {
925 suppress_chevron_ = true; 925 suppress_chevron_ = true;
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 AnimationEnded(resize_animation_.get()); 1096 AnimationEnded(resize_animation_.get());
1097 } 1097 }
1098 } 1098 }
1099 1099
1100 bool BrowserActionsContainer::ShouldDisplayBrowserAction( 1100 bool BrowserActionsContainer::ShouldDisplayBrowserAction(
1101 const Extension* extension) { 1101 const Extension* extension) {
1102 // Only display incognito-enabled extensions while in incognito mode. 1102 // Only display incognito-enabled extensions while in incognito mode.
1103 return (!profile_->IsOffTheRecord() || 1103 return (!profile_->IsOffTheRecord() ||
1104 profile_->GetExtensionService()->IsIncognitoEnabled(extension)); 1104 profile_->GetExtensionService()->IsIncognitoEnabled(extension));
1105 } 1105 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/bookmark_menu_controller_views.cc ('k') | chrome/browser/ui/views/download_item_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698