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

Side by Side Diff: chrome/browser/extensions/extension_tab_helper.cc

Issue 10388160: Only return the visible page actions from PageActionController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: actually fix Created 8 years, 7 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/extensions/extension_tab_helper.h" 5 #include "chrome/browser/extensions/extension_tab_helper.h"
6 6
7 #include "chrome/browser/extensions/extension_service.h" 7 #include "chrome/browser/extensions/extension_service.h"
8 #include "chrome/browser/extensions/page_action_controller.h"
9 #include "chrome/browser/extensions/script_executor_impl.h"
8 #include "chrome/browser/extensions/webstore_inline_installer.h" 10 #include "chrome/browser/extensions/webstore_inline_installer.h"
9 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sessions/restore_tab_helper.h" 12 #include "chrome/browser/sessions/restore_tab_helper.h"
11 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
12 #include "chrome/browser/ui/browser_list.h" 14 #include "chrome/browser/ui/browser_list.h"
13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
14 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
15 #include "chrome/common/extensions/extension_action.h" 17 #include "chrome/common/extensions/extension_action.h"
16 #include "chrome/common/extensions/extension_constants.h" 18 #include "chrome/common/extensions/extension_constants.h"
17 #include "chrome/common/extensions/extension_icon_set.h" 19 #include "chrome/common/extensions/extension_icon_set.h"
18 #include "chrome/common/extensions/extension_messages.h" 20 #include "chrome/common/extensions/extension_messages.h"
19 #include "chrome/common/extensions/extension_resource.h" 21 #include "chrome/common/extensions/extension_resource.h"
20 #include "content/public/browser/invalidate_type.h" 22 #include "content/public/browser/invalidate_type.h"
21 #include "content/public/browser/navigation_details.h" 23 #include "content/public/browser/navigation_details.h"
22 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
23 #include "content/public/browser/render_process_host.h" 25 #include "content/public/browser/render_process_host.h"
24 #include "content/public/browser/render_view_host.h" 26 #include "content/public/browser/render_view_host.h"
25 #include "content/public/browser/render_widget_host_view.h" 27 #include "content/public/browser/render_widget_host_view.h"
26 #include "content/public/browser/web_contents.h" 28 #include "content/public/browser/web_contents.h"
27 #include "ui/gfx/image/image.h" 29 #include "ui/gfx/image/image.h"
28 30
29 using content::WebContents; 31 using content::WebContents;
32 using extensions::ScriptExecutorImpl;
33 using extensions::PageActionController;
30 34
31 namespace { 35 namespace {
32 36
33 const char kPermissionError[] = "permission_error"; 37 const char kPermissionError[] = "permission_error";
34 38
35 } // namespace 39 } // namespace
36 40
37 ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper) 41 ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper)
38 : content::WebContentsObserver(wrapper->web_contents()), 42 : content::WebContentsObserver(wrapper->web_contents()),
39 delegate_(NULL), 43 delegate_(NULL),
40 extension_app_(NULL), 44 extension_app_(NULL),
41 ALLOW_THIS_IN_INITIALIZER_LIST( 45 ALLOW_THIS_IN_INITIALIZER_LIST(
42 extension_function_dispatcher_(wrapper->profile(), this)), 46 extension_function_dispatcher_(wrapper->profile(), this)),
43 wrapper_(wrapper) { 47 wrapper_(wrapper) {
48 script_executor_.reset(new ScriptExecutorImpl(wrapper->web_contents()));
49 action_box_controller_.reset(new PageActionController(wrapper, this));
44 } 50 }
45 51
46 ExtensionTabHelper::~ExtensionTabHelper() { 52 ExtensionTabHelper::~ExtensionTabHelper() {
47 } 53 }
48 54
49 void ExtensionTabHelper::CopyStateFrom(const ExtensionTabHelper& source) { 55 void ExtensionTabHelper::CopyStateFrom(const ExtensionTabHelper& source) {
50 SetExtensionApp(source.extension_app()); 56 SetExtensionApp(source.extension_app());
51 extension_app_icon_ = source.extension_app_icon_; 57 extension_app_icon_ = source.extension_app_icon_;
52 } 58 }
53 59
54 void ExtensionTabHelper::PageActionStateChanged() { 60 void ExtensionTabHelper::PageActionStateChanged() {
61 // TODO(kalman): replace this with just the Observer interface.
55 web_contents()->NotifyNavigationStateChanged( 62 web_contents()->NotifyNavigationStateChanged(
56 content::INVALIDATE_TYPE_PAGE_ACTIONS); 63 content::INVALIDATE_TYPE_PAGE_ACTIONS);
64
65 FOR_EACH_OBSERVER(Observer, observers_, OnPageActionStateChanged());
57 } 66 }
58 67
59 void ExtensionTabHelper::GetApplicationInfo(int32 page_id) { 68 void ExtensionTabHelper::GetApplicationInfo(int32 page_id) {
60 Send(new ExtensionMsg_GetApplicationInfo(routing_id(), page_id)); 69 Send(new ExtensionMsg_GetApplicationInfo(routing_id(), page_id));
61 } 70 }
62 71
72 void ExtensionTabHelper::AddObserver(ExtensionTabHelper::Observer* observer) {
73 observers_.AddObserver(observer);
74 }
75
76 void ExtensionTabHelper::RemoveObserver(
77 ExtensionTabHelper::Observer* observer) {
78 observers_.RemoveObserver(observer);
79 }
80
63 void ExtensionTabHelper::SetExtensionApp(const Extension* extension) { 81 void ExtensionTabHelper::SetExtensionApp(const Extension* extension) {
64 DCHECK(!extension || extension->GetFullLaunchURL().is_valid()); 82 DCHECK(!extension || extension->GetFullLaunchURL().is_valid());
65 extension_app_ = extension; 83 extension_app_ = extension;
66 84
67 UpdateExtensionAppIcon(extension_app_); 85 UpdateExtensionAppIcon(extension_app_);
68 86
69 content::NotificationService::current()->Notify( 87 content::NotificationService::current()->Notify(
70 chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, 88 chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED,
71 content::Source<ExtensionTabHelper>(this), 89 content::Source<ExtensionTabHelper>(this),
72 content::NotificationService::NoDetails()); 90 content::NotificationService::NoDetails());
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 void ExtensionTabHelper::OnInlineInstallFailure(int install_id, 359 void ExtensionTabHelper::OnInlineInstallFailure(int install_id,
342 int return_route_id, 360 int return_route_id,
343 const std::string& error) { 361 const std::string& error) {
344 Send(new ExtensionMsg_InlineWebstoreInstallResponse( 362 Send(new ExtensionMsg_InlineWebstoreInstallResponse(
345 return_route_id, install_id, false, error)); 363 return_route_id, install_id, false, error));
346 } 364 }
347 365
348 WebContents* ExtensionTabHelper::GetAssociatedWebContents() const { 366 WebContents* ExtensionTabHelper::GetAssociatedWebContents() const {
349 return web_contents(); 367 return web_contents();
350 } 368 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tab_helper.h ('k') | chrome/browser/extensions/extension_tabs_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698