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

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

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