OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_dom_ui.h" | 5 #include "chrome/browser/extensions/extension_dom_ui.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "net/base/file_stream.h" | 9 #include "net/base/file_stream.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/browser.h" | 12 #include "chrome/browser/browser.h" |
13 #include "chrome/browser/browser_list.h" | 13 #include "chrome/browser/browser_list.h" |
14 #include "chrome/browser/chrome_thread.h" | 14 #include "chrome/browser/chrome_thread.h" |
15 #include "chrome/browser/extensions/extension_bookmark_manager_api.h" | 15 #include "chrome/browser/extensions/extension_bookmark_manager_api.h" |
16 #include "chrome/browser/extensions/extensions_service.h" | 16 #include "chrome/browser/extensions/extensions_service.h" |
17 #include "chrome/browser/extensions/image_loading_tracker.h" | 17 #include "chrome/browser/extensions/image_loading_tracker.h" |
18 #include "chrome/browser/pref_service.h" | 18 #include "chrome/browser/pref_service.h" |
19 #include "chrome/browser/profile.h" | 19 #include "chrome/browser/profile.h" |
20 #include "chrome/browser/renderer_host/render_widget_host_view.h" | 20 #include "chrome/browser/renderer_host/render_widget_host_view.h" |
21 #include "chrome/browser/tab_contents/tab_contents.h" | 21 #include "chrome/browser/tab_contents/tab_contents.h" |
22 #include "chrome/common/bindings_policy.h" | 22 #include "chrome/common/bindings_policy.h" |
23 #include "chrome/common/page_transition_types.h" | 23 #include "chrome/common/page_transition_types.h" |
24 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 25 #include "chrome/common/extensions/extension_constants.h" |
25 #include "chrome/common/extensions/extension_resource.h" | 26 #include "chrome/common/extensions/extension_resource.h" |
26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
27 #include "gfx/codec/png_codec.h" | 28 #include "gfx/codec/png_codec.h" |
28 #include "gfx/favicon_size.h" | 29 #include "gfx/favicon_size.h" |
29 #include "third_party/skia/include/core/SkBitmap.h" | 30 #include "third_party/skia/include/core/SkBitmap.h" |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 // De-dupes the items in |list|. Assumes the values are strings. | 34 // De-dupes the items in |list|. Assumes the values are strings. |
34 void CleanUpDuplicates(ListValue* list) { | 35 void CleanUpDuplicates(ListValue* list) { |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // Use the NavigationController to get the URL rather than the TabContents | 137 // Use the NavigationController to get the URL rather than the TabContents |
137 // since this is the real underlying URL (see HandleChromeURLOverride). | 138 // since this is the real underlying URL (see HandleChromeURLOverride). |
138 NavigationController& controller = tab_contents()->controller(); | 139 NavigationController& controller = tab_contents()->controller(); |
139 const GURL& url = controller.GetActiveEntry()->url(); | 140 const GURL& url = controller.GetActiveEntry()->url(); |
140 extension_function_dispatcher_.reset( | 141 extension_function_dispatcher_.reset( |
141 ExtensionFunctionDispatcher::Create(render_view_host, this, url)); | 142 ExtensionFunctionDispatcher::Create(render_view_host, this, url)); |
142 DCHECK(extension_function_dispatcher_.get()); | 143 DCHECK(extension_function_dispatcher_.get()); |
143 } | 144 } |
144 | 145 |
145 void ExtensionDOMUI::ResetExtensionBookmarkManagerEventRouter() { | 146 void ExtensionDOMUI::ResetExtensionBookmarkManagerEventRouter() { |
146 extension_bookmark_manager_event_router_.reset( | 147 // Hack: A few things we specialize just for the bookmark manager. |
147 new ExtensionBookmarkManagerEventRouter(GetProfile(), tab_contents())); | 148 if (extension_function_dispatcher_->extension_id() == |
148 // We set the link transition type to AUTO_BOOKMARK for the bookmark manager. | 149 extension_misc::kBookmarkManagerId) { |
149 // This doesn't really belong here, but neither does this function. | 150 extension_bookmark_manager_event_router_.reset( |
150 // ExtensionDOMUI could potentially be used for extensions besides the | 151 new ExtensionBookmarkManagerEventRouter(GetProfile(), tab_contents())); |
151 // bookmark manager, but currently it does not. | 152 |
152 link_transition_type_ = PageTransition::AUTO_BOOKMARK; | 153 link_transition_type_ = PageTransition::AUTO_BOOKMARK; |
| 154 } |
153 } | 155 } |
154 | 156 |
155 void ExtensionDOMUI::RenderViewCreated(RenderViewHost* render_view_host) { | 157 void ExtensionDOMUI::RenderViewCreated(RenderViewHost* render_view_host) { |
156 ResetExtensionFunctionDispatcher(render_view_host); | 158 ResetExtensionFunctionDispatcher(render_view_host); |
157 ResetExtensionBookmarkManagerEventRouter(); | 159 ResetExtensionBookmarkManagerEventRouter(); |
158 } | 160 } |
159 | 161 |
160 void ExtensionDOMUI::RenderViewReused(RenderViewHost* render_view_host) { | 162 void ExtensionDOMUI::RenderViewReused(RenderViewHost* render_view_host) { |
161 ResetExtensionFunctionDispatcher(render_view_host); | 163 ResetExtensionFunctionDispatcher(render_view_host); |
162 ResetExtensionBookmarkManagerEventRouter(); | 164 ResetExtensionBookmarkManagerEventRouter(); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 } | 375 } |
374 | 376 |
375 // static | 377 // static |
376 void ExtensionDOMUI::GetFaviconForURL(Profile* profile, | 378 void ExtensionDOMUI::GetFaviconForURL(Profile* profile, |
377 FaviconService::GetFaviconRequest* request, const GURL& page_url) { | 379 FaviconService::GetFaviconRequest* request, const GURL& page_url) { |
378 // tracker deletes itself when done. | 380 // tracker deletes itself when done. |
379 ExtensionDOMUIImageLoadingTracker* tracker = | 381 ExtensionDOMUIImageLoadingTracker* tracker = |
380 new ExtensionDOMUIImageLoadingTracker(profile, request, page_url); | 382 new ExtensionDOMUIImageLoadingTracker(profile, request, page_url); |
381 tracker->Init(); | 383 tracker->Init(); |
382 } | 384 } |
OLD | NEW |