OLD | NEW |
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_web_ui.h" | 5 #include "chrome/browser/extensions/extension_web_ui.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/prefs/pref_service.h" | 11 #include "base/prefs/pref_service.h" |
12 #include "base/prefs/scoped_user_pref_update.h" | 12 #include "base/prefs/scoped_user_pref_update.h" |
13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage
r_private_api.h" | 15 #include "chrome/browser/extensions/api/bookmark_manager_private/bookmark_manage
r_private_api.h" |
16 #include "chrome/browser/extensions/extension_tab_util.h" | 16 #include "chrome/browser/extensions/extension_tab_util.h" |
17 #include "chrome/browser/extensions/extension_util.h" | 17 #include "chrome/browser/extensions/extension_util.h" |
18 #include "chrome/browser/favicon/favicon_service.h" | 18 #include "chrome/browser/favicon/favicon_service.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
21 #include "chrome/common/extensions/extension_constants.h" | 21 #include "chrome/common/extensions/extension_constants.h" |
22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
23 #include "components/favicon_base/favicon_util.h" | 23 #include "components/favicon_base/favicon_util.h" |
24 #include "components/pref_registry/pref_registry_syncable.h" | 24 #include "components/pref_registry/pref_registry_syncable.h" |
25 #include "content/public/browser/navigation_controller.h" | 25 #include "content/public/browser/navigation_controller.h" |
26 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
27 #include "content/public/browser/web_ui.h" | 27 #include "content/public/browser/web_ui.h" |
28 #include "content/public/common/bindings_policy.h" | 28 #include "content/public/common/bindings_policy.h" |
29 #include "content/public/common/page_transition_types.h" | |
30 #include "extensions/browser/extension_registry.h" | 29 #include "extensions/browser/extension_registry.h" |
31 #include "extensions/browser/image_loader.h" | 30 #include "extensions/browser/image_loader.h" |
32 #include "extensions/common/extension.h" | 31 #include "extensions/common/extension.h" |
33 #include "extensions/common/extension_icon_set.h" | 32 #include "extensions/common/extension_icon_set.h" |
34 #include "extensions/common/extension_resource.h" | 33 #include "extensions/common/extension_resource.h" |
35 #include "extensions/common/manifest_handlers/icons_handler.h" | 34 #include "extensions/common/manifest_handlers/icons_handler.h" |
36 #include "extensions/common/manifest_handlers/incognito_info.h" | 35 #include "extensions/common/manifest_handlers/incognito_info.h" |
37 #include "net/base/file_stream.h" | 36 #include "net/base/file_stream.h" |
38 #include "third_party/skia/include/core/SkBitmap.h" | 37 #include "third_party/skia/include/core/SkBitmap.h" |
| 38 #include "ui/base/page_transition_types.h" |
39 #include "ui/gfx/codec/png_codec.h" | 39 #include "ui/gfx/codec/png_codec.h" |
40 #include "ui/gfx/favicon_size.h" | 40 #include "ui/gfx/favicon_size.h" |
41 #include "ui/gfx/image/image_skia.h" | 41 #include "ui/gfx/image/image_skia.h" |
42 | 42 |
43 using content::WebContents; | 43 using content::WebContents; |
44 using extensions::Extension; | 44 using extensions::Extension; |
45 using extensions::URLOverrides; | 45 using extensions::URLOverrides; |
46 | 46 |
47 namespace { | 47 namespace { |
48 | 48 |
(...skipping 25 matching lines...) Expand all Loading... |
74 return; | 74 return; |
75 | 75 |
76 GURL url = web_contents->GetURL(); | 76 GURL url = web_contents->GetURL(); |
77 if (!url.SchemeIs(content::kChromeUIScheme) || url.host() != page) | 77 if (!url.SchemeIs(content::kChromeUIScheme) || url.host() != page) |
78 return; | 78 return; |
79 | 79 |
80 // Don't use Reload() since |url| isn't the same as the internal URL that | 80 // Don't use Reload() since |url| isn't the same as the internal URL that |
81 // NavigationController has. | 81 // NavigationController has. |
82 web_contents->GetController().LoadURL( | 82 web_contents->GetController().LoadURL( |
83 url, content::Referrer(url, blink::WebReferrerPolicyDefault), | 83 url, content::Referrer(url, blink::WebReferrerPolicyDefault), |
84 content::PAGE_TRANSITION_RELOAD, std::string()); | 84 ui::PAGE_TRANSITION_RELOAD, std::string()); |
85 } | 85 } |
86 | 86 |
87 // Run favicon callbck with image result. If no favicon was available then | 87 // Run favicon callbck with image result. If no favicon was available then |
88 // |image| will be empty. | 88 // |image| will be empty. |
89 void RunFaviconCallbackAsync( | 89 void RunFaviconCallbackAsync( |
90 const favicon_base::FaviconResultsCallback& callback, | 90 const favicon_base::FaviconResultsCallback& callback, |
91 const gfx::Image& image) { | 91 const gfx::Image& image) { |
92 std::vector<favicon_base::FaviconRawBitmapResult>* favicon_bitmap_results = | 92 std::vector<favicon_base::FaviconRawBitmapResult>* favicon_bitmap_results = |
93 new std::vector<favicon_base::FaviconRawBitmapResult>(); | 93 new std::vector<favicon_base::FaviconRawBitmapResult>(); |
94 | 94 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 // UseWebUIBindingsForURL). | 163 // UseWebUIBindingsForURL). |
164 int bindings = 0; | 164 int bindings = 0; |
165 web_ui->SetBindings(bindings); | 165 web_ui->SetBindings(bindings); |
166 | 166 |
167 // Hack: A few things we specialize just for the bookmark manager. | 167 // Hack: A few things we specialize just for the bookmark manager. |
168 if (extension->id() == extension_misc::kBookmarkManagerId) { | 168 if (extension->id() == extension_misc::kBookmarkManagerId) { |
169 bookmark_manager_private_drag_event_router_.reset( | 169 bookmark_manager_private_drag_event_router_.reset( |
170 new extensions::BookmarkManagerPrivateDragEventRouter( | 170 new extensions::BookmarkManagerPrivateDragEventRouter( |
171 profile, web_ui->GetWebContents())); | 171 profile, web_ui->GetWebContents())); |
172 | 172 |
173 web_ui->SetLinkTransitionType(content::PAGE_TRANSITION_AUTO_BOOKMARK); | 173 web_ui->SetLinkTransitionType(ui::PAGE_TRANSITION_AUTO_BOOKMARK); |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 ExtensionWebUI::~ExtensionWebUI() {} | 177 ExtensionWebUI::~ExtensionWebUI() {} |
178 | 178 |
179 extensions::BookmarkManagerPrivateDragEventRouter* | 179 extensions::BookmarkManagerPrivateDragEventRouter* |
180 ExtensionWebUI::bookmark_manager_private_drag_event_router() { | 180 ExtensionWebUI::bookmark_manager_private_drag_event_router() { |
181 return bookmark_manager_private_drag_event_router_.get(); | 181 return bookmark_manager_private_drag_event_router_.get(); |
182 } | 182 } |
183 | 183 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, | 432 extensions::ImageLoader::ImageRepresentation::ALWAYS_RESIZE, |
433 gfx::Size(pixel_size, pixel_size), | 433 gfx::Size(pixel_size, pixel_size), |
434 resource_scale_factor)); | 434 resource_scale_factor)); |
435 } | 435 } |
436 | 436 |
437 // LoadImagesAsync actually can run callback synchronously. We want to force | 437 // LoadImagesAsync actually can run callback synchronously. We want to force |
438 // async. | 438 // async. |
439 extensions::ImageLoader::Get(profile)->LoadImagesAsync( | 439 extensions::ImageLoader::Get(profile)->LoadImagesAsync( |
440 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); | 440 extension, info_list, base::Bind(&RunFaviconCallbackAsync, callback)); |
441 } | 441 } |
OLD | NEW |