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

Side by Side Diff: chrome/browser/guest_view/extension_options/extension_options_guest.cc

Issue 497843002: GuestViews should be able to specify task manager entries (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More cleanup Created 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/guest_view/extension_options/extension_options_guest.h" 5 #include "chrome/browser/guest_view/extension_options/extension_options_guest.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h" 8 #include "chrome/browser/extensions/chrome_extension_web_contents_observer.h"
9 #include "chrome/browser/extensions/extension_tab_util.h" 9 #include "chrome/browser/extensions/extension_tab_util.h"
10 #include "chrome/browser/guest_view/extension_options/extension_options_constant s.h" 10 #include "chrome/browser/guest_view/extension_options/extension_options_constant s.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/task_manager/task_manager_util.h"
12 #include "chrome/browser/ui/browser.h" 13 #include "chrome/browser/ui/browser.h"
13 #include "chrome/browser/ui/browser_finder.h" 14 #include "chrome/browser/ui/browser_finder.h"
14 #include "chrome/browser/ui/browser_window.h" 15 #include "chrome/browser/ui/browser_window.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/extensions/api/extension_options_internal.h" 17 #include "chrome/common/extensions/api/extension_options_internal.h"
17 #include "chrome/common/extensions/manifest_url_handler.h" 18 #include "chrome/common/extensions/manifest_url_handler.h"
19 #include "chrome/grit/generated_resources.h"
18 #include "components/crx_file/id_util.h" 20 #include "components/crx_file/id_util.h"
19 #include "content/public/browser/render_process_host.h" 21 #include "content/public/browser/render_process_host.h"
20 #include "content/public/browser/site_instance.h" 22 #include "content/public/browser/site_instance.h"
21 #include "content/public/browser/web_contents.h" 23 #include "content/public/browser/web_contents.h"
22 #include "extensions/browser/extension_function_dispatcher.h" 24 #include "extensions/browser/extension_function_dispatcher.h"
23 #include "extensions/browser/extension_registry.h" 25 #include "extensions/browser/extension_registry.h"
24 #include "extensions/browser/guest_view/guest_view_manager.h" 26 #include "extensions/browser/guest_view/guest_view_manager.h"
25 #include "extensions/common/extension.h" 27 #include "extensions/common/extension.h"
26 #include "extensions/common/extension_messages.h" 28 #include "extensions/common/extension_messages.h"
27 #include "extensions/common/feature_switch.h" 29 #include "extensions/common/feature_switch.h"
28 #include "extensions/common/permissions/permissions_data.h" 30 #include "extensions/common/permissions/permissions_data.h"
29 #include "ipc/ipc_message_macros.h" 31 #include "ipc/ipc_message_macros.h"
30 32
31 using content::WebContents; 33 using content::WebContents;
32 using namespace extensions::api; 34 using namespace extensions::api;
33 35
34 // static 36 // static
35 const char ExtensionOptionsGuest::Type[] = "extensionoptions"; 37 const char ExtensionOptionsGuest::Type[] = "extensionoptions";
36 38
37 ExtensionOptionsGuest::ExtensionOptionsGuest( 39 ExtensionOptionsGuest::ExtensionOptionsGuest(
38 content::BrowserContext* browser_context, 40 content::BrowserContext* browser_context,
39 int guest_instance_id) 41 int guest_instance_id)
40 : GuestView<ExtensionOptionsGuest>(browser_context, guest_instance_id) { 42 : GuestView<ExtensionOptionsGuest>(browser_context, guest_instance_id) {
41 } 43 }
42 44
43 ExtensionOptionsGuest::~ExtensionOptionsGuest() { 45 ExtensionOptionsGuest::~ExtensionOptionsGuest() {
44 } 46 }
45 47
46 const char* ExtensionOptionsGuest::GetAPINamespace() {
47 return extensionoptions::kAPINamespace;
48 }
49
50 // static 48 // static
51 extensions::GuestViewBase* ExtensionOptionsGuest::Create( 49 extensions::GuestViewBase* ExtensionOptionsGuest::Create(
52 content::BrowserContext* browser_context, 50 content::BrowserContext* browser_context,
53 int guest_instance_id) { 51 int guest_instance_id) {
54 if (!extensions::FeatureSwitch::embedded_extension_options()->IsEnabled()) { 52 if (!extensions::FeatureSwitch::embedded_extension_options()->IsEnabled()) {
55 return NULL; 53 return NULL;
56 } 54 }
57 return new ExtensionOptionsGuest(browser_context, guest_instance_id); 55 return new ExtensionOptionsGuest(browser_context, guest_instance_id);
58 } 56 }
59 57
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 guest_web_contents()); 119 guest_web_contents());
122 } 120 }
123 121
124 void ExtensionOptionsGuest::DidStopLoading() { 122 void ExtensionOptionsGuest::DidStopLoading() {
125 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); 123 scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue());
126 DispatchEventToEmbedder(new extensions::GuestViewBase::Event( 124 DispatchEventToEmbedder(new extensions::GuestViewBase::Event(
127 extensions::api::extension_options_internal::OnLoad::kEventName, 125 extensions::api::extension_options_internal::OnLoad::kEventName,
128 args.Pass())); 126 args.Pass()));
129 } 127 }
130 128
129 const char* ExtensionOptionsGuest::GetAPINamespace() const {
130 return extensionoptions::kAPINamespace;
131 }
132
133 int ExtensionOptionsGuest::GetTaskPrefix() const {
134 return IDS_TASK_MANAGER_EXTENSIONOPTIONS_TAG_PREFIX;
135 }
136
131 content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const { 137 content::WebContents* ExtensionOptionsGuest::GetAssociatedWebContents() const {
132 return guest_web_contents(); 138 return guest_web_contents();
133 } 139 }
134 140
135 bool ExtensionOptionsGuest::OnMessageReceived(const IPC::Message& message) { 141 bool ExtensionOptionsGuest::OnMessageReceived(const IPC::Message& message) {
136 bool handled = true; 142 bool handled = true;
137 IPC_BEGIN_MESSAGE_MAP(ExtensionOptionsGuest, message) 143 IPC_BEGIN_MESSAGE_MAP(ExtensionOptionsGuest, message)
138 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) 144 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
139 IPC_MESSAGE_UNHANDLED(handled = false) 145 IPC_MESSAGE_UNHANDLED(handled = false)
140 IPC_END_MESSAGE_MAP() 146 IPC_END_MESSAGE_MAP()
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 content::OpenURLParams params(target_url, 217 content::OpenURLParams params(target_url,
212 content::Referrer(), 218 content::Referrer(),
213 NEW_FOREGROUND_TAB, 219 NEW_FOREGROUND_TAB,
214 content::PAGE_TRANSITION_LINK, 220 content::PAGE_TRANSITION_LINK,
215 false); 221 false);
216 browser->OpenURL(params); 222 browser->OpenURL(params);
217 // TODO(ericzeng): Open the tab in the background if the click was a 223 // TODO(ericzeng): Open the tab in the background if the click was a
218 // ctrl-click or middle mouse button click 224 // ctrl-click or middle mouse button click
219 return false; 225 return false;
220 } 226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698