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

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

Issue 10332235: Make the page action space show extensions with active content scripts or (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . 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" 8 #include "chrome/browser/extensions/page_action_controller.h"
9 #include "chrome/browser/extensions/script_badge_controller.h"
9 #include "chrome/browser/extensions/script_executor_impl.h" 10 #include "chrome/browser/extensions/script_executor_impl.h"
10 #include "chrome/browser/extensions/webstore_inline_installer.h" 11 #include "chrome/browser/extensions/webstore_inline_installer.h"
11 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/sessions/restore_tab_helper.h" 13 #include "chrome/browser/sessions/restore_tab_helper.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_list.h" 15 #include "chrome/browser/ui/browser_list.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
16 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
17 #include "chrome/common/extensions/extension_action.h" 18 #include "chrome/common/extensions/extension_action.h"
18 #include "chrome/common/extensions/extension_constants.h" 19 #include "chrome/common/extensions/extension_constants.h"
19 #include "chrome/common/extensions/extension_icon_set.h" 20 #include "chrome/common/extensions/extension_icon_set.h"
20 #include "chrome/common/extensions/extension_messages.h" 21 #include "chrome/common/extensions/extension_messages.h"
21 #include "chrome/common/extensions/extension_resource.h" 22 #include "chrome/common/extensions/extension_resource.h"
23 #include "chrome/common/extensions/extension_switch_utils.h"
22 #include "content/public/browser/invalidate_type.h" 24 #include "content/public/browser/invalidate_type.h"
23 #include "content/public/browser/navigation_details.h" 25 #include "content/public/browser/navigation_details.h"
24 #include "content/public/browser/notification_service.h" 26 #include "content/public/browser/notification_service.h"
25 #include "content/public/browser/render_process_host.h" 27 #include "content/public/browser/render_process_host.h"
26 #include "content/public/browser/render_view_host.h" 28 #include "content/public/browser/render_view_host.h"
27 #include "content/public/browser/render_widget_host_view.h" 29 #include "content/public/browser/render_widget_host_view.h"
28 #include "content/public/browser/web_contents.h" 30 #include "content/public/browser/web_contents.h"
29 #include "ui/gfx/image/image.h" 31 #include "ui/gfx/image/image.h"
30 32
31 using content::WebContents; 33 using content::WebContents;
34 using extensions::ScriptBadgeController;
32 using extensions::ScriptExecutorImpl; 35 using extensions::ScriptExecutorImpl;
33 using extensions::PageActionController; 36 using extensions::PageActionController;
34 37
35 namespace { 38 namespace {
36 39
37 const char kPermissionError[] = "permission_error"; 40 const char kPermissionError[] = "permission_error";
38 41
39 } // namespace 42 } // namespace
40 43
41 ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper) 44 ExtensionTabHelper::ExtensionTabHelper(TabContentsWrapper* wrapper)
42 : content::WebContentsObserver(wrapper->web_contents()), 45 : content::WebContentsObserver(wrapper->web_contents()),
43 delegate_(NULL), 46 delegate_(NULL),
44 extension_app_(NULL), 47 extension_app_(NULL),
45 ALLOW_THIS_IN_INITIALIZER_LIST( 48 ALLOW_THIS_IN_INITIALIZER_LIST(
46 extension_function_dispatcher_(wrapper->profile(), this)), 49 extension_function_dispatcher_(wrapper->profile(), this)),
47 wrapper_(wrapper) { 50 wrapper_(wrapper) {
48 script_executor_.reset(new ScriptExecutorImpl(wrapper->web_contents())); 51 if (extensions::switch_utils::IsActionBoxEnabled()) {
49 action_box_controller_.reset(new PageActionController(wrapper, this)); 52 script_badge_controller_.reset(new ScriptBadgeController(wrapper));
53 } else {
54 script_executor_.reset(new ScriptExecutorImpl(wrapper->web_contents()));
55 action_box_controller_.reset(new PageActionController(wrapper, this));
56 }
50 } 57 }
51 58
52 ExtensionTabHelper::~ExtensionTabHelper() { 59 ExtensionTabHelper::~ExtensionTabHelper() {
53 } 60 }
54 61
55 void ExtensionTabHelper::CopyStateFrom(const ExtensionTabHelper& source) { 62 void ExtensionTabHelper::CopyStateFrom(const ExtensionTabHelper& source) {
56 SetExtensionApp(source.extension_app()); 63 SetExtensionApp(source.extension_app());
57 extension_app_icon_ = source.extension_app_icon_; 64 extension_app_icon_ = source.extension_app_icon_;
58 } 65 }
59 66
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 UpdateExtensionAppIcon(extension); 111 UpdateExtensionAppIcon(extension);
105 } 112 }
106 113
107 SkBitmap* ExtensionTabHelper::GetExtensionAppIcon() { 114 SkBitmap* ExtensionTabHelper::GetExtensionAppIcon() {
108 if (extension_app_icon_.empty()) 115 if (extension_app_icon_.empty())
109 return NULL; 116 return NULL;
110 117
111 return &extension_app_icon_; 118 return &extension_app_icon_;
112 } 119 }
113 120
121 extensions::ScriptExecutor* ExtensionTabHelper::script_executor() {
122 if (script_badge_controller_.get())
123 return script_badge_controller_.get();
124 return script_executor_.get();
125 }
126
127 extensions::ActionBoxController* ExtensionTabHelper::action_box_controller() {
128 if (script_badge_controller_.get())
129 return script_badge_controller_.get();
130 return action_box_controller_.get();
131 }
132
114 void ExtensionTabHelper::DidNavigateMainFrame( 133 void ExtensionTabHelper::DidNavigateMainFrame(
115 const content::LoadCommittedDetails& details, 134 const content::LoadCommittedDetails& details,
116 const content::FrameNavigateParams& params) { 135 const content::FrameNavigateParams& params) {
117 if (details.is_in_page) 136 if (details.is_in_page)
118 return; 137 return;
119 138
120 Profile* profile = 139 Profile* profile =
121 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 140 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
122 ExtensionService* service = profile->GetExtensionService(); 141 ExtensionService* service = profile->GetExtensionService();
123 if (!service) 142 if (!service)
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 void ExtensionTabHelper::OnInlineInstallFailure(int install_id, 378 void ExtensionTabHelper::OnInlineInstallFailure(int install_id,
360 int return_route_id, 379 int return_route_id,
361 const std::string& error) { 380 const std::string& error) {
362 Send(new ExtensionMsg_InlineWebstoreInstallResponse( 381 Send(new ExtensionMsg_InlineWebstoreInstallResponse(
363 return_route_id, install_id, false, error)); 382 return_route_id, install_id, false, error));
364 } 383 }
365 384
366 WebContents* ExtensionTabHelper::GetAssociatedWebContents() const { 385 WebContents* ExtensionTabHelper::GetAssociatedWebContents() const {
367 return web_contents(); 386 return web_contents();
368 } 387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698