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

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

Issue 10754004: Remove the refcount from ScriptBadgeController. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revert ScopedObserver 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/extensions/extension_tab_helper.h" 5 #include "chrome/browser/extensions/extension_tab_helper.h"
6 6
7 #include "chrome/browser/extensions/crx_installer.h" 7 #include "chrome/browser/extensions/crx_installer.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/page_action_controller.h" 9 #include "chrome/browser/extensions/page_action_controller.h"
10 #include "chrome/browser/extensions/script_badge_controller.h" 10 #include "chrome/browser/extensions/script_badge_controller.h"
11 #include "chrome/browser/extensions/script_executor_impl.h" 11 #include "chrome/browser/extensions/script_executor.h"
12 #include "chrome/browser/extensions/webstore_inline_installer.h" 12 #include "chrome/browser/extensions/webstore_inline_installer.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/sessions/restore_tab_helper.h" 14 #include "chrome/browser/sessions/restore_tab_helper.h"
15 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/browser_dialogs.h" 16 #include "chrome/browser/ui/browser_dialogs.h"
17 #include "chrome/browser/ui/tab_contents/tab_contents.h" 17 #include "chrome/browser/ui/tab_contents/tab_contents.h"
18 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" 18 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
19 #include "chrome/browser/ui/web_applications/web_app_ui.h" 19 #include "chrome/browser/ui/web_applications/web_app_ui.h"
20 #include "chrome/browser/web_applications/web_app.h" 20 #include "chrome/browser/web_applications/web_app.h"
21 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
(...skipping 17 matching lines...) Expand all
39 #include "content/public/browser/web_contents_view.h" 39 #include "content/public/browser/web_contents_view.h"
40 #include "ui/gfx/image/image.h" 40 #include "ui/gfx/image/image.h"
41 41
42 using content::NavigationController; 42 using content::NavigationController;
43 using content::NavigationEntry; 43 using content::NavigationEntry;
44 using content::RenderViewHost; 44 using content::RenderViewHost;
45 using content::WebContents; 45 using content::WebContents;
46 using extensions::Extension; 46 using extensions::Extension;
47 using extensions::PageActionController; 47 using extensions::PageActionController;
48 using extensions::ScriptBadgeController; 48 using extensions::ScriptBadgeController;
49 using extensions::ScriptExecutorImpl; 49 using extensions::ScriptExecutor;
50 50
51 namespace { 51 namespace {
52 52
53 const char kPermissionError[] = "permission_error"; 53 const char kPermissionError[] = "permission_error";
54 54
55 } // namespace 55 } // namespace
56 56
57 ExtensionTabHelper::ExtensionTabHelper(TabContents* tab_contents) 57 ExtensionTabHelper::ExtensionTabHelper(TabContents* tab_contents)
58 : content::WebContentsObserver(tab_contents->web_contents()), 58 : content::WebContentsObserver(tab_contents->web_contents()),
59 extension_app_(NULL), 59 extension_app_(NULL),
60 ALLOW_THIS_IN_INITIALIZER_LIST( 60 ALLOW_THIS_IN_INITIALIZER_LIST(
61 extension_function_dispatcher_(tab_contents->profile(), this)), 61 extension_function_dispatcher_(tab_contents->profile(), this)),
62 pending_web_app_action_(NONE), 62 pending_web_app_action_(NONE),
63 tab_contents_(tab_contents), 63 tab_contents_(tab_contents),
64 script_executor_(new extensions::ScriptExecutor(
65 tab_contents->web_contents())),
64 active_tab_permission_manager_(tab_contents) { 66 active_tab_permission_manager_(tab_contents) {
65 if (extensions::switch_utils::AreScriptBadgesEnabled()) { 67 if (extensions::switch_utils::AreScriptBadgesEnabled()) {
66 script_badge_controller_ = new ScriptBadgeController(tab_contents); 68 location_bar_controller_.reset(new ScriptBadgeController(
69 tab_contents, script_executor_.get()));
67 } else { 70 } else {
68 script_executor_.reset(
69 new ScriptExecutorImpl(tab_contents->web_contents()));
70 location_bar_controller_.reset(new PageActionController(tab_contents)); 71 location_bar_controller_.reset(new PageActionController(tab_contents));
71 } 72 }
72 registrar_.Add(this, 73 registrar_.Add(this,
73 content::NOTIFICATION_LOAD_STOP, 74 content::NOTIFICATION_LOAD_STOP,
74 content::Source<NavigationController>( 75 content::Source<NavigationController>(
75 &tab_contents->web_contents()->GetController())); 76 &tab_contents->web_contents()->GetController()));
76 } 77 }
77 78
78 ExtensionTabHelper::~ExtensionTabHelper() { 79 ExtensionTabHelper::~ExtensionTabHelper() {
79 } 80 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 UpdateExtensionAppIcon(extension); 141 UpdateExtensionAppIcon(extension);
141 } 142 }
142 143
143 SkBitmap* ExtensionTabHelper::GetExtensionAppIcon() { 144 SkBitmap* ExtensionTabHelper::GetExtensionAppIcon() {
144 if (extension_app_icon_.empty()) 145 if (extension_app_icon_.empty())
145 return NULL; 146 return NULL;
146 147
147 return &extension_app_icon_; 148 return &extension_app_icon_;
148 } 149 }
149 150
150 extensions::ScriptExecutor* ExtensionTabHelper::script_executor() {
151 if (script_badge_controller_.get())
152 return script_badge_controller_.get();
153 return script_executor_.get();
154 }
155
156 extensions::LocationBarController*
157 ExtensionTabHelper::location_bar_controller() {
158 if (script_badge_controller_.get())
159 return script_badge_controller_.get();
160 return location_bar_controller_.get();
161 }
162
163 void ExtensionTabHelper::RenderViewCreated(RenderViewHost* render_view_host) { 151 void ExtensionTabHelper::RenderViewCreated(RenderViewHost* render_view_host) {
164 render_view_host->Send( 152 render_view_host->Send(
165 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), tab_id())); 153 new ExtensionMsg_SetTabId(render_view_host->GetRoutingID(), tab_id()));
166 } 154 }
167 155
168 void ExtensionTabHelper::DidNavigateMainFrame( 156 void ExtensionTabHelper::DidNavigateMainFrame(
169 const content::LoadCommittedDetails& details, 157 const content::LoadCommittedDetails& details,
170 const content::FrameNavigateParams& params) { 158 const content::FrameNavigateParams& params) {
171 if (details.is_in_page) 159 if (details.is_in_page)
172 return; 160 return;
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 // last committed entry is not NULL. Last committed entry could be NULL 456 // last committed entry is not NULL. Last committed entry could be NULL
469 // when an interstitial page is injected (e.g. bad https certificate, 457 // when an interstitial page is injected (e.g. bad https certificate,
470 // malware site etc). When this happens, we abort the shortcut update. 458 // malware site etc). When this happens, we abort the shortcut update.
471 NavigationEntry* entry = controller.GetLastCommittedEntry(); 459 NavigationEntry* entry = controller.GetLastCommittedEntry();
472 if (entry) 460 if (entry)
473 GetApplicationInfo(entry->GetPageID()); 461 GetApplicationInfo(entry->GetPageID());
474 else 462 else
475 pending_web_app_action_ = NONE; 463 pending_web_app_action_ = NONE;
476 } 464 }
477 } 465 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_tab_helper.h ('k') | chrome/browser/extensions/script_badge_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698