| OLD | NEW | 
|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_contents/render_view_host_delegate_helper.h" | 5 #include "chrome/browser/tab_contents/render_view_host_delegate_helper.h" | 
| 6 | 6 | 
| 7 #include <string> | 7 #include <string> | 
| 8 | 8 | 
| 9 #include "base/command_line.h" | 9 #include "base/command_line.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/background_contents_service.h" | 12 #include "chrome/browser/background_contents_service.h" | 
|  | 13 #include "chrome/browser/background_contents_service_factory.h" | 
| 13 #include "chrome/browser/character_encoding.h" | 14 #include "chrome/browser/character_encoding.h" | 
| 14 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" | 
| 15 #include "chrome/browser/gpu_data_manager.h" | 16 #include "chrome/browser/gpu_data_manager.h" | 
| 16 #include "chrome/browser/prefs/pref_service.h" | 17 #include "chrome/browser/prefs/pref_service.h" | 
| 17 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 18 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 
| 18 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" | 
| 19 #include "chrome/browser/tab_contents/background_contents.h" | 20 #include "chrome/browser/tab_contents/background_contents.h" | 
| 20 #include "chrome/browser/user_style_sheet_watcher.h" | 21 #include "chrome/browser/user_style_sheet_watcher.h" | 
| 21 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" | 
| 22 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" | 
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 57       extensions_service->GetExtensionByWebExtent(opener_url); | 58       extensions_service->GetExtensionByWebExtent(opener_url); | 
| 58   if (!extension) | 59   if (!extension) | 
| 59     return NULL; | 60     return NULL; | 
| 60 | 61 | 
| 61   // If the extension manifest specifies a background page, then don't allow one | 62   // If the extension manifest specifies a background page, then don't allow one | 
| 62   // to be created here. | 63   // to be created here. | 
| 63   if (extension->background_url().is_valid()) | 64   if (extension->background_url().is_valid()) | 
| 64     return NULL; | 65     return NULL; | 
| 65 | 66 | 
| 66   // Only allow a single background contents per app. | 67   // Only allow a single background contents per app. | 
| 67   if (!profile->GetBackgroundContentsService() || | 68   BackgroundContentsService* service = | 
| 68       profile->GetBackgroundContentsService()->GetAppBackgroundContents( | 69       BackgroundContentsServiceFactory::GetForProfile(profile); | 
|  | 70   if (!service || service->GetAppBackgroundContents( | 
| 69           ASCIIToUTF16(extension->id()))) | 71           ASCIIToUTF16(extension->id()))) | 
| 70     return NULL; | 72     return NULL; | 
| 71 | 73 | 
| 72   // Ensure that we're trying to open this from the extension's process. | 74   // Ensure that we're trying to open this from the extension's process. | 
| 73   ExtensionProcessManager* process_manager = | 75   ExtensionProcessManager* process_manager = | 
| 74       profile->GetExtensionProcessManager(); | 76       profile->GetExtensionProcessManager(); | 
| 75   if (!site->GetProcess() || !process_manager || | 77   if (!site->GetProcess() || !process_manager || | 
| 76       site->GetProcess() != process_manager->GetExtensionProcess(opener_url)) | 78       site->GetProcess() != process_manager->GetExtensionProcess(opener_url)) | 
| 77     return NULL; | 79     return NULL; | 
| 78 | 80 | 
| 79   // Passed all the checks, so this should be created as a BackgroundContents. | 81   // Passed all the checks, so this should be created as a BackgroundContents. | 
| 80   return profile->GetBackgroundContentsService()->CreateBackgroundContents( | 82   return service->CreateBackgroundContents(site, route_id, profile, frame_name, | 
| 81       site, route_id, profile, frame_name, ASCIIToUTF16(extension->id())); | 83                                            ASCIIToUTF16(extension->id())); | 
| 82 } | 84 } | 
| 83 | 85 | 
| 84 TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow( | 86 TabContents* RenderViewHostDelegateViewHelper::CreateNewWindow( | 
| 85     int route_id, | 87     int route_id, | 
| 86     Profile* profile, | 88     Profile* profile, | 
| 87     SiteInstance* site, | 89     SiteInstance* site, | 
| 88     WebUI::TypeID webui_type, | 90     WebUI::TypeID webui_type, | 
| 89     RenderViewHostDelegate* opener, | 91     RenderViewHostDelegate* opener, | 
| 90     WindowContainerType window_container_type, | 92     WindowContainerType window_container_type, | 
| 91     const string16& frame_name) { | 93     const string16& frame_name) { | 
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 375   DictionaryPrefUpdate update(profile->GetPrefs(), | 377   DictionaryPrefUpdate update(profile->GetPrefs(), | 
| 376                               prefs::kWebKitInspectorSettings); | 378                               prefs::kWebKitInspectorSettings); | 
| 377   DictionaryValue* inspector_settings = update.Get(); | 379   DictionaryValue* inspector_settings = update.Get(); | 
| 378   inspector_settings->SetWithoutPathExpansion(key, | 380   inspector_settings->SetWithoutPathExpansion(key, | 
| 379                                               Value::CreateStringValue(value)); | 381                                               Value::CreateStringValue(value)); | 
| 380 } | 382 } | 
| 381 | 383 | 
| 382 void RenderViewHostDelegateHelper::ClearInspectorSettings(Profile* profile) { | 384 void RenderViewHostDelegateHelper::ClearInspectorSettings(Profile* profile) { | 
| 383   profile->GetPrefs()->ClearPref(prefs::kWebKitInspectorSettings); | 385   profile->GetPrefs()->ClearPref(prefs::kWebKitInspectorSettings); | 
| 384 } | 386 } | 
| OLD | NEW | 
|---|