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

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

Issue 10533086: Action box menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Action box menu Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/action_box_button_view.h" 5 #include "chrome/browser/ui/views/location_bar/action_box_button_view.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/command_updater.h" 9 #include "chrome/browser/command_updater.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
11 #include "chrome/browser/extensions/extension_system.h"
12 #include "chrome/browser/ui/browser_finder.h"
13 #include "chrome/browser/ui/tab_contents/tab_contents.h"
14 #include "chrome/browser/ui/toolbar/action_box_menu_model.h"
11 #include "chrome/browser/ui/view_ids.h" 15 #include "chrome/browser/ui/view_ids.h"
16 #include "chrome/browser/ui/views/action_box_menu.h"
12 #include "chrome/browser/ui/views/browser_dialogs.h" 17 #include "chrome/browser/ui/views/browser_dialogs.h"
13 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
14 #include "grit/theme_resources.h" 19 #include "grit/theme_resources.h"
15 #include "ui/base/accessibility/accessible_view_state.h" 20 #include "ui/base/accessibility/accessible_view_state.h"
16 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h" 22 #include "ui/base/resource/resource_bundle.h"
18 23
19 namespace { 24 namespace {
20 25
21 // Colors used for button backgrounds. 26 // Colors used for button backgrounds.
22 const SkColor kNormalBackgroundColor = SkColorSetRGB(255, 255, 255); 27 const SkColor kNormalBackgroundColor = SkColorSetRGB(255, 255, 255);
23 const SkColor kHotBackgroundColor = SkColorSetRGB(239, 239, 239); 28 const SkColor kHotBackgroundColor = SkColorSetRGB(239, 239, 239);
24 const SkColor kPushedBackgroundColor = SkColorSetRGB(207, 207, 207); 29 const SkColor kPushedBackgroundColor = SkColorSetRGB(207, 207, 207);
25 30
26 const SkColor kNormalBorderColor = SkColorSetRGB(255, 255, 255); 31 const SkColor kNormalBorderColor = SkColorSetRGB(255, 255, 255);
27 const SkColor kHotBorderColor = SkColorSetRGB(223, 223, 223); 32 const SkColor kHotBorderColor = SkColorSetRGB(223, 223, 223);
28 const SkColor kPushedBorderColor = SkColorSetRGB(191, 191, 191); 33 const SkColor kPushedBorderColor = SkColorSetRGB(191, 191, 191);
29 34
30 } // namespace 35 } // namespace
31 36
32 37
33 ActionBoxButtonView::ActionBoxButtonView(ExtensionService* extension_service) 38 ActionBoxButtonView::ActionBoxButtonView(Profile* profile,
39 Delegate* delegate)
34 : views::MenuButton(NULL, string16(), this, false), 40 : views::MenuButton(NULL, string16(), this, false),
35 extension_service_(extension_service) { 41 profile_(profile),
42 delegate_(delegate),
43 bookmark_state_(false) {
36 set_id(VIEW_ID_ACTION_BOX_BUTTON); 44 set_id(VIEW_ID_ACTION_BOX_BUTTON);
37 SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_ACTION_BOX_BUTTON)); 45 SetTooltipText(l10n_util::GetStringUTF16(IDS_TOOLTIP_ACTION_BOX_BUTTON));
38 SetIcon(*ui::ResourceBundle::GetSharedInstance().GetBitmapNamed( 46 SetIcon(*ui::ResourceBundle::GetSharedInstance().GetBitmapNamed(
39 IDR_ACTION_BOX_BUTTON)); 47 IDR_ACTION_BOX_BUTTON));
40 set_accessibility_focusable(true); 48 set_accessibility_focusable(true);
41 set_border(NULL); 49 set_border(NULL);
42 } 50 }
43 51
44 ActionBoxButtonView::~ActionBoxButtonView() { 52 ActionBoxButtonView::~ActionBoxButtonView() {
45 } 53 }
(...skipping 20 matching lines...) Expand all
66 } 74 }
67 } 75 }
68 76
69 void ActionBoxButtonView::GetAccessibleState(ui::AccessibleViewState* state) { 77 void ActionBoxButtonView::GetAccessibleState(ui::AccessibleViewState* state) {
70 MenuButton::GetAccessibleState(state); 78 MenuButton::GetAccessibleState(state);
71 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_ACTION_BOX_BUTTON); 79 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_ACTION_BOX_BUTTON);
72 } 80 }
73 81
74 void ActionBoxButtonView::OnMenuButtonClicked(View* source, 82 void ActionBoxButtonView::OnMenuButtonClicked(View* source,
75 const gfx::Point& point) { 83 const gfx::Point& point) {
76 // TODO(yefim): Implement menu here. 84 ExtensionService* extension_service =
85 extensions::ExtensionSystem::Get(profile_)->extension_service();
86 if (!extension_service)
Peter Kasting 2012/07/18 01:37:25 Can either of these NULL-checks ever actually fail
yefimt 2012/07/18 23:18:13 I dont know enough yet to say for sure, but there
Peter Kasting 2012/07/19 04:27:31 The extension service might be able to be NULL whe
yefimt 2012/07/19 20:00:15 It was my original implementation to pass browser
Peter Kasting 2012/07/19 20:45:11 The Browser isn't NULL at this point, the Location
87 return;
88
89 Browser* browser = delegate_->GetBrowser();
90 if (!browser)
91 return;
92
93 ActionBoxMenuModel model(extension_service);
94 action_box_menu_.reset(new ActionBoxMenu(browser, &model, bookmark_state_));
95 action_box_menu_->Init();
96 action_box_menu_->RunMenu(this);
97 action_box_menu_.reset();
77 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698