Index: chrome/browser/ui/views/location_bar/action_box_button_view.cc |
diff --git a/chrome/browser/ui/views/location_bar/action_box_button_view.cc b/chrome/browser/ui/views/location_bar/action_box_button_view.cc |
index 6d25cd40e29856b66e76a8fd8ed3e2722d694339..f35de3bef2e70c747ab97bc8c850ac1dd9be029a 100644 |
--- a/chrome/browser/ui/views/location_bar/action_box_button_view.cc |
+++ b/chrome/browser/ui/views/location_bar/action_box_button_view.cc |
@@ -8,7 +8,12 @@ |
#include "chrome/app/chrome_command_ids.h" |
#include "chrome/browser/command_updater.h" |
#include "chrome/browser/extensions/extension_service.h" |
+#include "chrome/browser/extensions/extension_system.h" |
+#include "chrome/browser/ui/browser_finder.h" |
+#include "chrome/browser/ui/tab_contents/tab_contents.h" |
+#include "chrome/browser/ui/toolbar/action_box_menu_model.h" |
#include "chrome/browser/ui/view_ids.h" |
+#include "chrome/browser/ui/views/action_box_menu.h" |
#include "chrome/browser/ui/views/browser_dialogs.h" |
#include "grit/generated_resources.h" |
#include "grit/theme_resources.h" |
@@ -31,9 +36,12 @@ const SkColor kPushedBorderColor = SkColorSetRGB(191, 191, 191); |
} // namespace |
-ActionBoxButtonView::ActionBoxButtonView(ExtensionService* extension_service) |
+ActionBoxButtonView::ActionBoxButtonView(Profile* profile, |
+ LocationBarView::Delegate* delegate) |
: views::MenuButton(NULL, string16(), this, false), |
- extension_service_(extension_service) { |
+ profile_(profile), |
+ delegate_(delegate), |
+ bookmark_state_(false) { |
set_id(VIEW_ID_ACTION_BOX_BUTTON); |
SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_ACTION_BOX_BUTTON)); |
SetIcon(*ui::ResourceBundle::GetSharedInstance().GetBitmapNamed( |
@@ -67,6 +75,10 @@ SkColor ActionBoxButtonView::GetBorderColor() { |
} |
} |
+void ActionBoxButtonView::SetBookmarkState(bool on) { |
+ bookmark_state_ = on; |
Aaron Boodman
2012/07/02 22:41:34
Do you need to trigger a paint here?
yefimt
2012/07/11 22:34:34
I don't think so, button by itself doesn't show bo
|
+} |
+ |
void ActionBoxButtonView::GetAccessibleState(ui::AccessibleViewState* state) { |
MenuButton::GetAccessibleState(state); |
state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_ACTION_BOX_BUTTON); |
@@ -74,5 +86,23 @@ void ActionBoxButtonView::GetAccessibleState(ui::AccessibleViewState* state) { |
void ActionBoxButtonView::OnMenuButtonClicked(View* source, |
const gfx::Point& point) { |
- // TODO(yefim): Implement menu here. |
+ ExtensionService* extension_service = |
+ ExtensionSystem::Get(profile_)->extension_service(); |
+ if (!extension_service) |
+ return; |
+ |
+ const TabContents* tab_contents = delegate_->GetTabContents(); |
+ if (!tab_contents) |
+ return; |
+ Browser* browser = |
Aaron Boodman
2012/07/02 22:41:34
Add blank line before this one.
yefimt
2012/07/11 22:34:34
Done.
|
+ browser::FindBrowserWithWebContents(tab_contents->web_contents()); |
+ |
Aaron Boodman
2012/07/02 22:41:34
Remove blank line.
yefimt
2012/07/11 22:34:34
Done.
|
+ if (!browser) |
+ return; |
+ |
+ ActionBoxMenuModel model(extension_service); |
+ action_box_menu_.reset(new ActionBoxMenu(browser, &model, bookmark_state_)); |
+ action_box_menu_->Init(); |
+ action_box_menu_->RunMenu(this); |
+ action_box_menu_.reset(NULL); |
} |