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

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

Issue 164458: Land http://codereview.chromium.org/159067: (Closed)
Patch Set: undo docs Created 11 years, 4 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
OLDNEW
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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_host.h" 5 #include "chrome/browser/extensions/extension_host.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "app/resource_bundle.h" 8 #include "app/resource_bundle.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "chrome/browser/browser.h" 10 #include "chrome/browser/browser.h"
11 #include "chrome/browser/browser_list.h" 11 #include "chrome/browser/browser_list.h"
12 #include "chrome/browser/debugger/devtools_manager.h" 12 #include "chrome/browser/debugger/devtools_manager.h"
13 #include "chrome/browser/extensions/extension_message_service.h" 13 #include "chrome/browser/extensions/extension_message_service.h"
14 #include "chrome/browser/extensions/extension_tabs_module.h"
14 #include "chrome/browser/profile.h" 15 #include "chrome/browser/profile.h"
15 #include "chrome/browser/renderer_host/render_view_host.h" 16 #include "chrome/browser/renderer_host/render_view_host.h"
16 #include "chrome/browser/renderer_host/render_process_host.h" 17 #include "chrome/browser/renderer_host/render_process_host.h"
17 #include "chrome/browser/renderer_host/render_widget_host.h" 18 #include "chrome/browser/renderer_host/render_widget_host.h"
18 #include "chrome/browser/renderer_host/render_widget_host_view.h" 19 #include "chrome/browser/renderer_host/render_widget_host_view.h"
19 #include "chrome/browser/renderer_host/site_instance.h" 20 #include "chrome/browser/renderer_host/site_instance.h"
20 #include "chrome/browser/tab_contents/infobar_delegate.h" 21 #include "chrome/browser/tab_contents/infobar_delegate.h"
21 #include "chrome/browser/tab_contents/tab_contents.h" 22 #include "chrome/browser/tab_contents/tab_contents.h"
22 #include "chrome/browser/tab_contents/tab_contents_view.h" 23 #include "chrome/browser/tab_contents/tab_contents_view.h"
23 #include "chrome/common/bindings_policy.h" 24 #include "chrome/common/bindings_policy.h"
24 #include "chrome/common/extensions/extension.h" 25 #include "chrome/common/extensions/extension.h"
25 #include "chrome/common/notification_service.h" 26 #include "chrome/common/notification_service.h"
26 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
27 #include "chrome/common/pref_service.h" 28 #include "chrome/common/pref_service.h"
29 #include "chrome/common/view_types.h"
28 #include "chrome/common/render_messages.h" 30 #include "chrome/common/render_messages.h"
29 #include "chrome/common/url_constants.h" 31 #include "chrome/common/url_constants.h"
30 32
31 #include "grit/browser_resources.h" 33 #include "grit/browser_resources.h"
32 #include "grit/generated_resources.h" 34 #include "grit/generated_resources.h"
33 #include "grit/theme_resources.h" 35 #include "grit/theme_resources.h"
34 36
35 #include "webkit/glue/context_menu.h" 37 #include "webkit/glue/context_menu.h"
36 38
37 namespace { 39 namespace {
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 DISALLOW_COPY_AND_ASSIGN(CrashedExtensionInfobarDelegate); 79 DISALLOW_COPY_AND_ASSIGN(CrashedExtensionInfobarDelegate);
78 }; 80 };
79 81
80 } // namespace 82 } // namespace
81 83
82 84
83 // static 85 // static
84 bool ExtensionHost::enable_dom_automation_ = false; 86 bool ExtensionHost::enable_dom_automation_ = false;
85 87
86 ExtensionHost::ExtensionHost(Extension* extension, SiteInstance* site_instance, 88 ExtensionHost::ExtensionHost(Extension* extension, SiteInstance* site_instance,
87 const GURL& url) 89 const GURL& url, ViewType::Type host_type)
88 : extension_(extension), 90 : extension_(extension),
89 profile_(site_instance->browsing_instance()->profile()), 91 profile_(site_instance->browsing_instance()->profile()),
90 did_stop_loading_(false), 92 did_stop_loading_(false),
91 document_element_available_(false), 93 document_element_available_(false),
92 url_(url) { 94 url_(url),
95 extension_host_type_(host_type) {
93 render_view_host_ = new RenderViewHost( 96 render_view_host_ = new RenderViewHost(
94 site_instance, this, MSG_ROUTING_NONE, NULL); 97 site_instance, this, MSG_ROUTING_NONE, NULL);
95 render_view_host_->AllowBindings(BindingsPolicy::EXTENSION); 98 render_view_host_->AllowBindings(BindingsPolicy::EXTENSION);
96 if (enable_dom_automation_) 99 if (enable_dom_automation_)
97 render_view_host_->AllowBindings(BindingsPolicy::DOM_AUTOMATION); 100 render_view_host_->AllowBindings(BindingsPolicy::DOM_AUTOMATION);
98 } 101 }
99 102
100 ExtensionHost::~ExtensionHost() { 103 ExtensionHost::~ExtensionHost() {
101 NotificationService::current()->Notify( 104 NotificationService::current()->Notify(
102 NotificationType::EXTENSION_HOST_DESTROYED, 105 NotificationType::EXTENSION_HOST_DESTROYED,
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 render_view_host()->process()->profile()); 381 render_view_host()->process()->profile());
379 // NOTE(rafaelw): This can return NULL in some circumstances. In particular, 382 // NOTE(rafaelw): This can return NULL in some circumstances. In particular,
380 // a toolstrip or background_page onload chrome.tabs api call can make it 383 // a toolstrip or background_page onload chrome.tabs api call can make it
381 // into here before the browser is sufficiently initialized to return here. 384 // into here before the browser is sufficiently initialized to return here.
382 // A similar situation may arise during shutdown. 385 // A similar situation may arise during shutdown.
383 // TODO(rafaelw): Delay creation of background_page until the browser 386 // TODO(rafaelw): Delay creation of background_page until the browser
384 // is available. http://code.google.com/p/chromium/issues/detail?id=13284 387 // is available. http://code.google.com/p/chromium/issues/detail?id=13284
385 return browser; 388 return browser;
386 } 389 }
387 390
391 ViewType::Type ExtensionHost::GetRenderViewType() const {
392 return extension_host_type_;
393 }
394
388 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { 395 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) {
389 // TODO(mpcomplete): This is duplicated in DidNavigate, which means that 396 // TODO(mpcomplete): This is duplicated in DidNavigate, which means that
390 // we'll create 2 EFDs for the first navigation. We should try to find a 397 // we'll create 2 EFDs for the first navigation. We should try to find a
391 // better way to unify them. 398 // better way to unify them.
392 // See http://code.google.com/p/chromium/issues/detail?id=18240 399 // See http://code.google.com/p/chromium/issues/detail?id=18240
393 extension_function_dispatcher_.reset( 400 extension_function_dispatcher_.reset(
394 new ExtensionFunctionDispatcher(render_view_host, this, url_)); 401 new ExtensionFunctionDispatcher(render_view_host, this, url_));
395 } 402 }
403
404 int ExtensionHost::GetBrowserWindowID() const {
405 int window_id = -1;
406 if (extension_host_type_ == ViewType::EXTENSION_TOOLSTRIP) {
407 window_id = ExtensionTabUtil::GetWindowId(
408 const_cast<ExtensionHost* >(this)->GetBrowser());
409 } else if (extension_host_type_ == ViewType::EXTENSION_BACKGROUND_PAGE) {
410 // Background page is not attached to any browser window, so pass -1.
411 window_id = -1;
412 } else {
413 NOTREACHED();
414 }
415 return window_id;
416 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/extensions/extension_process_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698