| OLD | NEW |
| 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 "extensions/browser/guest_view/extension_options/extension_options_gues
t.h" | 5 #include "extensions/browser/guest_view/extension_options/extension_options_gues
t.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "components/crx_file/id_util.h" | 8 #include "components/crx_file/id_util.h" |
| 9 #include "content/public/browser/render_process_host.h" | 9 #include "content/public/browser/render_process_host.h" |
| 10 #include "content/public/browser/site_instance.h" | 10 #include "content/public/browser/site_instance.h" |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 // static | 34 // static |
| 35 const char ExtensionOptionsGuest::Type[] = "extensionoptions"; | 35 const char ExtensionOptionsGuest::Type[] = "extensionoptions"; |
| 36 | 36 |
| 37 ExtensionOptionsGuest::ExtensionOptionsGuest( | 37 ExtensionOptionsGuest::ExtensionOptionsGuest( |
| 38 content::BrowserContext* browser_context, | 38 content::BrowserContext* browser_context, |
| 39 int guest_instance_id) | 39 int guest_instance_id) |
| 40 : GuestView<ExtensionOptionsGuest>(browser_context, guest_instance_id), | 40 : GuestView<ExtensionOptionsGuest>(browser_context, guest_instance_id), |
| 41 extension_options_guest_delegate_( | 41 extension_options_guest_delegate_( |
| 42 extensions::ExtensionsAPIClient::Get() | 42 extensions::ExtensionsAPIClient::Get() |
| 43 ->CreateExtensionOptionsGuestDelegate(this)) { | 43 ->CreateExtensionOptionsGuestDelegate(this)), |
| 44 has_navigated_(false) { |
| 44 } | 45 } |
| 45 | 46 |
| 46 ExtensionOptionsGuest::~ExtensionOptionsGuest() { | 47 ExtensionOptionsGuest::~ExtensionOptionsGuest() { |
| 47 } | 48 } |
| 48 | 49 |
| 49 // static | 50 // static |
| 50 extensions::GuestViewBase* ExtensionOptionsGuest::Create( | 51 extensions::GuestViewBase* ExtensionOptionsGuest::Create( |
| 51 content::BrowserContext* browser_context, | 52 content::BrowserContext* browser_context, |
| 52 int guest_instance_id) { | 53 int guest_instance_id) { |
| 53 if (!extensions::FeatureSwitch::embedded_extension_options()->IsEnabled()) { | 54 if (!extensions::FeatureSwitch::embedded_extension_options()->IsEnabled()) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 // WebContents, so we can use |extension_url| for creating the SiteInstance. | 102 // WebContents, so we can use |extension_url| for creating the SiteInstance. |
| 102 content::SiteInstance* options_site_instance = | 103 content::SiteInstance* options_site_instance = |
| 103 content::SiteInstance::CreateForURL(browser_context(), extension_url); | 104 content::SiteInstance::CreateForURL(browser_context(), extension_url); |
| 104 WebContents::CreateParams params(browser_context(), options_site_instance); | 105 WebContents::CreateParams params(browser_context(), options_site_instance); |
| 105 params.guest_delegate = this; | 106 params.guest_delegate = this; |
| 106 callback.Run(WebContents::Create(params)); | 107 callback.Run(WebContents::Create(params)); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void ExtensionOptionsGuest::DidAttachToEmbedder() { | 110 void ExtensionOptionsGuest::DidAttachToEmbedder() { |
| 110 SetUpAutoSize(); | 111 SetUpAutoSize(); |
| 112 |
| 113 // We should not re-navigate on reattachment. |
| 114 if (has_navigated_) |
| 115 return; |
| 116 |
| 111 web_contents()->GetController().LoadURL(options_page_, | 117 web_contents()->GetController().LoadURL(options_page_, |
| 112 content::Referrer(), | 118 content::Referrer(), |
| 113 ui::PAGE_TRANSITION_LINK, | 119 ui::PAGE_TRANSITION_LINK, |
| 114 std::string()); | 120 std::string()); |
| 121 has_navigated_ = true; |
| 115 } | 122 } |
| 116 | 123 |
| 117 void ExtensionOptionsGuest::DidInitialize() { | 124 void ExtensionOptionsGuest::DidInitialize() { |
| 118 extension_function_dispatcher_.reset( | 125 extension_function_dispatcher_.reset( |
| 119 new extensions::ExtensionFunctionDispatcher(browser_context(), this)); | 126 new extensions::ExtensionFunctionDispatcher(browser_context(), this)); |
| 120 if (extension_options_guest_delegate_) { | 127 if (extension_options_guest_delegate_) { |
| 121 extension_options_guest_delegate_->DidInitialize(); | 128 extension_options_guest_delegate_->DidInitialize(); |
| 122 } | 129 } |
| 123 } | 130 } |
| 124 | 131 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 attach_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); | 259 attach_params()->GetInteger(extensionoptions::kAttributeMinWidth, &min_width); |
| 253 | 260 |
| 254 // Call SetAutoSize to apply all the appropriate validation and clipping of | 261 // Call SetAutoSize to apply all the appropriate validation and clipping of |
| 255 // values. | 262 // values. |
| 256 SetAutoSize(auto_size_enabled, | 263 SetAutoSize(auto_size_enabled, |
| 257 gfx::Size(min_width, min_height), | 264 gfx::Size(min_width, min_height), |
| 258 gfx::Size(max_width, max_height)); | 265 gfx::Size(max_width, max_height)); |
| 259 } | 266 } |
| 260 | 267 |
| 261 } // namespace extensions | 268 } // namespace extensions |
| OLD | NEW |